diff --git a/app/controllers/waivers_controller.rb b/app/controllers/waivers_controller.rb index cc3eff5b..6fbf4f0a 100644 --- a/app/controllers/waivers_controller.rb +++ b/app/controllers/waivers_controller.rb @@ -10,6 +10,8 @@ def new if @user.has_signed_waiver flash[:notice] = "You have already agreed to the release." + else + @user.start_waiver_timer end end @@ -21,9 +23,11 @@ def create else @participant = Participant.find params[:participant_id] end - - - if params[:adult].blank? + + if @participant.is_waiver_cheater? + @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 (asgreen@andrew.cmu.edu)." redirect_to action: :new elsif params[:agree].blank? diff --git a/app/models/participant.rb b/app/models/participant.rb index bdc4d3f5..92a3c77f 100644 --- a/app/models/participant.rb +++ b/app/models/participant.rb @@ -21,6 +21,7 @@ # **`phone_number`** | `string(255)` | # **`updated_at`** | `datetime` | # **`user_id`** | `integer` | +# **`waiver_start`** | `datetime` | # # ### Indexes # @@ -49,6 +50,15 @@ class Participant < ActiveRecord::Base scope :search, lambda { |term| where('lower(andrewid) LIKE lower(?) OR lower(cached_name) LIKE lower(?)', "%#{term}%", "%#{term}%") } scope :scc, -> { joins(:organizations).where(organizations: {name: 'Spring Carnival Committee'}) } + def start_waiver_timer + self.waiver_start = DateTime.now + self.save + end + + def is_waiver_cheater? + (self.waiver_start + 3.minutes + 37.seconds) > DateTime.now + end + def is_booth_chair? !memberships.booth_chairs.blank? end diff --git a/db/migrate/20170305040259_add_waiver_start_to_participant.rb b/db/migrate/20170305040259_add_waiver_start_to_participant.rb new file mode 100644 index 00000000..46f785d0 --- /dev/null +++ b/db/migrate/20170305040259_add_waiver_start_to_participant.rb @@ -0,0 +1,5 @@ +class AddWaiverStartToParticipant < ActiveRecord::Migration + def change + add_column :participants, :waiver_start, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 7746d390..d1008223 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160404161512) do +ActiveRecord::Schema.define(version: 20170305040259) do create_table "charge_types", force: :cascade do |t| t.string "name" @@ -196,6 +196,7 @@ t.string "cached_department" t.string "cached_student_class" t.datetime "cache_updated" + t.datetime "waiver_start" t.integer "phone_carrier_id" end diff --git a/public/cheating.html b/public/cheating.html new file mode 100644 index 00000000..4142d913 --- /dev/null +++ b/public/cheating.html @@ -0,0 +1,34 @@ + + +
+Please watch the entire safety video before completing the waiver!
+