Skip to content

Commit

Permalink
seems to work well in both collect birthday and not mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hdaws committed Feb 7, 2025
1 parent 973ccfa commit a82117d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions uber/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,7 @@ def _unrepr(d):
for _name, _section in _config['age_groups'].items():
_val = getattr(c, _name.upper())
c.AGE_GROUP_CONFIGS[_val] = dict(_section.dict(), val=_val)
c.AGE_GROUP_OPTS = [(key, value['desc']) for key,value in c.AGE_GROUP_CONFIGS.items()]

c.RECEIPT_DEPT_CATEGORIES = {}
for _name, _val in _config['enums']['receipt_item_dept'].items():
Expand Down
24 changes: 22 additions & 2 deletions uber/configspec.ini
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ shift_custom_badges = boolean(default=True)
# is turned on, then all registration forms will display and collect the exact
# birthdate. Turning this off will simply display a drop-down selection of the age
# groups defined below.
collect_exact_birthdate = boolean(default=False)
collect_exact_birthdate = boolean(default=True)

# Certain events need attendees' full addresses - others will only want some
# information. If this is turned off, attendees are only asked for their zipcode,
Expand Down Expand Up @@ -1392,7 +1392,7 @@ can_volunteer = boolean(default=True)
consent_form = boolean(default=False)

[[under_13]]
desc = string(default="Between 6 and 13")
desc = string(default="Between 6 and 12")
min_age = integer(default=6)
max_age = integer(default=12)
wristband_color = string(default="red")
Expand All @@ -1401,6 +1401,26 @@ can_register = boolean(default=True)
can_volunteer = boolean(default=False)
consent_form = boolean(default=True)

[[13_to_17]]
desc = string(default="Between 13 and 17")
min_age = integer(default=13)
max_age = integer(default=17)
wristband_color = string(default="yellow")
discount = integer(default=0)
can_register = boolean(default=True)
can_volunteer = boolean(default=False)
consent_form = boolean(default=True)

[[over_17]]
desc = string(default="18 and older")
min_age = integer(default=18)
max_age = integer(default=120)
wristband_color = string(default="green")
discount = integer(default=0)
can_register = boolean(default=True)
can_volunteer = boolean(default=True)
consent_form = boolean(default=True)

[[__many__]]
desc = string
min_age = integer
Expand Down
2 changes: 1 addition & 1 deletion uber/forms/attendee.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class PersonalInfo(AddressForm, MagForm):
else validators.Optional()])
age_group = SelectField('Age Group', validators=[
validators.DataRequired("Please select your age group.") if not c.COLLECT_EXACT_BIRTHDATE
else validators.Optional()], choices=c.AGE_GROUPS)
else validators.Optional()], choices=c.AGE_GROUP_OPTS)
ec_name = StringField('Emergency Contact Name', validators=[
validators.DataRequired("Please tell us the name of your emergency contact.")
], render_kw={'placeholder': 'Who we should contact if something happens to you'})
Expand Down
2 changes: 1 addition & 1 deletion uber/templates/forms/attendee/personal_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
{% if c.COLLECT_EXACT_BIRTHDATE %}
{{ form_macros.form_input(personal_info.birthdate, admin_text=attendee.age_group_conf.desc) }}
{% else %}
TBD
{{ form_macros.form_input(personal_info.age_group) }}
{% endif %}
</div>

Expand Down
2 changes: 1 addition & 1 deletion uber/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def get_age_conf_from_birthday(birthdate, today=None):
age = get_age_from_birthday(birthdate, today)

for val, age_group in c.AGE_GROUP_CONFIGS.items():
if val != c.AGE_UNKNOWN and age_group['min_age'] <= age and age <= age_group['max_age']:
if val != c.AGE_UNKNOWN and age_group['min_age'] <= age <= age_group['max_age']:
return age_group

return c.AGE_GROUP_CONFIGS[c.AGE_UNKNOWN]
Expand Down

0 comments on commit a82117d

Please sign in to comment.