diff --git a/magstock/forms.py b/magstock/forms.py index 22f46f3..bf3555c 100644 --- a/magstock/forms.py +++ b/magstock/forms.py @@ -9,7 +9,7 @@ from pockets.autolog import log from uber.config import c -from uber.forms import (MagForm, HiddenBoolField, HiddenIntField, SelectAvailableField, MultiCheckbox) +from uber.forms import (CustomValidation, MagForm, HiddenBoolField, HiddenIntField, SelectAvailableField, MultiCheckbox) from uber.custom_tags import popup_link, format_currency, pluralize, table_prices, email_to_link @@ -35,6 +35,8 @@ def license_plate_desc(self): @MagForm.form_mixin class BadgeExtras: + new_or_changed_validation = CustomValidation() + camping_type = HiddenIntField('How are you camping?') cabin_type = SelectAvailableField('Cabin Type', choices=[(0, 'Please select a cabin type')] + c.CABIN_TYPE_OPTS, @@ -52,6 +54,11 @@ 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, ' 'on our website.') + + @new_or_changed_validation.cabin_type + def cabin_sold_out(form, field): + if field.data in field.get_sold_out_list(): + raise ValidationError(f"Sorry, we're sold out of {c.CABIN_TYPES[field.data].lower()}s!") @MagForm.form_mixin @@ -96,8 +103,6 @@ def get_optional_fields(self, attendee, is_admin=False): @MagForm.form_mixin class AdminConsents: - acknowledged_checkin_policy = HiddenBoolField() - waiver_consent = HiddenBoolField() waiver_date = DateField('Date of Signature') diff --git a/magstock/model_checks.py b/magstock/model_checks.py index 8064fce..36f68e0 100644 --- a/magstock/model_checks.py +++ b/magstock/model_checks.py @@ -22,10 +22,3 @@ def waiver_consent(attendee): attendee.legal_first_name + ' ' + attendee.legal_last_name) elif attendee.waiver_date and attendee.waiver_date != datetime.utcnow().date(): return 'Your date of signature should be today' - - -@prereg_validation.Attendee -def cabin_sold_out(attendee): - if (attendee.is_new or attendee.orig_value_of('cabin_type') != attendee.cabin_type) \ - and attendee.cabin_type and c.CABIN_AVAILABILITY_MATRIX[attendee.cabin_type] < 1: - return "The type of cabin you have selected is sold out." diff --git a/magstock/models.py b/magstock/models.py index ce3ceaf..e897e38 100644 --- a/magstock/models.py +++ b/magstock/models.py @@ -51,7 +51,7 @@ def calc_camping_type_change(self, **kwargs): return int(current_cost) * 100, (int(new_cost) * 100) - (int(current_cost) * 100) def auto_update_receipt(self, params): - if params.get('camping_type') and params['camping_type'] != c.CABIN: + if params.get('camping_type') and int(params['camping_type']) != c.CABIN: params['cabin_type'] = 0 return params @@ -82,13 +82,13 @@ def available_cabin_types(self): @property def addons(self): addon_list = [] - if self.meal_plan: + if self.meal_plan and self.meal_plan != c.NO_FOOD: addon_list.append(f'{self.meal_plan_label} (${c.MEAL_PLAN_PRICES[self.meal_plan]})') if self.camping_type and self.camping_type == c.CABIN and self.cabin_type: - addon_list.append(f'{self.cabin_type_label} (${c.CABIN_TYPE_PRICES[self.cabin_type]})') + addon_list.append(f'{self.cabin_type_label}') elif self.camping_type and int(c.CAMPING_TYPE_PRICES[self.camping_type]): addon_list.append('{}{}{}'.format(self.camping_type_label, - ' parking pass' if self.camping_type in [c.CAR, c.RV] else '', + ' Parking Pass' if self.camping_type in [c.CAR, c.RV] else '', ' (${})'.format(c.CAMPING_TYPE_PRICES[self.camping_type]))) return addon_list diff --git a/magstock/templates/forms/attendee/admin_consents.html b/magstock/templates/forms/attendee/admin_consents.html index ae99fe6..6d91cb6 100644 --- a/magstock/templates/forms/attendee/admin_consents.html +++ b/magstock/templates/forms/attendee/admin_consents.html @@ -2,8 +2,9 @@ {% block required %} {{ super() }} -{{ consents.acknowledged_checkin_policy }} -{{ consents.waiver_consent }} + +{{ form_macros.form_input(consents.acknowledged_checkin_policy, force_hidden=True)}} +{{ form_macros.form_input(consents.waiver_consent, force_hidden=True)}}