Skip to content

Commit

Permalink
Add customization for at-con
Browse files Browse the repository at this point in the history
Overrides the registration type form for the badge type options so we can show one-day badges and group reg at the same time during at-con mode
  • Loading branch information
kitsuta committed Sep 28, 2024
1 parent a366656 commit b759236
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 2 deletions.
3 changes: 1 addition & 2 deletions magwest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
from uber.utils import mount_site_sections, static_overrides

from magwest._version import __version__ # noqa: F401
from magwest.config import *


config = parse_config("magwest", Path(__file__).parents[0])
c.include_plugin_config(config)
mount_site_sections(config['module_root'])
static_overrides(join(config['module_root'], 'static'))
template_overrides(join(config['module_root'], 'templates'))
Expand Down
48 changes: 48 additions & 0 deletions magwest/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import math
from collections import defaultdict
from datetime import timedelta
from pathlib import Path
from markupsafe import Markup

from uber.config import c, Config, dynamic, parse_config
from uber.menu import MenuItem
from uber.utils import localized_now

config = parse_config("magwest", Path(__file__).parents[0])
c.include_plugin_config(config)

@Config.mixin
class ExtraConfig:
@property
def FORMATTED_BADGE_TYPES(self):
badge_types = []
if c.AT_THE_CON and self.ONE_DAYS_ENABLED and self.ONE_DAY_BADGE_AVAILABLE:
badge_types.append({
'name': 'Single Day',
'desc': 'Allows access to the convention for today. Can be upgraded to a weekend badge.',
'value': c.ONE_DAY_BADGE,
'price': c.ONEDAY_BADGE_PRICE
})
badge_types.append({
'name': 'Attendee',
'desc': 'Allows access to the convention for its duration.',
'value': c.ATTENDEE_BADGE,
'price': c.get_attendee_price()
})
if c.GROUPS_ENABLED and c.BEFORE_GROUP_PREREG_TAKEDOWN:
badge_types.append({
'name': "Group Leader",
'desc': Markup(f"Register a group of {c.MIN_GROUP_SIZE} people or more at ${c.GROUP_PRICE} per badge."
"<br/><br/><span class='form-text'>Please purchase badges for children 12 and under "
"separate from your group.</span>"),
'value': c.PSEUDO_GROUP_BADGE,
'price': c.GROUP_PRICE,
})
for badge_type in c.BADGE_TYPE_PRICES:
badge_types.append({
'name': c.BADGES[badge_type],
'desc': 'Donate extra to get an upgraded badge with perks.',
'value': badge_type,
'price': c.BADGE_TYPE_PRICES[badge_type]
})
return badge_types
28 changes: 28 additions & 0 deletions magwest/model_checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from datetime import datetime

from os.path import join

from residue import CoerceUTF8 as UnicodeText
from sqlalchemy.types import Boolean, Date
from uber.api import AttendeeLookup
from uber.config import c, Config
from uber.decorators import cost_property, prereg_validation, presave_adjustment, validation
from uber.menu import MenuItem
from uber.models import Choice, DefaultColumn as Column, Session
from uber.jinja import template_overrides
from uber.utils import localized_now, valid_email, get_age_from_birthday


@prereg_validation.Attendee
def attendee_badge_under_13(attendee):
if c.AT_THE_CON:
return

if not attendee.is_new and attendee.badge_status not in [c.PENDING_STATUS, c.AT_DOOR_PENDING_STATUS] \
or attendee.unassigned_group_reg or attendee.valid_placeholder:
return

if c.CHILD_BADGE in c.PREREG_BADGE_TYPES and attendee.birthdate and attendee.badge_type == c.ATTENDEE_BADGE and (
get_age_from_birthday(attendee.birthdate, c.NOW_OR_AT_CON) < 13):
return ('badge_type', "If you will be 12 or younger at the start of {}, "
"please select the 12 and Under badge instead of an Attendee badge.".format(c.EVENT_NAME))
22 changes: 22 additions & 0 deletions magwest/templates/forms/prereg_fields.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{%- import 'macros.html' as macros -%}
{% import 'forms/macros.html' as form_macros with context %}
{% set badge_extras = badge_extras or forms['badge_extras'] %}
{% set group_info = group_info or forms['group_info'] %}

{% if c.FORMATTED_REG_TYPES and c.FORMATTED_REG_TYPES|length > 1 and not c.AT_THE_CON %}
<div class="row g-sm-3">
{{ form_macros.card_select(badge_extras.badge_type,
c.FORMATTED_REG_TYPES, disabled_opts=c.UNAVAILABLE_REG_TYPES,
target_field_id="badge_type", disabled_card_text="Unavailable", label="Registration Type") }}
</div>
{% else %}
<div class="row g-sm-3">
{{ form_macros.card_select(badge_extras.badge_type,
attendee.available_badge_type_opts, disabled_opts=c.SOLD_OUT_BADGE_TYPES,
target_field_id=id_upgrade_prepend ~ "badge_type") }}
</div>
{% endif %}
{% if c.GROUPS_ENABLED %}
{{ form_macros.toggle_fields_js(badge_extras.badge_type, [group_info.name, group_info.badges],
on_values=[c.PSEUDO_GROUP_BADGE], toggle_required=True) }}
{% endif %}

0 comments on commit b759236

Please sign in to comment.