Skip to content

Commit

Permalink
Define wristband colors as constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Clark committed Mar 28, 2017
1 parent ff5cb9d commit 2091498
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
18 changes: 11 additions & 7 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 @@ -35,16 +36,16 @@ def lookup
def show
@memberships = @participant.memberships.all

building_statuses = @memberships.map { |m| m.organization.organization_category.building_status }
building = building_statuses.include?(true)
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 building
@wristband = "Red"
elsif is_building
@wristband = @wristband_colors[:building]
else
@wristband = "Blue"
@wristband = @wristband_colors[:nonbuilding]
end
end

Expand Down Expand Up @@ -92,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

This file was deleted.

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

0 comments on commit 2091498

Please sign in to comment.