Skip to content

Commit

Permalink
Merge pull request #250 from sc0v/wristband-dist
Browse files Browse the repository at this point in the history
  • Loading branch information
sclark authored Mar 28, 2017
2 parents de1891d + fd0a0d8 commit 97279ac
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 19 deletions.
20 changes: 18 additions & 2 deletions app/controllers/participants_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class ParticipantsController < ApplicationController
load_and_authorize_resource skip_load_resource only: [:create]
before_action :set_participant, only: [:show, :edit, :update, :destroy]

before_action :set_wristband_colors

# GET /participants
# GET /participants.json
def index
Expand Down Expand Up @@ -34,6 +35,18 @@ def lookup
# GET /participants/1.json
def show
@memberships = @participant.memberships.all

building_statuses = @memberships.map { |m| m.organization.organization_category.is_building }
is_building = building_statuses.include?(true)
if @memberships.empty?
@wristband = "None - No organizations"
elsif !@participant.has_signed_waiver
@wristband = "None - No waiver signature"
elsif is_building
@wristband = @wristband_colors[:building]
else
@wristband = @wristband_colors[:nonbuilding]
end
end

# GET /participants/new
Expand Down Expand Up @@ -80,5 +93,8 @@ def participant_create_params
def participant_update_params
params.require(:participant).permit(:phone_number, :has_signed_waiver, :has_signed_hardhat_waiver)
end
end

def set_wristband_colors
@wristband_colors = { :building => "Red", :nonbuilding => "Blue" }
end
end
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 AddIsBuildingToOrganizationCategory < ActiveRecord::Migration
def change
add_column :organization_categories, :is_building, :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 97279ac

Please sign in to comment.