Verified Commit 3164fc5f authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Fix board validate_unique

parent a85fa932
...@@ -148,12 +148,19 @@ class Board(Committee): ...@@ -148,12 +148,19 @@ class Board(Committee):
def validate_unique(self, *args, **kwargs): def validate_unique(self, *args, **kwargs):
""" Check uniqueness""" """ Check uniqueness"""
super().validate_unique(*args, **kwargs) super().validate_unique(*args, **kwargs)
for board in Board.objects.filter(since__year=self.since.year, if self.since is not None and self.until is not None:
until__year=self.until.year): for board in Board.objects.filter(since__year=self.since.year,
if board != self: until__year=self.until.year):
raise ValidationError({ if board != self:
'since': _('A board already exists for those years'), raise ValidationError({
'until': _('A board already exists for those years')}) 'since': _('A board already exists for those years'),
'until': _('A board already exists for those years')})
elif self.since is not None:
for board in Board.objects.filter(since__lte=self.since,
until__gte=self.since):
if board != self:
raise ValidationError({
'since': _('A board already exists for those years')})
class ActiveMembershipManager(models.Manager): class ActiveMembershipManager(models.Manager):
......
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