Skip to content

Commit

Permalink
Require boards to have an end date (#3752)
Browse files Browse the repository at this point in the history
* Added a clean function to prevent broad with no start or stop date being created.

* Removed bogus test on line 255 which created a NoneType board.

---------

Co-authored-by: Lisanne Weidmann <[email protected]>
  • Loading branch information
DeD1rk and Lisanne Weidmann authored Jul 10, 2024
1 parent 9f366ea commit d9b6f55
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
17 changes: 17 additions & 0 deletions website/activemembers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,23 @@ def save(self, **kwargs):
self.active = True
super().save(**kwargs)

def clean(self):
if self.since is None:
raise ValidationError(
{
"since": _("Please insert a starting year for the new board."),
}
)

if self.until is None:
raise ValidationError(
{
"until": _(
"Please insert the year until when the board is active."
),
}
)

def get_absolute_url(self):
return reverse(
"activemembers:board", args=[str(self.since.year), str(self.until.year)]
Expand Down
3 changes: 0 additions & 3 deletions website/activemembers/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,5 @@ def test_create_unique_period2(self):
b.since = b.since.replace(year=1991, month=9, day=2)
b.full_clean()

b.until = None
b.full_clean()

def test_get_absolute_url(self):
self.testboard.get_absolute_url()

0 comments on commit d9b6f55

Please sign in to comment.