-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prevent participants from skipping saftey video * Added user certifications * Add certification check to tools checkout * Only show certifications required by tool type if they exist * Added cancan checks around certification creation and deletion * Added wristband field to participant view to help with wristband distribution #220 * Added digital signature to waiver #173 * Cleaned waiver code * Changed store items price datatype to support fractional prices #168 * Added rake db:migrate to travis script so it can build with migrations * Added rake db:migrate to travis script so it can build with migrations * Fixing style on PR #248 * Removing nil check for PR #248 * Changed error message after skipping the saftey video * Using migration technique from http://stackoverflow.com/questions/17150529 * Reverting to previous 9V battery price * Fixing spelling of 'safety' * Define wristband colors as constants * Added load_and_authorize_resource to CertificationsController * Changed building_status to is_building in db seeds file * Fixed waiver playing in bg for admin and allow admin to skip video * Added scissor lift wristband color * Updated safety video * Cleaned up waiver code and let user skip waiver on error from previous error * Fixed ForbiddenAttribute error on certification creation * Fixed messed up sidebar on SCC member new waiver
- Loading branch information
Showing
34 changed files
with
450 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class CertificationsController < ApplicationController | ||
load_and_authorize_resource | ||
|
||
before_action :set_participant, only: [:new, :create] | ||
before_action :set_certification, only: [:destroy] | ||
before_action :check_all_certifications, except: [:destroy] | ||
|
||
def new | ||
@certification = Certification.new(:participant => @participant) | ||
respond_with @certification | ||
end | ||
|
||
def create | ||
@certification = Certification.new(certification_params) | ||
@certification.participant = @participant | ||
@certification.save | ||
respond_with @certification, location: -> { @certification.participant } | ||
end | ||
|
||
def destroy | ||
@certification.destroy | ||
respond_with @certification, location: -> { @certification.participant } | ||
end | ||
|
||
private | ||
def set_participant | ||
@participant = Participant.find(params[:participant_id]) | ||
end | ||
|
||
def set_certification | ||
@certification = Certification.find(params[:id]) | ||
end | ||
|
||
def check_all_certifications | ||
if @participant.certifications.size == CertificationType.all.size | ||
redirect_to (participant_path @participant), :flash => { :error => @participant.name + " has already gotten all certifications." } | ||
end | ||
end | ||
|
||
def certification_params | ||
params.require(:certification).permit(:participant_id, :certification_type_id) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
class WaiversController < ApplicationController | ||
before_filter :require_authenticated_user | ||
|
||
def new | ||
if params[:participant_id].nil? or !current_user.participant.is_scc? | ||
@user = current_user.participant | ||
else | ||
@user = Participant.find params[:participant_id] | ||
end | ||
|
||
if @user.has_signed_waiver | ||
flash[:notice] = "You have already agreed to the release." | ||
elsif !flash[:error] | ||
@user.start_waiver_timer | ||
end | ||
|
||
|
||
@should_see_video = !flash[:error] && cannot?(:skip_video, WaiversController) | ||
|
||
end | ||
|
||
|
||
|
@@ -21,16 +25,21 @@ def create | |
else | ||
@participant = Participant.find params[:participant_id] | ||
end | ||
|
||
|
||
if params[:adult].blank? | ||
|
||
if @participant.is_waiver_cheater? && cannot?(:skip_video, WaiversController) | ||
@participant.start_waiver_timer | ||
redirect_to '/cheating.html' | ||
elsif params[:adult].blank? | ||
flash[:error] = "You must be 18 or older to sign the electronic waiver. Please contact Andrew Greenwald (<a target='_blank' href='mailto:[email protected]'>[email protected]</a>)." | ||
redirect_to action: :new | ||
elsif params[:agree].blank? | ||
flash[:error] = "You must agree to the terms of the release." | ||
redirect_to action: :new | ||
elsif params[:phone_number] == "" | ||
flash[:error] = "You must provide a mobile phone number" | ||
flash[:error] = "You must provide a mobile phone number." | ||
redirect_to action: :new | ||
elsif params[:signature] != @participant.name | ||
flash[:error] = "You must electronically sign the waiver with your full name as it appears on the waiver." | ||
redirect_to action: :new | ||
else | ||
@participant.phone_number = params[:phone_number] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Certification < ActiveRecord::Base | ||
belongs_to :certification_type | ||
belongs_to :participant | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class CertificationType < ActiveRecord::Base | ||
validates :name, :presence => true, :uniqueness => true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# ## Schema Information | ||
# | ||
# Table name: `tool_type_certifications` | ||
# | ||
# ### Columns | ||
# | ||
# Name | Type | Attributes | ||
# ---------------------------- | ------------------ | --------------------------- | ||
# **`certification_type_id`** | `integer` | | ||
# **`created_at`** | `datetime` | `not null` | ||
# **`id`** | `integer` | `not null, primary key` | ||
# **`tool_type_id`** | `integer` | | ||
# **`updated_at`** | `datetime` | `not null` | ||
# | ||
# ### Indexes | ||
# | ||
# * `index_tool_type_certifications_on_certification_type_id`: | ||
# * **`certification_type_id`** | ||
# * `index_tool_type_certifications_on_tool_type_id`: | ||
# * **`tool_type_id`** | ||
# | ||
|
||
class ToolTypeCertification < ActiveRecord::Base | ||
belongs_to :tool_type | ||
belongs_to :certification_type | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<% current_certs = @participant.certifications.map { |cert| cert.certification_type.name } %> | ||
|
||
<%= simple_form_for [@participant, @certification], :html => { :class => 'form-horizontal' } do |f| %> | ||
<div class="form-inputs"> | ||
<div class = "row"> | ||
<div class = "col-md-8" style="margin-left:73px"> | ||
</div> | ||
</div> | ||
<%= f.association :certification_type, collection: CertificationType.all.select { |c| !current_certs.include?(c.name) }, style: "margin-left:80px" %> | ||
<%= f.input :participant_id, :as => :hidden %> | ||
</div> | ||
|
||
<div class="form-actions"> | ||
<%= f.button :submit, :class => 'btn-primary' %> | ||
<%= link_to t('.cancel', :default => t("helpers.links.cancel")), | ||
@participant, :class => 'btn btn-default' %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%- model_class = Certification -%> | ||
<div class="page-header"> | ||
<h1>Add Certification for <%= @participant.name %></h1> | ||
</div> | ||
|
||
<%= render 'form' %> |
Oops, something went wrong.