Skip to content

Commit

Permalink
Merge pull request #1107 from CodingPirates/1105-fix-activity-require…
Browse files Browse the repository at this point in the history
…d-date-fields

Valider at dato-felter for aktivitet er udfyldt
  • Loading branch information
lakridserne authored Sep 16, 2024
2 parents 98a55a8 + 95f3308 commit b9b3cf4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion members/models/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,27 @@ def clean(self):
f"Prisen er for lav. Denne type aktivitet skal koste mindst {min_amount} kr."
)

if self.signup_closing > self.end_date:
if self.start_date is None:
errors["start_date"] = "Der skal angives en startdato for aktiviteten"

if self.end_date is None:
errors["end_date"] = "Der skal angives en slutdato for aktiviteten"

if self.signup_closing is None:
errors["signup_closing"] = "Der skal angives en dato for tilmeldingsfrist"

if (
(self.start_date is not None)
and (self.end_date is not None)
and (self.start_date > self.end_date)
):
errors["signup_closing"] = "Startdato skal være før aktivitetens slutdato"

if (
(self.signup_closing is not None)
and (self.end_date is not None)
and (self.signup_closing > self.end_date)
):
errors["signup_closing"] = (
"Tilmeldingsfristen skal være før aktiviteten slutter"
)
Expand Down

0 comments on commit b9b3cf4

Please sign in to comment.