Skip to content

Commit

Permalink
Add new fields to admin forms
Browse files Browse the repository at this point in the history
You couldn't save anyone as an admin due to these fields being missing. Whoops.
  • Loading branch information
kitsuta committed Mar 21, 2024
1 parent 370ca4e commit f5aceb4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
14 changes: 13 additions & 1 deletion magstock/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pockets.autolog import log

from uber.config import c
from uber.forms import (AddressForm, NumberInputGroup, MagForm, IntSelect, SwitchInput, HiddenIntField, SelectAvailableField, CustomValidation)
from uber.forms import (MagForm, HiddenBoolField, HiddenIntField, SelectAvailableField, CustomValidation)
from uber.custom_tags import popup_link, format_currency, pluralize, table_prices, email_to_link


Expand Down Expand Up @@ -50,6 +50,11 @@ def camping_type_desc(self):
'<a href="https://magstock.org/camping-info/" target="_blank">on our website</a>.')


@MagForm.form_mixin
class AdminBadgeExtras:
camping_type = SelectField('Camping Type', coerce=int, choices=c.CAMPING_TYPE_OPTS)


@MagForm.form_mixin
class Consents:
acknowledged_checkin_policy = BooleanField(
Expand Down Expand Up @@ -85,6 +90,13 @@ def get_optional_fields(self, attendee, is_admin=False):
return optional_fields


@MagForm.form_mixin
class AdminConsents:
acknowledged_checkin_policy = HiddenBoolField()
waiver_consent = HiddenBoolField()
waiver_date = DateField('Date of Signature')


@MagForm.form_mixin
class PreregOtherInfo:
first_name = HiddenField('First Name')
Expand Down
12 changes: 12 additions & 0 deletions magstock/templates/forms/attendee/admin_badge_extras.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends 'uber/templates/forms/attendee/admin_badge_extras.html' %}

{% block add_ons %}
{{ form_macros.toggle_fields_js(badge_extras.camping_type, [badge_extras.cabin_type], on_values=["267506057"], toggle_required=True,
closest_hide_selector='.form-floating') }}
<div class="row g-sm-3">
<div class="col-12 col-sm-6">{{ form_macros.form_input(badge_extras.camping_type) }}</div>
<div class="col-12 col-sm-6">{{ form_macros.form_input(badge_extras.cabin_type) }}</div>
</div>

{{ super() }}
{% endblock %}
12 changes: 12 additions & 0 deletions magstock/templates/forms/attendee/admin_consents.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends 'uber/templates/forms/attendee/admin_consents.html' %}

{% block required %}
{{ super() }}
{{ consents.acknowledged_checkin_policy }}
{{ consents.waiver_consent }}

<div class="row g-sm-3">
<div class="col-12 col-sm-6">{{ form_macros.form_input(consents.waiver_signature, readonly=True) }}</div>
<div class="col-12 col-sm-6">{{ form_macros.form_input(consents.waiver_date, readonly=True) }}</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion magstock/templates/forms/attendee/consents.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block required %}
{{ super() }}

{% if not attendee.is_new and attendee.badge_status != c.PENDING_STATUS %}
{% if 'transfer_badge' in c.PAGE_PATH or (not attendee.is_new and attendee.badge_status != c.PENDING_STATUS) %}
<div class="row g-sm-3">
<div class="col-12">{{ form_macros.form_input(consents.acknowledged_checkin_policy) }}</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion magstock/templates/forms/attendee/personal_info.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'uber/templates/forms/attendee/personal_info.html' %}

{% block address %}
{% if attendee.badge_type == c.PSEUDO_DEALER_BADGE %}
{% if attendee.badge_type == c.PSEUDO_DEALER_BADGE or 'transfer_badge' in c.PAGE_PATH %}
{# Hack to get around WTForms requiring a selection for choice fields #}
<input type="hidden" name="cabin_type" value="0" />
{% endif %}
Expand Down

0 comments on commit f5aceb4

Please sign in to comment.