Skip to content

Commit

Permalink
Added wristband field to participant view to help with wristband dist…
Browse files Browse the repository at this point in the history
…ribution #220
  • Loading branch information
Stephen Clark committed Mar 22, 2017
1 parent bbb4739 commit c037978
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
12 changes: 12 additions & 0 deletions app/controllers/participants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ def lookup
# GET /participants/1.json
def show
@memberships = @participant.memberships.all

building_statuses = @memberships.map { |m| m.organization.organization_category.building_status }
building = building_statuses.include?(true)
if @memberships.empty?
@wristband = "None - No organizations"
elsif !@participant.has_signed_waiver
@wristband = "None - No waiver signature"
elsif building
@wristband = "Red"
else
@wristband = "Blue"
end
end

# GET /participants/new
Expand Down
13 changes: 7 additions & 6 deletions app/models/organization_category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
#
# ### Columns
#
# Name | Type | Attributes
# ----------------- | ------------------ | ---------------------------
# **`created_at`** | `datetime` |
# **`id`** | `integer` | `not null, primary key`
# **`name`** | `string(255)` |
# **`updated_at`** | `datetime` |
# Name | Type | Attributes
# ---------------------- | ------------------ | ---------------------------
# **`building_status`** | `boolean` |
# **`created_at`** | `datetime` |
# **`id`** | `integer` | `not null, primary key`
# **`name`** | `string(255)` |
# **`updated_at`** | `datetime` |
#

class OrganizationCategory < ActiveRecord::Base
Expand Down
8 changes: 5 additions & 3 deletions app/views/participants/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
</div>

<dl class="dl-horizontal">
<dt><strong>Wristband:</strong></dt>
<dd><%= @wristband %></dd>
<dt><strong><%= model_class.human_attribute_name(:has_signed_waiver) %>:</strong></dt>
<dd><%= @participant.has_signed_waiver ? "Yes" : "No" %></dd>
<% if can?(:read_phone_number, @participant) %>
<dt><strong><%= model_class.human_attribute_name(:phone_number) %>:</strong></dt>
<dd><%= @participant.formatted_phone_number %>
<% end %>
<dt><strong><%= model_class.human_attribute_name(:has_signed_waiver) %>:</strong></dt>
<dd><%= @participant.has_signed_waiver ? "yes" : "no" %></dd>
<% end %>
<dt><strong><%= model_class.human_attribute_name(:department) %>:</strong></dt>
<dd><%= @participant.department %></dd>
<dt><strong><%= model_class.human_attribute_name(:student_class) %>:</strong></dt>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddBuildingStatusToOrganizationCategory < ActiveRecord::Migration
def change
add_column :organization_categories, :building_status, :boolean
end
end
16 changes: 8 additions & 8 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
# Organization Categories -----------------------------------------------------
puts 'Organization Categories'

fraternity = OrganizationCategory.create({ name: 'Fraternity'})
sorority = OrganizationCategory.create({ name: 'Sorority'})
independent = OrganizationCategory.create({ name: 'Independent'})
blitz = OrganizationCategory.create({ name: 'Blitz'})
concessions = OrganizationCategory.create({ name: 'Concessions'})
non_building = OrganizationCategory.create({ name: 'Non-Building' })
scc = OrganizationCategory.create({ name: 'SCC'})
staff = OrganizationCategory.create({ name: 'Staff' })
fraternity = OrganizationCategory.create({ name: 'Fraternity', building_status: true })
sorority = OrganizationCategory.create({ name: 'Sorority', building_status: true })
independent = OrganizationCategory.create({ name: 'Independent', building_status: true})
blitz = OrganizationCategory.create({ name: 'Blitz', building_status: true })
concessions = OrganizationCategory.create({ name: 'Concessions', building_status: true })
non_building = OrganizationCategory.create({ name: 'Non-Building', building_status: false })
scc = OrganizationCategory.create({ name: 'SCC', building_status: false })
staff = OrganizationCategory.create({ name: 'Staff', building_status: false })

# Organizations ---------------------------------------------------------------
puts 'Organizations'
Expand Down

0 comments on commit c037978

Please sign in to comment.