Commit c4c927e6 authored by Tom van Bussel's avatar Tom van Bussel
Browse files

Add a new filter for active committee memberships

parent 998cd827
...@@ -3,6 +3,7 @@ import csv ...@@ -3,6 +3,7 @@ import csv
import datetime import datetime
from django import forms from django import forms
from django.db.models import Q
from django.contrib import admin, messages from django.contrib import admin, messages
from django.contrib.auth.models import Permission from django.contrib.auth.models import Permission
from django.http import HttpResponse from django.http import HttpResponse
...@@ -138,12 +139,35 @@ class LectureYearFilter(admin.SimpleListFilter): ...@@ -138,12 +139,35 @@ class LectureYearFilter(admin.SimpleListFilter):
return queryset.exclude(until__lt=first_of_september) return queryset.exclude(until__lt=first_of_september)
class ActiveMembershipsFilter(admin.SimpleListFilter):
"""Filter the memberships by whether they are active or not"""
title = _('active memberships')
parameter_name = 'active'
def lookups(self, request, model_name):
return (
('active', _('Active')),
('inactive', _('Inactive')),
)
def queryset(self, request, queryset):
now = timezone.now()
if self.value() == 'active':
return queryset.filter(Q(until__isnull=True) |
Q(until__gte=now))
if self.value() == 'inactive':
return queryset.filter(until__lt=now)
@admin.register(models.CommitteeMembership) @admin.register(models.CommitteeMembership)
class CommitteeMembershipAdmin(TranslatedModelAdmin): class CommitteeMembershipAdmin(TranslatedModelAdmin):
"""Manage the committee memberships""" """Manage the committee memberships"""
form = CommitteeMembershipForm form = CommitteeMembershipForm
list_display = ('member', 'committee', 'since', 'until', 'chair', 'role') list_display = ('member', 'committee', 'since', 'until', 'chair', 'role')
list_filter = ('committee', BoardFilter, LectureYearFilter) list_filter = ('committee', BoardFilter, LectureYearFilter,
ActiveMembershipsFilter)
list_select_related = ('member', 'committee',) list_select_related = ('member', 'committee',)
search_fields = ('member__first_name', 'member__last_name', search_fields = ('member__first_name', 'member__last_name',
'member__email') 'member__email')
......
...@@ -7,8 +7,8 @@ msgid "" ...@@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-14 21:37+0100\n" "POT-Creation-Date: 2018-06-13 20:07+0200\n"
"PO-Revision-Date: 2018-03-14 21:38+0100\n" "PO-Revision-Date: 2018-06-13 20:08+0200\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n" "Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: \n" "Language-Team: \n"
"Language: nl\n" "Language: nl\n"
...@@ -16,25 +16,37 @@ msgstr "" ...@@ -16,25 +16,37 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.0.4\n" "X-Generator: Poedit 2.0.6\n"
#: admin.py:95 #: admin.py:100
msgid "board memberships" msgid "board memberships"
msgstr "Bestuurslidmaatschappen" msgstr "bestuurslidmaatschappen"
#: admin.py:100 #: admin.py:105
msgid "Only board memberships" msgid "Only board memberships"
msgstr "Alleen bestuurslidmaatschappen" msgstr "Alleen bestuurslidmaatschappen"
#: admin.py:101 #: admin.py:106
msgid "No board memberships" msgid "No board memberships"
msgstr "Geen bestuurslidmaatschappen" msgstr "Geen bestuurslidmaatschappen"
#: admin.py:114 #: admin.py:120
msgid "lecture year" msgid "lecture year"
msgstr "collegejaar" msgstr "collegejaar"
#: admin.py:147 #: admin.py:143
msgid "active memberships"
msgstr "actieve lidmaatschappen"
#: admin.py:148
msgid "Active"
msgstr "Actief"
#: admin.py:149
msgid "Inactive"
msgstr "Inactief"
#: admin.py:176
msgid "" msgid ""
"Do not edit existing memberships if the chair of a committee has changed, " "Do not edit existing memberships if the chair of a committee has changed, "
"add a new committeemembership instead." "add a new committeemembership instead."
...@@ -42,79 +54,79 @@ msgstr "" ...@@ -42,79 +54,79 @@ msgstr ""
"Pas geen bestaande lidmaatschappen aan als de voorzitter van een commissie " "Pas geen bestaande lidmaatschappen aan als de voorzitter van een commissie "
"is veranderd. Voeg in de plaats daarvan een nieuw commissielidmaatschap toe." "is veranderd. Voeg in de plaats daarvan een nieuw commissielidmaatschap toe."
#: admin.py:160 #: admin.py:189
msgid "First name" msgid "First name"
msgstr "Voornaam" msgstr "Voornaam"
#: admin.py:161 #: admin.py:190
msgid "Last name" msgid "Last name"
msgstr "Achernaam" msgstr "Achernaam"
#: admin.py:162 #: admin.py:191
msgid "Email" msgid "Email"
msgstr "Email" msgstr "Email"
#: admin.py:163 models.py:222 #: admin.py:192 models.py:227
msgid "Committee" msgid "Committee"
msgstr "Commissie" msgstr "Commissie"
#: admin.py:164 models.py:226 #: admin.py:193 models.py:231
msgid "Committee member since" msgid "Committee member since"
msgstr "Commissielid sinds" msgstr "Commissielid sinds"
#: admin.py:165 models.py:232 #: admin.py:194 models.py:237
msgid "Committee member until" msgid "Committee member until"
msgstr "Commissielid tot" msgstr "Commissielid tot"
#: admin.py:166 models.py:240 #: admin.py:195 models.py:245
msgid "Chair of the committee" msgid "Chair of the committee"
msgstr "Voorzitter van de commissie" msgstr "Voorzitter van de commissie"
#: admin.py:167 #: admin.py:196
msgid "Role" msgid "Role"
msgstr "Rol" msgstr "Rol"
#: admin.py:183 #: admin.py:212
msgid "Export selected memberships" msgid "Export selected memberships"
msgstr "Exporteer de geselecteerde lidmaatschappen" msgstr "Exporteer de geselecteerde lidmaatschappen"
#: apps.py:7 #: apps.py:9
msgid "Active members" msgid "Active members"
msgstr "Actieve leden" msgstr "Actieve leden"
#: models.py:56 #: models.py:57
msgid "Committee name" msgid "Committee name"
msgstr "Commissienaam" msgstr "Commissienaam"
#: models.py:62 #: models.py:63
msgid "Description" msgid "Description"
msgstr "Beschrijving" msgstr "Beschrijving"
#: models.py:66 #: models.py:67
msgid "Image" msgid "Image"
msgstr "Afbeelding" msgstr "Afbeelding"
#: models.py:79 #: models.py:80
msgid "permissions" msgid "permissions"
msgstr "permissies" msgstr "permissies"
#: models.py:84 #: models.py:85
msgid "founded in" msgid "founded in"
msgstr "opgericht in" msgstr "opgericht in"
#: models.py:90 #: models.py:91
msgid "existed until" msgid "existed until"
msgstr "bestond tot" msgstr "bestond tot"
#: models.py:98 #: models.py:99
msgid "contact email address" msgid "contact email address"
msgstr "contact e-mailadres" msgstr "contact e-mailadres"
#: models.py:105 #: models.py:106
msgid "contact mailing list" msgid "contact mailing list"
msgstr "contact mailinglijst" msgstr "contact mailinglijst"
#: models.py:112 #: models.py:113
msgid "Wiki namespace" msgid "Wiki namespace"
msgstr "Wiki namespace" msgstr "Wiki namespace"
...@@ -130,81 +142,81 @@ msgstr "commissie" ...@@ -130,81 +142,81 @@ msgstr "commissie"
msgid "committees" msgid "committees"
msgstr "commissies" msgstr "commissies"
#: models.py:164 #: models.py:168
msgid "Is this a board" msgid "Is this a board"
msgstr "Is dit een bestuur" msgstr "Is dit een bestuur"
#: models.py:171 #: models.py:175
msgid "Access the board wiki" msgid "Access the board wiki"
msgstr "Toegang tot bestuurswiki" msgstr "Toegang tot bestuurswiki"
#: models.py:197 models.py:198 #: models.py:200 models.py:201
msgid "A board already exists for those years" msgid "A board already exists for those years"
msgstr "Er bestaat al een bestuur voor die jaren" msgstr "Er bestaat al een bestuur voor die jaren"
#: models.py:216 models.py:360 #: models.py:221 models.py:364
msgid "Member" msgid "Member"
msgstr "Lid" msgstr "Lid"
#: models.py:227 #: models.py:232
msgid "The date this member joined the committee in this role" msgid "The date this member joined the committee in this role"
msgstr "De datum waarop deze persoon lid werd deze commissie in deze rol" msgstr "De datum waarop deze persoon lid werd deze commissie in deze rol"
#: models.py:233 #: models.py:238
msgid "A member of this committee until this time (can't be in the future)." msgid "A member of this committee until this time (can't be in the future)."
msgstr "" msgstr ""
"De datum waarop deze persoon de commissie verliet (kan niet in de toekomst " "De datum waarop deze persoon de commissie verliet (kan niet in de toekomst "
"liggen)" "liggen)"
#: models.py:241 #: models.py:246
msgid "There can only be one chair at a time!" msgid "There can only be one chair at a time!"
msgstr "Er kan maar één voorzitter tegelijkertijd zijn!" msgstr "Er kan maar één voorzitter tegelijkertijd zijn!"
#: models.py:247 #: models.py:252
msgid "role" msgid "role"
msgstr "rol" msgstr "rol"
#: models.py:248 #: models.py:253
msgid "The role of this member" msgid "The role of this member"
msgstr "De rol van dit lid binnen de commissie" msgstr "De rol van dit lid binnen de commissie"
#: models.py:276 #: models.py:280
msgid "End date can't be before start date" msgid "End date can't be before start date"
msgstr "De einddatum kan niet voor de startdatum liggen" msgstr "De einddatum kan niet voor de startdatum liggen"
#: models.py:279 #: models.py:283
msgid "End date can't be in the future" msgid "End date can't be in the future"
msgstr "De einddatum kan niet in de toekomst liggen" msgstr "De einddatum kan niet in de toekomst liggen"
#: models.py:284 #: models.py:288
msgid "Start date can't be before committee start date" msgid "Start date can't be before committee start date"
msgstr "De begindatum kan niet voor de begindatum van de commissie liggen" msgstr "De begindatum kan niet voor de begindatum van de commissie liggen"
#: models.py:289 #: models.py:293
msgid "Start date can't be after committee end date" msgid "Start date can't be after committee end date"
msgstr "De begindatum kan niet na de einddatum van de commissie liggen" msgstr "De begindatum kan niet na de einddatum van de commissie liggen"
#: models.py:294 #: models.py:298
msgid "End date cannot be set for boards" msgid "End date cannot be set for boards"
msgstr "Voor besturen kan geen einddatum worden opgegeven" msgstr "Voor besturen kan geen einddatum worden opgegeven"
#: models.py:317 #: models.py:320
msgid "There already is a chair for this time period" msgid "There already is a chair for this time period"
msgstr "Er is al een voorzitter voor deze periode" msgstr "Er is al een voorzitter voor deze periode"
#: models.py:334 #: models.py:337
msgid "This member is already in the committee for this period" msgid "This member is already in the committee for this period"
msgstr "Deze persoon is al lid van deze commissie in de aangegeven periode" msgstr "Deze persoon is al lid van deze commissie in de aangegeven periode"
#: models.py:352 #: models.py:355
msgid "committee membership" msgid "committee membership"
msgstr "commissielidmaatschap" msgstr "commissielidmaatschap"
#: models.py:353 #: models.py:356
msgid "committee memberships" msgid "committee memberships"
msgstr "commissielidmaatschappen" msgstr "commissielidmaatschappen"
#: models.py:365 #: models.py:369
#, python-brace-format #, python-brace-format
msgid "{name} mentor in {year}" msgid "{name} mentor in {year}"
msgstr "{name} mentor in {year}" msgstr "{name} mentor in {year}"
...@@ -299,7 +311,7 @@ msgstr "Commissielid sinds: ?" ...@@ -299,7 +311,7 @@ msgstr "Commissielid sinds: ?"
msgid "Committee member since: %(since)s" msgid "Committee member since: %(since)s"
msgstr "Commissielid sinds: %(since)s" msgstr "Commissielid sinds: %(since)s"
#: templates/activemembers/committee_detail.html:68 #: templates/activemembers/committee_detail.html:71
msgid "This committee doesn't have any members?" msgid "This committee doesn't have any members?"
msgstr "Deze commissie heeft geen leden?" msgstr "Deze commissie heeft geen leden?"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment