forked from adamlaska/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
40 lines (32 loc) · 1.47 KB
/
views.py
File metadata and controls
40 lines (32 loc) · 1.47 KB
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
39
40
# Copyright The IETF Trust 2007, All Rights Reserved
import os
from django.shortcuts import get_object_or_404, render
import debug # pyflakes:ignore
from ietf.doc.models import State, StateType
from ietf.name.models import StreamName
def state_index(request):
types = StateType.objects.all()
names = [ type.slug for type in types ]
for type in types:
if "-" in type.slug and type.slug.split('-',1)[0] in names:
type.stategroups = None
else:
groups = StateType.objects.filter(slug__startswith=type.slug)
type.stategroups = [ g.slug[len(type.slug)+1:] for g in groups if not g == type ] or ""
return render(request, 'help/state_index.html', {"types": types})
def state(request, doc, type=None):
if type:
streams = [ s.slug for s in StreamName.objects.all() ]
if type in streams:
type = "stream-%s" % type
slug = "%s-%s" % (doc,type) if type else doc
statetype = get_object_or_404(StateType, slug=slug)
states = State.objects.filter(used=True, type=statetype).order_by('order')
return render(request, 'help/states.html', {"doc": doc, "type": statetype, "states":states} )
def environment(request):
if request.is_secure():
os.environ['SCHEME'] = "https"
else:
os.environ['SCHEME'] = "http"
os.environ["URL"] = request.build_absolute_uri(".")
return render(request, 'help/environment.html', {"env": os.environ} )