Implement track request acceptance

Allow track submitter to request specific dates
Redirect to Tracks#edit if a track doesn't have a room or start/end date
before accepting it

Don't allow the submitter or the track organizers to edit the request
after it has been accepted or confirmed

Restrict track selection in proposals and move track selection from
Proposals form to events helper

Mark cfp_active of the tracks table as not null and fill in true if nil
This commit is contained in:
AEtherC0r3 2017-07-14 15:57:34 +03:00 committed by Stella Rouzi
parent 2f9eb04219
commit d9faffc96a
27 changed files with 909 additions and 62 deletions

View file

@ -45,6 +45,7 @@ class Event < ActiveRecord::Base
validates :max_attendees, numericality: { only_integer: true, greater_than_or_equal_to: 1, allow_nil: true }
validate :max_attendees_no_more_than_room_size
validate :acceptable_track
scope :confirmed, -> { where(state: 'confirmed') }
scope :canceled, -> { where(state: 'canceled') }
@ -303,4 +304,11 @@ class Event < ActiveRecord::Base
def conference_id
program.conference_id
end
##
# Allow only confirmed tracks that belong to the same program and are included in the cfp
def acceptable_track
return unless track && track.program && program
errors.add(:track, 'is invalid') unless track.confirmed? && track.cfp_active && track.program == program
end
end