sort talks
This commit is contained in:
parent
858e579ab4
commit
2aecfe3abe
|
@ -13,7 +13,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
{% comment %}<th></th>{% endcomment %}
|
{% comment %}<th></th>{% endcomment %}
|
||||||
<th class="text-center">{% trans "Title" %} <a href="?{{ sort_urls.title }}"><span class="glyphicon glyphicon-{{ sort_glyphicons.title }} pull-right"></span></a></th>
|
<th class="text-center">{% trans "Title" %} <a href="?{{ sort_urls.title }}"><span class="glyphicon glyphicon-{{ sort_glyphicons.title }} pull-right"></span></a></th>
|
||||||
<th class="text-center">{% trans "Intervention kind" %} <a href="?{{ sort_urls.kind }}"><span class="glyphicon glyphicon-{{ sort_glyphicons.kind }} pull-right"></span></a></th>
|
<th class="text-center">{% trans "Intervention kind" %} <a href="?{{ sort_urls.category }}"><span class="glyphicon glyphicon-{{ sort_glyphicons.category }} pull-right"></span></a></th>
|
||||||
<th class="text-center">{% trans "Speakers" %}</th>
|
<th class="text-center">{% trans "Speakers" %}</th>
|
||||||
<th class="text-center">{% trans "Track" %}</th>
|
<th class="text-center">{% trans "Track" %}</th>
|
||||||
<th class="text-center">{% trans "Status" %} <a href="?{{ sort_urls.status }}"><span class="glyphicon glyphicon-{{ sort_glyphicons.status }} pull-right"></span></a></th>
|
<th class="text-center">{% trans "Status" %} <a href="?{{ sort_urls.status }}"><span class="glyphicon glyphicon-{{ sort_glyphicons.status }} pull-right"></span></a></th>
|
||||||
|
|
35
cfp/views.py
35
cfp/views.py
|
@ -132,8 +132,43 @@ def staff(request, conference):
|
||||||
@staff_required
|
@staff_required
|
||||||
def talk_list(request, conference):
|
def talk_list(request, conference):
|
||||||
talks = Talk.objects.filter(site=conference.site)
|
talks = Talk.objects.filter(site=conference.site)
|
||||||
|
# Sorting
|
||||||
|
if request.GET.get('order') == 'desc':
|
||||||
|
reverse = True
|
||||||
|
else:
|
||||||
|
reverse = False
|
||||||
|
SORT_MAPPING = {
|
||||||
|
'title': 'title',
|
||||||
|
'category': 'category',
|
||||||
|
'status': 'accepted',
|
||||||
|
}
|
||||||
|
sort = request.GET.get('sort')
|
||||||
|
if sort in SORT_MAPPING.keys():
|
||||||
|
if reverse:
|
||||||
|
talks = talks.order_by('-' + SORT_MAPPING[sort])
|
||||||
|
else:
|
||||||
|
talks = talks.order_by(SORT_MAPPING[sort])
|
||||||
|
# Sorting URLs
|
||||||
|
sort_urls = dict()
|
||||||
|
sort_glyphicons = dict()
|
||||||
|
for c in SORT_MAPPING.keys():
|
||||||
|
url = request.GET.copy()
|
||||||
|
url['sort'] = c
|
||||||
|
if c == sort:
|
||||||
|
if reverse:
|
||||||
|
del url['order']
|
||||||
|
glyphicon = 'sort-by-attributes-alt'
|
||||||
|
else:
|
||||||
|
url['order'] = 'desc'
|
||||||
|
glyphicon = 'sort-by-attributes'
|
||||||
|
else:
|
||||||
|
glyphicon = 'sort'
|
||||||
|
sort_urls[c] = url.urlencode()
|
||||||
|
sort_glyphicons[c] = glyphicon
|
||||||
return render(request, 'cfp/staff/talk_list.html', {
|
return render(request, 'cfp/staff/talk_list.html', {
|
||||||
'talk_list': talks,
|
'talk_list': talks,
|
||||||
|
'sort_urls': sort_urls,
|
||||||
|
'sort_glyphicons': sort_glyphicons,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue