Unverified Commit afb3a7dc authored by Joost Rijneveld's avatar Joost Rijneveld
Browse files

Disallow committee membership end dates in future

This also fixes the is_staff constraint, as memberships
that ended today should not give staff access anymore. This is
a particularly important case, as this is typically what happens
when memberships end 'today' and the object is saved.
parent 96e454a6
...@@ -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: 2017-01-30 17:52+0100\n" "POT-Creation-Date: 2017-01-30 18:53+0100\n"
"PO-Revision-Date: 2017-01-30 17:53+0100\n" "PO-Revision-Date: 2017-01-30 18:54+0100\n"
"Last-Translator: Joost Rijneveld <joost@joostrijneveld.nl>\n" "Last-Translator: Joost Rijneveld <joost@joostrijneveld.nl>\n"
"Language-Team: \n" "Language-Team: \n"
"Language: nl\n" "Language: nl\n"
...@@ -66,7 +66,7 @@ msgstr "Is dit een bestuur" ...@@ -66,7 +66,7 @@ msgstr "Is dit een bestuur"
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:167 models.py:296 #: models.py:167 models.py:299
msgid "Member" msgid "Member"
msgstr "Lid" msgstr "Lid"
...@@ -112,27 +112,31 @@ msgstr "De rol van dit lid binnen de commissie" ...@@ -112,27 +112,31 @@ msgstr "De rol van dit lid binnen de commissie"
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:229 #: models.py:228
msgid "End date can't be in the future"
msgstr "De einddatum kan niet in de toekomst liggen"
#: models.py:232
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:252 #: models.py:255
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:268 #: models.py:271
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:288 #: models.py:291
msgid "committee membership" msgid "committee membership"
msgstr "commissielidmaatschap" msgstr "commissielidmaatschap"
#: models.py:289 #: models.py:292
msgid "committee memberships" msgid "committee memberships"
msgstr "commissielidmaatschappen" msgstr "commissielidmaatschappen"
#: models.py:301 #: models.py:304
#, 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}"
......
...@@ -223,6 +223,9 @@ class CommitteeMembership(models.Model, metaclass=ModelTranslateMeta): ...@@ -223,6 +223,9 @@ class CommitteeMembership(models.Model, metaclass=ModelTranslateMeta):
if self.until and (not self.since or self.until < self.since): if self.until and (not self.since or self.until < self.since):
raise ValidationError( raise ValidationError(
{'until': _("End date can't be before start date")}) {'until': _("End date can't be before start date")})
if self.until and self.until > timezone.now().date():
raise ValidationError(
{'until': _("End date can't be in the future")})
try: try:
if self.until and self.committee.board: if self.until and self.committee.board:
raise ValidationError( raise ValidationError(
...@@ -274,7 +277,7 @@ class CommitteeMembership(models.Model, metaclass=ModelTranslateMeta): ...@@ -274,7 +277,7 @@ class CommitteeMembership(models.Model, metaclass=ModelTranslateMeta):
self.member self.member
.committeemembership_set .committeemembership_set
.exclude( .exclude(
until__lt=timezone.now().date()) until__lte=timezone.now().date())
.count()) >= 1 .count()) >= 1
self.member.user.save() self.member.user.save()
......
Markdown is supported
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