Add filtering to kaehmy list

This commit is contained in:
Jan Tuomi
2017-10-18 12:13:14 +03:00
parent cd94c0d0f4
commit b3aec2b3e4
7 changed files with 79 additions and 38 deletions
Binary file not shown.
+22 -16
View File
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-18 11:11+0300\n"
"POT-Creation-Date: 2017-10-18 12:06+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -168,7 +168,7 @@ msgid "id"
msgstr "id"
#: infoscreen/templates/infoscreen_admin.html:141 webapp/models.py:110
#: webapp/models.py:144 webapp/templates/kaehmy_list.html:40
#: webapp/models.py:144 webapp/templates/kaehmy_list.html:36
msgid "Name"
msgstr "Name"
@@ -209,7 +209,7 @@ msgid "Last name"
msgstr "Last name"
#: members/models.py:16 webapp/models.py:145
#: webapp/templates/kaehmy_list.html:44
#: webapp/templates/kaehmy_list.html:40
msgid "Email"
msgstr "Email"
@@ -351,7 +351,7 @@ msgstr ""
#: members/templates/member_add_many.html:48
#: members/templates/member_add_many_confirm.html:22
#: webapp/templates/kaehmy_list.html:52
#: webapp/templates/kaehmy_list.html:48
msgid "Send"
msgstr "Send"
@@ -891,28 +891,34 @@ msgstr "Deadline to apply as a non-board official!"
msgid "Vaalikokous, osa 3 (toimarien valinta)"
msgstr "Election meeting, part 3 (non-board election)"
#: webapp/templates/kaehmy_list.html:24
#: webapp/templates/kaehmy_list.html:24 webapp/templates/kaehmy_list.html:59
msgid "All kaehmys"
msgstr "All applications"
#: webapp/templates/kaehmy_list.html:28
#: webapp/templates/kaehmy_list.html:32
msgid "Commenting on post by "
msgstr ""
#: webapp/templates/kaehmy_list.html:44
msgid "Comment"
msgstr ""
#: webapp/templates/kaehmy_list.html:57
#, fuzzy
#| msgid "List kaehmys"
msgid "Filter kaehmys"
msgstr "List applications"
#: webapp/templates/kaehmy_list.html:70
#: webapp/templates/kaehmy_statistics.html:18
msgid "Total kaehmys:"
msgstr "Total applications:"
#: webapp/templates/kaehmy_list.html:36
msgid "Commenting on post by "
msgstr ""
#: webapp/templates/kaehmy_list.html:48
msgid "Comment"
msgstr ""
#: webapp/templates/kaehmy_list.html:73
#: webapp/templates/kaehmy_list.html:88
msgid "Show comments"
msgstr ""
#: webapp/templates/kaehmy_list.html:79
#: webapp/templates/kaehmy_list.html:94
msgid "Add comment"
msgstr ""
Binary file not shown.
+20 -16
View File
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-18 11:11+0300\n"
"POT-Creation-Date: 2017-10-18 12:06+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -169,7 +169,7 @@ msgid "id"
msgstr "id"
#: infoscreen/templates/infoscreen_admin.html:141 webapp/models.py:110
#: webapp/models.py:144 webapp/templates/kaehmy_list.html:40
#: webapp/models.py:144 webapp/templates/kaehmy_list.html:36
msgid "Name"
msgstr "Nimi"
@@ -210,7 +210,7 @@ msgid "Last name"
msgstr "Sukunimi"
#: members/models.py:16 webapp/models.py:145
#: webapp/templates/kaehmy_list.html:44
#: webapp/templates/kaehmy_list.html:40
msgid "Email"
msgstr "Sähköposti"
@@ -356,7 +356,7 @@ msgstr ""
#: members/templates/member_add_many.html:48
#: members/templates/member_add_many_confirm.html:22
#: webapp/templates/kaehmy_list.html:52
#: webapp/templates/kaehmy_list.html:48
msgid "Send"
msgstr "Lähetä"
@@ -874,28 +874,32 @@ msgstr ""
msgid "Vaalikokous, osa 3 (toimarien valinta)"
msgstr ""
#: webapp/templates/kaehmy_list.html:24
#: webapp/templates/kaehmy_list.html:24 webapp/templates/kaehmy_list.html:59
msgid "All kaehmys"
msgstr "Kaikki kaehmyt"
#: webapp/templates/kaehmy_list.html:28
#: webapp/templates/kaehmy_list.html:32
msgid "Commenting on post by "
msgstr "Kommentoidaan viestiin lähettäjältä"
#: webapp/templates/kaehmy_list.html:44
msgid "Comment"
msgstr "Kommentti"
#: webapp/templates/kaehmy_list.html:57
msgid "Filter kaehmys"
msgstr "Rajaa kaehmyjä"
#: webapp/templates/kaehmy_list.html:70
#: webapp/templates/kaehmy_statistics.html:18
msgid "Total kaehmys:"
msgstr "Kaehmyjä yhteensä:"
#: webapp/templates/kaehmy_list.html:36
msgid "Commenting on post by "
msgstr "Kommentoidaan viestiin lähettäjältä"
#: webapp/templates/kaehmy_list.html:48
msgid "Comment"
msgstr "Kommentti"
#: webapp/templates/kaehmy_list.html:73
#: webapp/templates/kaehmy_list.html:88
msgid "Show comments"
msgstr "Näytä kommentit"
#: webapp/templates/kaehmy_list.html:79
#: webapp/templates/kaehmy_list.html:94
msgid "Add comment"
msgstr "Kommentoi"
+6
View File
@@ -18,3 +18,9 @@ div.tooltip-inner {
.tooltip {
margin-left: 1rem;
}
.role-filter-form {
max-width: 30rem;
width: auto;
margin-bottom: 1rem;
}
+19 -4
View File
@@ -24,10 +24,6 @@
<h2 style="padding-top: 1rem">{% trans "All kaehmys" %}</h2>
</div>
<div>
<h6 style="padding-bottom: 1rem">{% trans "Total kaehmys:" %} {{ application_count }}</h6>
</div>
<div class="collapse" id="collapse_add_comment">
<div class="card">
<div class="card-block">
@@ -56,6 +52,25 @@
</div>
</div>
<div>
<form class="role-filter-form form-inline" method="GET">
<label><strong>{% trans "Filter kaehmys" %}:</strong></label>
<select onchange="this.form.submit()" name="role" class="form-control">
<option value="-1">{% trans "All kaehmys" %}</option>
{% for option in filter_options %}
<option value={{ option.0 }} {% if request.GET.role|slugify == option.0|slugify %} selected="selected"{% endif %}>
{{ option.1 }} ({{ option.2 }})
</option>
{% endfor %}
</select>
</form>
</div>
<div>
<h6 style="padding-bottom: 1rem">{% trans "Total kaehmys:" %} {{ application_count }}</h6>
</div>
{% for application in applications %}
<div class="card">
<h4 class="card-header">{{ application.name }}</h4>
+12 -2
View File
@@ -1,5 +1,6 @@
"""Webapp views."""
from django.db.models import Count
from django.shortcuts import render, redirect
from django.contrib.auth import login, logout, authenticate
from django.views.decorators.http import require_http_methods
@@ -226,11 +227,20 @@ def ohlhafv_list(request, *args, **kwargs):
def kaehmy_list_view(request, *args, **kwargs):
"""Kaehmy application list"""
applications = KaehmyForm.objects.order_by('-timestamp')
role_filter = request.GET.get('role', None)
if role_filter is not None and str(role_filter) != '-1':
applications = KaehmyForm.objects.filter(custom_roles__id=role_filter) | KaehmyForm.objects.filter(preset_roles__id=role_filter)
else:
applications = KaehmyForm.objects.all()
applications = applications.order_by('-timestamp')
filter_options_preset = PresetKaehmyRole.objects.annotate(form_count=Count('forms')).filter(form_count__gt=0)
filter_options = [(r.id, r.name, r.form_count) for r in filter_options_preset]
context = {
'applications': applications,
'application_count': len(applications)
'application_count': len(applications),
'filter_options': filter_options
}
return render(request, 'kaehmy_list.html', context)