Skip to content

Commit

Permalink
Use dropdown for site numbers for consistency (#89)
Browse files Browse the repository at this point in the history
This is the most basic fix for #58. It requires running a DB migration. It simply converts the site_number field to a dropdown, and adds all the sites in via development-defaults.ini.
  • Loading branch information
kitsuta authored Jun 16, 2016
1 parent 4b2afb1 commit 5341385
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Change site_number to Choices column
Revision ID: 8b08c2523a1a
Revises: 6a885e4ac48d
Create Date: 2016-06-16 04:08:27.579294
"""

# revision identifiers, used by Alembic.
revision = '8b08c2523a1a'
down_revision = '6a885e4ac48d'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
import sideboard


def upgrade():
op.alter_column('attendee', 'site_number',
existing_type=sa.VARCHAR(),
nullable=True,
existing_server_default=sa.text("''::character varying"))
### end Alembic commands ###


def downgrade():
op.alter_column('attendee', 'site_number',
existing_type=sa.VARCHAR(),
nullable=False,
existing_server_default=sa.text("''::character varying"))
### end Alembic commands ###
48 changes: 48 additions & 0 deletions development-defaults.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[enums]
[[campsite]]
asp1 = "Aspin Point 001"
blake1 = "Bl Lakeside 001"
blue5 = "Blue 5"
brown4 = "Brown 4"
brown5 = "Brown 5"
brown7 = "Brown 7"
brown16 = "Brown 16"
brown17 = "Brown 17"
brown20 = "Brown 20"
purple11 = "Purple 11"
purple12 = "Purple 12"
purple14 = "Purple 14"
purple15 = "Purple 15"
purple16 = "Purple 16"
purple17 = "Purple 17"
purple19 = "Purple 19"
purple20 = "Purple 20"
purple27 = "Purple 27"
purple28 = "Purple 28"
purple33 = "Purple 33"
purple34 = "Purple 34"
purple35 = "Purple 35"
purple37 = "Purple 37"
purple38 = "Purple 38"
red2 = "Red 2"
red17 = "Red 17"
tent49 = "Tent 49"
tent50 = "Tent 50"
tent51 = "Tent 51"
tent52 = "Tent 52"
tent53 = "Tent 53"
tent54 = "Tent 54"
tent55 = "Tent 55"
tent56 = "Tent 56"
tent57 = "Tent 57"
tent58 = "Tent 58"
tent59 = "Tent 59"
tent75 = "Tent 75"
yellow1 = "Yellow 1"
yellow2 = "Yellow 2"
yellow3 = "Yellow 3"
yellow4 = "Yellow 4"
yellow10 = "Yellow 10"
yellow13 = "Yellow 13"
yellow21 = "Yellow 21"
bluejay = "Blue Jay"
4 changes: 2 additions & 2 deletions magstock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class Attendee:
noise_level = Column(Choice(c.NOISE_LEVEL_OPTS), nullable=True)
camping_type = Column(Choice(c.CAMPING_TYPE_OPTS), nullable=True)
purchased_food = Column(Boolean, default=False)
license_plate = Column(UnicodeText, default='')
site_number = Column(UnicodeText, default='')
license_plate = Column(UnicodeText, default='', admin_only=True)
site_number = Column(Choice(c.CAMPSITE_OPTS), nullable=True, admin_only=True)

@cost_property
def food_cost(self):
Expand Down
6 changes: 5 additions & 1 deletion magstock/configspec.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# The cost of a food wristband, which entitles attendees to meals provided by the event.
food_price = integer(default='20')
food_price = integer(default='20')

# A list of campsite numbers available to assign.
[enums]
[[campsite]]
9 changes: 6 additions & 3 deletions magstock/templates/regextra.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,17 @@
</div>

{% if c.PAGE_PATH == '/registration/form' %}
<div class="form-group" id="allergies">
<div class="form-group">
<label class="col-sm-2 control-label optional-field">Site Number</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="site_number" value="{{ attendee.site_number }}" placeholder="Admin-only field" />
<select name="site_number">
<option value="">Choose a campsite, if applicable</option>
{% options c.CAMPSITE_OPTS attendee.site_number %}
</select>
</div>
</div>

<div class="form-group" id="allergies">
<div class="form-group">
<label class="col-sm-2 control-label optional-field">License Plate</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="license_plate" value="{{ attendee.license_plate }}" placeholder="Admin-only field" />
Expand Down
7 changes: 6 additions & 1 deletion magstock/templates/registration/check_in_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
</tr>
<tr>
<td><strong>Site Number</strong></td>
<td><input type="text" id="site_{{ attendee.id }}" name="site_number" value="{{ attendee.site_number }}" /></td>
<td>
<select name="site_number">
<option value="">Choose a campsite, if applicable</option>
{% options c.CAMPSITE_OPTS attendee.site_number %}
</select>
</td>
</tr>
<tr>
<td><strong>License Plate</strong></td>
Expand Down
7 changes: 6 additions & 1 deletion magstock/templates/registration/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
{% endblock tableheadings %}

{% block tablerows %}
<td><input form="new_checkin" type="text" size="4" name="site_number" placeholder="Site" value="{{ attendee.site_number }}" /></td>
<td>
<select form="new_checkin" name="site_number">
<option value="">Choose a campsite, if applicable</option>
{% options c.CAMPSITE_OPTS attendee.site_number %}
</select>
</td>
<td><input form="new_checkin" type="text" size="8" name="license_plate" placeholder="License" value="{{ attendee.license_plate }}" /></td>
{{ block.super }}
{% endblock tablerows %}

0 comments on commit 5341385

Please sign in to comment.