diff --git a/app/controllers/participants_controller.rb b/app/controllers/participants_controller.rb index 6b0e2b2c..eef49089 100644 --- a/app/controllers/participants_controller.rb +++ b/app/controllers/participants_controller.rb @@ -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 @@ -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 @@ -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 diff --git a/app/models/organization_category.rb b/app/models/organization_category.rb index ae501a71..51529665 100644 --- a/app/models/organization_category.rb +++ b/app/models/organization_category.rb @@ -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 diff --git a/app/views/participants/show.html.erb b/app/views/participants/show.html.erb index 016bcc17..9751d33a 100644 --- a/app/views/participants/show.html.erb +++ b/app/views/participants/show.html.erb @@ -5,12 +5,14 @@
+
Wristband:
+
<%= @wristband %>
+
<%= model_class.human_attribute_name(:has_signed_waiver) %>:
+
<%= @participant.has_signed_waiver ? "Yes" : "No" %>
<% if can?(:read_phone_number, @participant) %>
<%= model_class.human_attribute_name(:phone_number) %>:
<%= @participant.formatted_phone_number %> - <% end %> -
<%= model_class.human_attribute_name(:has_signed_waiver) %>:
-
<%= @participant.has_signed_waiver ? "yes" : "no" %>
+ <% end %>
<%= model_class.human_attribute_name(:department) %>:
<%= @participant.department %>
<%= model_class.human_attribute_name(:student_class) %>:
diff --git a/db/migrate/20170322191208_add_is_building_to_organization_category.rb b/db/migrate/20170322191208_add_is_building_to_organization_category.rb new file mode 100644 index 00000000..4ae80946 --- /dev/null +++ b/db/migrate/20170322191208_add_is_building_to_organization_category.rb @@ -0,0 +1,5 @@ +class AddIsBuildingToOrganizationCategory < ActiveRecord::Migration + def change + add_column :organization_categories, :is_building, :boolean + end +end diff --git a/db/seeds.rb b/db/seeds.rb index f9e6d14b..38a77ced 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -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'