summaryrefslogtreecommitdiff
path: root/pgweb/featurematrix/views.py
blob: 6798240536cc2b8bf2ae5e3e5b9130a55bef53e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from django.shortcuts import get_object_or_404

from pgweb.util.contexts import render_pgweb

from pgweb.core.models import Version
from .models import Feature


def root(request):
    features = Feature.objects.all().select_related().order_by('group__groupsort', 'group__groupname', 'featurename')
    groups = []
    lastgroup = -1
    currentgroup = None
    for f in features:
        if f.group.id != lastgroup:
            if currentgroup:
                groups.append(currentgroup)
            lastgroup = f.group.id
            currentgroup = {
                'group': f.group,
                'features': [],
            }
        currentgroup['features'].append(f)
    if currentgroup:
        groups.append(currentgroup)

    versions = Version.objects.filter(tree__gte='8.1').order_by('-tree')
    return render_pgweb(request, 'about', 'featurematrix/featurematrix.html', {
        'groups': groups,
        'versions': versions,
    })


def detail(request, featureid):
    feature = get_object_or_404(Feature, pk=featureid)
    return render_pgweb(request, 'about', 'featurematrix/featuredetail.html', {
        'feature': feature,
    })