From b3aec2b3e4f8f6b927733e2e5321d1a89074a540 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 18 Oct 2017 12:13:14 +0300 Subject: [PATCH] Add filtering to kaehmy list --- locale/en/LC_MESSAGES/django.mo | Bin 9502 -> 9502 bytes locale/en/LC_MESSAGES/django.po | 38 +++++++++++++++++------------- locale/fi/LC_MESSAGES/django.mo | Bin 12685 -> 12732 bytes locale/fi/LC_MESSAGES/django.po | 36 +++++++++++++++------------- webapp/static/css/webapp.css | 6 +++++ webapp/templates/kaehmy_list.html | 23 ++++++++++++++---- webapp/views.py | 14 +++++++++-- 7 files changed, 79 insertions(+), 38 deletions(-) diff --git a/locale/en/LC_MESSAGES/django.mo b/locale/en/LC_MESSAGES/django.mo index 9e44d41d4cc748161963923b355c7873a5d4fb41..d97e0dc5890c6de8a58d167f1cb1a25e6577388d 100644 GIT binary patch delta 17 YcmbQ|HP36qGzk_XD+9C5vm{!006Pu^`Tzg` delta 17 YcmbQ|HP36qGzk_%D?`K0vm{!006Ojk^#A|> diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po index 576a084..d5b3b4c 100644 --- a/locale/en/LC_MESSAGES/django.po +++ b/locale/en/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/locale/fi/LC_MESSAGES/django.mo b/locale/fi/LC_MESSAGES/django.mo index 97561be88c17e8ab7176c69b358d4ef254ae8c86..18db11325cac440b567e29aca22ccb98f060cf0b 100644 GIT binary patch delta 4483 zcmYk3e$p9-q(W_xXOlpU>y}{r;v!C3{M|Q%wWQ z9LE>rI#LzxT=NFb#l))Bxv>e(m0~g0VI4+dWmDgmuo3mun1O4NA>0vb{}!XEe~0mS z0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U(;9XC z0I!M$oQR$(DO6%G6}7}!sF8Lvd!afWgt|Zp>bQxveJ1LwdI9PluSQ*W8)_v!M!hXH zw*N2|(5`FG`m5tMIsS-qFuZiAho}&>RHHB!OHnH|5%mo?A9>Dh+AQ6thHZW>4v)Wg>dwY?qcS?GuwNEh4QA2pyMsPjruw`Kx{e;ZI8 zExeo(A9dYcsFk`0we%w}NxvE;;fiyQV+1?qAa9GCPu7q`qOz$nGuX`ALTxh{L|!KM z5~l1HlZNsD72Txaw&8gkO_q|86e#(VBH9DzE#5f4W|8ZlW*dIPxf2L@1t{%cmZC-YGYel#pA6wgOCQMredg=_xz*?#Ih$RlJQsUcNl sAQ?v55tUv(t~WkS?yoLNEQqRJmhxLnpi}owovIgRY>loS94cw@FN!se;{X5v diff --git a/locale/fi/LC_MESSAGES/django.po b/locale/fi/LC_MESSAGES/django.po index 3b28c11..9de7b01 100644 --- a/locale/fi/LC_MESSAGES/django.po +++ b/locale/fi/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \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" diff --git a/webapp/static/css/webapp.css b/webapp/static/css/webapp.css index 1a745fa..ff016f1 100644 --- a/webapp/static/css/webapp.css +++ b/webapp/static/css/webapp.css @@ -17,4 +17,10 @@ div.tooltip-inner { .tooltip { margin-left: 1rem; +} + +.role-filter-form { + max-width: 30rem; + width: auto; + margin-bottom: 1rem; } \ No newline at end of file diff --git a/webapp/templates/kaehmy_list.html b/webapp/templates/kaehmy_list.html index e9b81ca..8167801 100644 --- a/webapp/templates/kaehmy_list.html +++ b/webapp/templates/kaehmy_list.html @@ -24,10 +24,6 @@

{% trans "All kaehmys" %}

-
-
{% trans "Total kaehmys:" %} {{ application_count }}
-
-
@@ -56,6 +52,25 @@
+
+
+ + +
+
+ +
+
{% trans "Total kaehmys:" %} {{ application_count }}
+
+ + {% for application in applications %}

{{ application.name }}

diff --git a/webapp/views.py b/webapp/views.py index 9c3f522..3638425 100644 --- a/webapp/views.py +++ b/webapp/views.py @@ -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)