-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from magfest/stock2024
Convert dealer reg to new form system
- Loading branch information
Showing
24 changed files
with
290 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import cherrypy | ||
|
||
from markupsafe import Markup | ||
from wtforms import (BooleanField, DateField, EmailField, Form, FormField, | ||
HiddenField, SelectField, SelectMultipleField, IntegerField, | ||
StringField, TelField, validators, TextAreaField) | ||
from wtforms.validators import ValidationError, StopValidation | ||
from wtforms.widgets import html_params | ||
from pockets.autolog import log | ||
|
||
from uber.config import c | ||
from uber.forms import (AddressForm, NumberInputGroup, MagForm, IntSelect, SwitchInput, HiddenIntField, SelectAvailableField, CustomValidation) | ||
from uber.custom_tags import popup_link, format_currency, pluralize, table_prices, email_to_link | ||
|
||
|
||
@MagForm.form_mixin | ||
class PersonalInfo: | ||
license_plate = StringField('License Plate #', render_kw={'placeholder': 'XXX-XXXX'}) | ||
badge_printed_name = HiddenField('Badge Printed Name (Unused)') | ||
|
||
def get_optional_fields(self, attendee, is_admin=False): | ||
optional_list = self.super_get_optional_fields(attendee, is_admin) | ||
|
||
# This field is disabled/hidden, so it's never required | ||
optional_list.append('badge_printed_name') | ||
return optional_list | ||
|
||
def onsite_contact_label(self): | ||
return "MAGBuddy" | ||
|
||
def license_plate_desc(self): | ||
return ("Get through registration faster on-site! If you don't know which vehicle you'll be using, " | ||
"you can come back and update this later.") | ||
|
||
|
||
@MagForm.form_mixin | ||
class BadgeExtras: | ||
camping_type = HiddenIntField('How are you camping?') | ||
cabin_type = SelectAvailableField('Cabin Type', | ||
choices=[(0, 'Please select a cabin type')] + c.CABIN_TYPE_OPTS, | ||
default=0, coerce=int, | ||
sold_out_list_func=lambda: [cabin for cabin in c.CABIN_AVAILABILITY_MATRIX | ||
if c.CABIN_AVAILABILITY_MATRIX[cabin] < 1]) | ||
# Meal tickets go here | ||
|
||
def camping_type_desc(self): | ||
return Markup( | ||
'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>.') | ||
|
||
|
||
@MagForm.form_mixin | ||
class Consents: | ||
acknowledged_checkin_policy = BooleanField( | ||
Markup('<strong>I acknowledge that there is NO early check-in and if I show up on Wednesday night ' | ||
'then I will probably be asked to leave the campground.</strong>'), | ||
validators=[validators.InputRequired("You must acknowledge that early check-in is not possible.")]) | ||
waiver_signature = StringField( | ||
'Electronic Signature', | ||
validators=[validators.DataRequired("You must sign your full legal name to consent to the waiver.")]) | ||
waiver_date_display = DateField('Date of Signature', render_kw={'disabled': True}) | ||
waiver_date = HiddenField('Date of Signature (UTC)', | ||
validators=[validators.DataRequired("No date of signature." | ||
"Please refresh the page or contact us.")]) | ||
waiver_consent = BooleanField( | ||
Markup('<strong>Yes</strong>, I understand that checking this box constitutes a legal signature ' | ||
'confirming that I acknowledge and agree to the above waiver.'), | ||
validators=[validators.InputRequired("You must check the waiver consent checkbox.")]) | ||
|
||
def get_non_admin_locked_fields(self, attendee): | ||
if attendee.needs_pii_consent: | ||
return [] | ||
|
||
return ['pii_consent', 'acknowledged_checkin_policy', 'waiver_date', 'waiver_signature', 'waiver_consent'] | ||
|
||
def get_optional_fields(self, attendee, is_admin=False): | ||
optional_fields = self.super_get_optional_fields(attendee, is_admin) | ||
|
||
if (attendee.is_new or attendee.badge_status == c.PENDING_STATUS) or ( | ||
attendee.valid_placeholder and cherrypy.request.method == 'POST'): | ||
optional_fields.extend(['acknowledged_checkin_policy', 'waiver_date', | ||
'waiver_signature', 'waiver_consent']) | ||
|
||
return optional_fields | ||
|
||
|
||
@MagForm.form_mixin | ||
class PreregOtherInfo: | ||
first_name = HiddenField('First Name') | ||
last_name = HiddenField('Last Name') | ||
acknowledged_checkin_policy = Consents.acknowledged_checkin_policy | ||
waiver_signature = Consents.waiver_signature | ||
waiver_date_display = Consents.waiver_date_display | ||
waiver_date = Consents.waiver_date | ||
waiver_consent = Consents.waiver_consent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{% extends 'uber/templates/forms/attendee/badge_extras.html' %} | ||
|
||
{% set id_upgrade_prepend = "upgrade_" if upgrade_modal else "" %} | ||
|
||
{% block badge_type %} | ||
{{ super() }} | ||
{{ badge_extras.camping_type(id=id_upgrade_prepend ~ "camping_type") }} | ||
|
||
{% if not receipt or upgrade_modal %} | ||
<div class="row g-sm-3"> | ||
{{ form_macros.card_select(badge_extras.camping_type, | ||
c.FORMATTED_CAMPING_TYPES, disabled_opts=[], | ||
target_field_id=id_upgrade_prepend ~ "camping_type") }} | ||
</div> | ||
{{ form_macros.toggle_fields_js(badge_extras.camping_type, [badge_extras.cabin_type], on_values=["267506057"], toggle_required=True, | ||
closest_hide_selector='.row', | ||
source_field_id=id_upgrade_prepend ~ "camping_type", | ||
target_field_prepend=id_upgrade_prepend) }} | ||
{% elif not is_prereg_attendee %} | ||
<div class="row g-sm-3"> | ||
<div class="col-12 col-sm-6"> | ||
<div class="form-text">{{ badge_extras.camping_type.label.text }}</div> | ||
<div class="form-control-plaintext h5">{{ attendee.camping_type_label }}{% if attendee.camping_type != c.CABIN %}{{ macros.upgrade_button('camping-type') }}{% endif %}</div> | ||
</div> | ||
</div> | ||
{% endif %} | ||
|
||
{% if not receipt or upgrade_modal %} | ||
<div class="row g-sm-3"> | ||
<div class="col-12 col-sm-6">{{ form_macros.form_input(badge_extras.cabin_type, required=True, id=id_upgrade_prepend ~ "cabin_type") }}</div> | ||
</div> | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block upgrade_modal_js %} | ||
{{ super() }} | ||
|
||
{% if upgrade_modal %} | ||
<script type="text/javascript"> | ||
$(function () { | ||
var lastCampingType; // Still hate JavaScript | ||
$("#upgrade_camping_type").on('change', function() { | ||
if (lastCampingType !== undefined && this.value == lastCampingType) { | ||
return; | ||
} else { | ||
if (lastCampingType == "{{ c.CABIN }}" && this.value != "{{ c.CABIN }}") { | ||
updateReceiptPreview('cabin_type', ''); | ||
} | ||
lastCampingType = this.value; | ||
} | ||
updateReceiptPreview('camping_type', this.value); | ||
}); | ||
|
||
var lastCabinType; | ||
$("#upgrade_cabin_type").on('change', function() { | ||
if ($("#upgrade_camping_type").val() == "{{ c.CABIN }}") { | ||
updateReceiptPreview('cabin_type', this.value); | ||
} | ||
}) | ||
}); | ||
</script> | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{% extends 'uber/templates/forms/attendee/consents.html' %} | ||
|
||
{% block required %} | ||
{{ super() }} | ||
|
||
{% if 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> | ||
|
||
<div class="row mt-3"> | ||
<div class="col-12"> | ||
<p class="text-center"> | ||
<strong>We require all attendees to sign a waiver before registering.</strong> Please | ||
{{ macros.popup_link("../static_views/waiver.html", "view the waiver here") }}, then sign below. | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div class="row g-sm-3"> | ||
<div class="col-12 col-sm-6">{{ form_macros.form_input(consents.waiver_signature) }}</div> | ||
<div class="col-12 col-sm-6"> | ||
{{ form_macros.form_input(consents.waiver_date_display, value=now()|datetime_local("%Y-%m-%d")) }} | ||
{{ form_macros.form_input(consents.waiver_date, value=now()|datetime("%Y-%m-%d")) }} | ||
</div> | ||
</div> | ||
|
||
<div class="row g-sm-3"> | ||
<div class="col-12">{{ form_macros.form_input(consents.waiver_consent) }}</div> | ||
</div> | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends 'uber/templates/forms/attendee/other_info.html' %} | ||
|
||
{% block accessibility %} | ||
{% if not admin_area %} | ||
<div class="row mt-3 mb-3"> | ||
<div class="col-12">For accessibility-related needs or questions, please contact {{ "[email protected]"|email_to_link }}.</div> | ||
</div> | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% extends 'uber/templates/forms/attendee/personal_info.html' %} | ||
|
||
{% block address %} | ||
{% if attendee.badge_type == c.PSEUDO_DEALER_BADGE %} | ||
{# Hack to get around WTForms requiring a selection for choice fields #} | ||
<input type="hidden" name="cabin_type" value="0" /> | ||
{% endif %} | ||
|
||
<div class="row g-sm-3"> | ||
{{ super() }} | ||
<div class="col-12 col-sm-6">{{ form_macros.form_input(personal_info.license_plate) }}</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{% extends 'uber/templates/forms/attendee/prereg_other_info.html' %} | ||
|
||
{% block prereg_extras %} | ||
{{ super() }} | ||
|
||
<div class="row g-sm-3"> | ||
<div class="col-12">{{ form_macros.form_input(other_info.acknowledged_checkin_policy) }}</div> | ||
</div> | ||
|
||
<div class="row mt-3"> | ||
<div class="col-12"> | ||
<p class="text-center"> | ||
<strong>We require all attendees to sign a waiver before registering.</strong> Please | ||
{{ macros.popup_link("../static_views/waiver.html", "view the waiver here") }}, then sign below. | ||
</p> | ||
</div> | ||
</div> | ||
|
||
{# The waiver validation needs to check first/last name, so they need to exist on this form. #} | ||
{{ other_info.first_name }} | ||
{{ other_info.last_name }} | ||
|
||
<div class="row g-sm-3"> | ||
<div class="col-12 col-sm-6">{{ form_macros.form_input(other_info.waiver_signature) }}</div> | ||
<div class="col-12 col-sm-6"> | ||
{{ form_macros.form_input(other_info.waiver_date_display, value=now()|datetime_local("%Y-%m-%d")) }} | ||
{{ form_macros.form_input(other_info.waiver_date, value=now()|datetime("%Y-%m-%d")) }} | ||
</div> | ||
</div> | ||
|
||
<div class="row g-sm-3"> | ||
<div class="col-12">{{ form_macros.form_input(other_info.waiver_consent) }}</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.