Skip to content

Commit

Permalink
quasi working config...need to fix defaults and remove debug
Browse files Browse the repository at this point in the history
  • Loading branch information
hdaws committed Feb 7, 2025
1 parent 973ccfa commit 6d6038a
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 6 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
2 changes: 1 addition & 1 deletion 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
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
4 changes: 4 additions & 0 deletions uber/models/attendee.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,17 +950,21 @@ def promo_code_code(self):

@property
def age_discount(self):
print(f"HMD calculating age discount on attendee")
# We dynamically calculate the age discount to be half the
# current badge price. If for some reason the default discount
# (if it exists) is greater than half off, we use that instead.
print(f"HMD age now or at con {self.age_now_or_at_con}")
if self.age_now_or_at_con and self.age_now_or_at_con < 13:
half_off = math.ceil(self.new_badge_cost / 2)
if not self.age_group_conf['discount'] or self.age_group_conf['discount'] < half_off:
return -half_off
print(f"HMD did not trigger under thirteen.... returning self age group conf discount")
return -self.age_group_conf['discount']

@property
def age_group_conf(self):
print(f"HMD calling age_group_conf on attendee")
return get_age_conf_from_birthday(self.birthdate, c.NOW_OR_AT_CON)

@property
Expand Down
2 changes: 2 additions & 0 deletions uber/receipt_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ def badge_comp_credit(attendee, new_attendee=None):

@receipt_calculation.Attendee
def age_discount_credit(attendee, new_attendee=None):
print("HMD DEBUG IN age_discount_credit")
print(f"HMD DEBUG in age_discount_credit {attendee.age_discount}")
if not new_attendee and (not attendee.qualifies_for_discounts or not attendee.age_discount):
return
elif not new_attendee:
Expand Down
4 changes: 3 additions & 1 deletion uber/templates/forms/attendee.html
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,8 @@ <h4>{{ tier.name }}</h4>


{% if not c.COLLECT_EXACT_BIRTHDATE or full_read or c.SECURITY_ADMIN_ACCESS %}
<div>HMD DEBUG</div>
<div>{{ c.AGE_GROUP_CONFIGS|jsonize }}</div>
{% set age %}
{% set read_only = age_ro or page_ro %}
<script type="text/javascript">
Expand All @@ -1009,7 +1011,7 @@ <h4>{{ tier.name }}</h4>
{% if c.COLLECT_EXACT_BIRTHDATE %}
{% set post_text %}
{% if admin_area and attendee.birthdate %}
({{ attendee.age_group_conf.desc }})
<div>HMD REMEMBER TO PUT THIS BACK IT WAS BROKEN!</div>
{% endif %}
{% endset %}

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/templates/registration/index_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ <h5 class="modal-title">
<td id="ribbon_{{ attendee.id }}">{{ attendee.ribbon_labels|join(", ") }}</td>
{% if c.DONATION_TIER_OPTS|length > 1 %}<td id="amount_extra_{{ attendee.id }}">{{ attendee.amount_extra_label }}</td>{% endif %}
<td id="paid_{{ attendee.id }}" ><nobr>{{ attendee.paid_label }}</nobr></td>
<td> <nobr>{{ attendee.age_group_conf.desc }}</nobr> </td>
<td> <nobr> HMD FIX THIS AND PUT IT BACK IT IS BROKEN </nobr> </td>
{% if c.AT_THE_CON or c.BADGE_PICKUP_ENABLED %}
{% if attendee.checked_in %}
<td>
Expand Down
6 changes: 5 additions & 1 deletion uber/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,21 @@ def get_age_from_birthday(birthdate, today=None):


def get_age_conf_from_birthday(birthdate, today=None):
print(f"Age group configs {c.AGE_GROUP_CONFIGS}")
"""
Combines get_age_from_birthday with our age configuration groups
to allow easy access to age-related config when doing validations.
"""
if not birthdate:
print(f"NOT BIRTHDATE")
return c.AGE_GROUP_CONFIGS[c.AGE_UNKNOWN]

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']:
print(f"comparing to age_group min and max {age_group['min_age']} {age_group['max_age']}")
if val != c.AGE_UNKNOWN and age_group['min_age'] <= age <= age_group['max_age']:
print(f"returning age group match {age_group}")
return age_group

return c.AGE_GROUP_CONFIGS[c.AGE_UNKNOWN]
Expand Down

0 comments on commit 6d6038a

Please sign in to comment.