-
Notifications
You must be signed in to change notification settings - Fork 55
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 #4242 from magfest/prereg-launch-fixes
Fix several form and validation bugs for prereg launch
- Loading branch information
Showing
37 changed files
with
175 additions
and
163 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
60 changes: 60 additions & 0 deletions
60
alembic/versions/41c34c63d54c_remove_panels_interest_column_from_.py
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,60 @@ | ||
"""Remove panels_interest column from attendees | ||
Revision ID: 41c34c63d54c | ||
Revises: 9122d9b6f62c | ||
Create Date: 2023-09-13 22:08:44.699427 | ||
""" | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '41c34c63d54c' | ||
down_revision = '9122d9b6f62c' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
|
||
try: | ||
is_sqlite = op.get_context().dialect.name == 'sqlite' | ||
except Exception: | ||
is_sqlite = False | ||
|
||
if is_sqlite: | ||
op.get_context().connection.execute('PRAGMA foreign_keys=ON;') | ||
utcnow_server_default = "(datetime('now', 'utc'))" | ||
else: | ||
utcnow_server_default = "timezone('utc', current_timestamp)" | ||
|
||
def sqlite_column_reflect_listener(inspector, table, column_info): | ||
"""Adds parenthesis around SQLite datetime defaults for utcnow.""" | ||
if column_info['default'] == "datetime('now', 'utc')": | ||
column_info['default'] = utcnow_server_default | ||
|
||
sqlite_reflect_kwargs = { | ||
'listeners': [('column_reflect', sqlite_column_reflect_listener)] | ||
} | ||
|
||
# =========================================================================== | ||
# HOWTO: Handle alter statements in SQLite | ||
# | ||
# def upgrade(): | ||
# if is_sqlite: | ||
# with op.batch_alter_table('table_name', reflect_kwargs=sqlite_reflect_kwargs) as batch_op: | ||
# batch_op.alter_column('column_name', type_=sa.Unicode(), server_default='', nullable=False) | ||
# else: | ||
# op.alter_column('table_name', 'column_name', type_=sa.Unicode(), server_default='', nullable=False) | ||
# | ||
# =========================================================================== | ||
|
||
|
||
def upgrade(): | ||
with op.batch_alter_table("attendee") as batch_op: | ||
batch_op.drop_column('panel_interest') | ||
|
||
|
||
def downgrade(): | ||
op.add_column('attendee', sa.Column('panel_interest', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,8 @@ | |
# TODO: turn this into a proper validation class | ||
def valid_cellphone(form, field): | ||
if field.data and invalid_phone_number(field.data): | ||
raise ValidationError('The provided phone number was not a valid 10-digit US phone number. ' \ | ||
'Please include a country code (e.g. +44) for international numbers.') | ||
raise ValidationError('Please provide a valid 10-digit US phone number or ' \ | ||
'include a country code (e.g. +44) for international numbers.') | ||
|
||
class PersonalInfo(AddressForm, MagForm): | ||
field_validation, new_or_changed_validation = CustomValidation(), CustomValidation() | ||
|
@@ -55,7 +55,8 @@ class PersonalInfo(AddressForm, MagForm): | |
], | ||
render_kw={'placeholder': '[email protected]'}) | ||
cellphone = TelField('Phone Number', validators=[ | ||
validators.DataRequired("Please provide a phone number.") | ||
validators.DataRequired("Please provide a phone number."), | ||
valid_cellphone | ||
], render_kw={'placeholder': 'A phone number we can use to contact you during the event'}) | ||
birthdate = DateField('Date of Birth', validators=[ | ||
validators.DataRequired("Please enter your date of birth.") if c.COLLECT_EXACT_BIRTHDATE else validators.Optional(), | ||
|
@@ -67,7 +68,8 @@ class PersonalInfo(AddressForm, MagForm): | |
validators.DataRequired("Please tell us the name of your emergency contact.") | ||
], render_kw={'placeholder': 'Who we should contact if something happens to you'}) | ||
ec_phone = TelField('Emergency Contact Phone', validators=[ | ||
validators.DataRequired("Please give us an emergency contact phone number.") | ||
validators.DataRequired("Please give us an emergency contact phone number."), | ||
valid_cellphone | ||
], render_kw={'placeholder': 'A valid phone number for your emergency contact'}) | ||
onsite_contact = TextAreaField('Onsite Contact', validators=[ | ||
validators.DataRequired("Please enter contact information for at least one trusted friend onsite, \ | ||
|
@@ -161,15 +163,6 @@ def not_same_cellphone_ec(form, field): | |
if field.data and field.data == form.ec_phone.data: | ||
raise ValidationError("Your phone number cannot be the same as your emergency contact number.") | ||
|
||
@field_validation.ec_phone | ||
def valid_ec_phone(form, field): | ||
if not form.international.data and invalid_phone_number(field.data): | ||
if c.COLLECT_FULL_ADDRESS: | ||
raise ValidationError('Please enter a 10-digit US phone number or include a ' \ | ||
'country code (e.g. +44) for your emergency contact number.') | ||
else: | ||
raise ValidationError('Please enter a 10-digit emergency contact number.') | ||
|
||
|
||
class BadgeExtras(MagForm): | ||
field_validation, new_or_changed_validation = CustomValidation(), CustomValidation() | ||
|
@@ -245,11 +238,12 @@ def out_of_badge_type(form, field): | |
|
||
|
||
class OtherInfo(MagForm): | ||
dynamic_choices_fields = {'requested_depts_ids': lambda: [(v[0], v[1]) for v in c.PUBLIC_DEPARTMENT_OPTS_WITH_DESC] if len(c.PUBLIC_DEPARTMENT_OPTS_WITH_DESC) > 1 else c.JOB_INTEREST_OPTS} | ||
field_validation = CustomValidation() | ||
dynamic_choices_fields = {'requested_depts_ids': lambda: [(v[0], v[1]) for v in c.PUBLIC_DEPARTMENT_OPTS_WITH_DESC]} | ||
|
||
placeholder = BooleanField(widget=HiddenInput()) | ||
staffing = BooleanField('I am interested in volunteering!', widget=SwitchInput(), description=popup_link(c.VOLUNTEER_PERKS_URL, "What do I get for volunteering?")) | ||
requested_depts_ids = SelectMultipleField('Where do you want to help?', widget=MultiCheckbox()) # TODO: Show attendees department descriptions | ||
requested_depts_ids = SelectMultipleField('Where do you want to help?', coerce=int, widget=MultiCheckbox()) # TODO: Show attendees department descriptions | ||
requested_accessibility_services = BooleanField(f'I would like to be contacted by the {c.EVENT_NAME} Accessibility Services department prior to the event and I understand my contact information will be shared with Accessibility Services for this purpose.', widget=SwitchInput()) | ||
interests = SelectMultipleField('What interests you?', choices=c.INTEREST_OPTS, coerce=int, validators=[validators.Optional()], widget=MultiCheckbox()) | ||
|
||
|
@@ -271,12 +265,20 @@ def get_non_admin_locked_fields(self, attendee): | |
|
||
return locked_fields | ||
|
||
@field_validation.requested_depts_ids | ||
def select_requested_depts(form, field): | ||
if form.staffing.data and not field.data and len(c.PUBLIC_DEPARTMENT_OPTS_WITH_DESC) > 1: | ||
raise ValidationError('Please select the department(s) you would like to work for, or "Anything".') | ||
|
||
|
||
class PreregOtherInfo(OtherInfo): | ||
new_or_changed_validation = CustomValidation() | ||
|
||
promo_code_code = StringField('Promo Code') | ||
cellphone = TelField('Phone Number', description="A cellphone number is required for volunteers.", render_kw={'placeholder': 'A phone number we can use to contact you during the event'}) | ||
cellphone = TelField('Phone Number', description="A cellphone number is required for volunteers.", validators=[ | ||
# Required in model_checks because the staffing property is too complex to rely on per-form logic | ||
valid_cellphone | ||
], render_kw={'placeholder': 'A phone number we can use to contact you during the event'}) | ||
no_cellphone = BooleanField('I won\'t have a phone with me during the event.') | ||
|
||
def get_non_admin_locked_fields(self, attendee): | ||
|
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.