Skip to content

Commit

Permalink
Enforce being sold out of car/rv spaces serverside
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsuta committed May 8, 2024
1 parent 9cc1e73 commit 7bd5d9d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion magstock/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ def camping_type_desc(self):
'Car and RV camping is restricted to a field adjacent to the communal bathrooms. '
'Please review the information about camping options, including cabin type descriptions, '
'<a href="https://magstock.org/camping-info/" target="_blank">on our website</a>.')


@new_or_changed_validation.camping_type
def car_or_rv_sold_out(form, field):
if field.data == c.CAR and c.CAR in c.SOLD_OUT_CAMPING_TYPES:
raise ValidationError(f"Sorry, we're sold out of car camping spaces!")
if field.data == c.RV and c.RV in c.SOLD_OUT_CAMPING_TYPES:
raise ValidationError(f"Sorry, we're sold out of RV spaces!")

@new_or_changed_validation.cabin_type
def cabin_sold_out(form, field):
if field.data in field.get_sold_out_list():
Expand Down

0 comments on commit 7bd5d9d

Please sign in to comment.