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):
def validate_unique(self, *args, **kwargs):
""" Check uniqueness"""
super().validate_unique(*args, **kwargs)
if self.since is not None and self.until is not None:
for board in Board.objects.filter(since__year=self.since.year,
until__year=self.until.year):
if board != self:
raise ValidationError({
'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):
......
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