render_to release show html def release_show request project_slug rele

 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
41
42
43
44
45
46
47
48
49
50
51
@render_to('release/show.html')
def release_show(request, project_slug, release_pk):
release = get_object_or_404(Release, project=request.project, pk=release_pk)
username = request.GET.get('user', '')
context = calculate_progress(release, username)
try:
visibility = int(request.GET.get('visibility', 'nan'))
except ValueError:
visibility = None
if not visibility in [0] + [x[0] for x in settings.STATUS_VISIBILITY]:
visibility = settings.VISIBILITY_ACTIVE
orm_sort_key, sort_string = parse_sort_argument(request.GET.get('sort', ''))
qs_params = '?visibility=%s&sort=%s&features=%s&user=%s' % (
visibility, sort_string, request.GET.get('features', ''),
username)
if 'visibility' in request.GET:
form = ReleaseFilterForm(request.GET)
else:
form = ReleaseFilterForm(initial={'visibility': visibility,
'sort': sort_string,
'user': '',
'features': ''})
rtasks = form.filter(release, visibility)\
.order_by(orm_sort_key)\
.select_related('task__task_type', 'task__status',
'task__priority', 'task__project')
next = request.path + urllib.quote(qs_params.encode('utf-8'), safe='?')
context.update({'rtasks': rtasks,
'release': release,
'sort': sort_string,
'sort_key': sort_string.split('_')[0],
'qs_params': qs_params,
'visibility': visibility,
'VISIBILITY_ACTIVE': settings.VISIBILITY_ACTIVE,
'VISIBILITY_DONE': settings.VISIBILITY_DONE,
'VISIBILITY_CLOSED': settings.VISIBILITY_CLOSED,
'VISIBILITY_ALL': 0,
'next': next,
'form': form,
})
return context