Skip to content

Commit

Permalink
Add ability to sell out of car/RV spots
Browse files Browse the repository at this point in the history
Requested via Slack.
  • Loading branch information
kitsuta committed May 8, 2024
1 parent ba4285d commit 9cc1e73
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions magstock/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class ExtraConfig:
@property
def FORMATTED_CAMPING_TYPES(self):
# Returns camping type options for the 'card_select' form macro.

return [
{'name': 'Tent', 'icon': '', 'link': '', 'value': c.TENT, 'price': c.CAMPING_TYPE_PRICES[c.TENT],
'desc': 'Included in your registration! Tent camping is first come, first serve.'},
Expand All @@ -38,7 +37,18 @@ def FORMATTED_CAMPING_TYPES(self):
'price': 0,
'desc': 'Select a cabin option below. Cabins are limited availability.'}
]


@property
def SOLD_OUT_CAMPING_TYPES(self):
sold_out_types = []
if c.CAR_STOCK and c.CAMPING_TYPES_BOUGHT[c.CAR] <= int(c.CAR_STOCK):
sold_out_types.append(c.CAR)
if c.RV_STOCK and c.CAMPING_TYPES_BOUGHT[c.RV] <= int(c.RV_STOCK):
sold_out_types.append(c.RV)
if not any(c.CABIN_AVAILABILITY_MATRIX.values()):
sold_out_types.append(c.CABIN)
return sold_out_types

@property
def FORMATTED_MEAL_PLANS(self):
return [
Expand Down
2 changes: 1 addition & 1 deletion magstock/templates/forms/attendee/badge_extras.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{% 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=[],
c.FORMATTED_CAMPING_TYPES, disabled_opts=c.SOLD_OUT_CAMPING_TYPES,
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,
Expand Down

0 comments on commit 9cc1e73

Please sign in to comment.