From c0379784a92603cadcc0c3ef12435c53fae00860 Mon Sep 17 00:00:00 2001 From: Stephen Clark Date: Wed, 22 Mar 2017 15:42:21 -0400 Subject: [PATCH] Added wristband field to participant view to help with wristband distribution #220 --- app/controllers/participants_controller.rb | 12 ++++++++++++ app/models/organization_category.rb | 13 +++++++------ app/views/participants/show.html.erb | 8 +++++--- ...d_building_status_to_organization_category.rb | 5 +++++ db/seeds.rb | 16 ++++++++-------- 5 files changed, 37 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20170322191208_add_building_status_to_organization_category.rb diff --git a/app/controllers/participants_controller.rb b/app/controllers/participants_controller.rb index 6b0e2b2c..d42bc79c 100644 --- a/app/controllers/participants_controller.rb +++ b/app/controllers/participants_controller.rb @@ -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 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_building_status_to_organization_category.rb b/db/migrate/20170322191208_add_building_status_to_organization_category.rb new file mode 100644 index 00000000..ec352394 --- /dev/null +++ b/db/migrate/20170322191208_add_building_status_to_organization_category.rb @@ -0,0 +1,5 @@ +class AddBuildingStatusToOrganizationCategory < ActiveRecord::Migration + def change + add_column :organization_categories, :building_status, :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'