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

@ -20,6 +20,7 @@ module Admin
def create
@track = @program.tracks.new(track_params)
@track.state = 'confirmed'
@track.cfp_active = true
if @track.save
redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
notice: 'Track successfully created.'
@ -60,10 +61,55 @@ module Admin
end
end
def restart
update_state(:restart, "Review for #{@track.name} started!")
end
def to_accept
update_state(:to_accept, "Track #{@track.name} marked as a possible acceptance!")
end
def accept
if @track.room && @track.start_date && @track.end_date
update_state(:accept, "Track #{@track.name} accepted!")
else
flash[:alert] = 'Please make sure that the track has a room and start/end dates before accepting it'
redirect_to edit_admin_conference_program_track_path(@conference.short_title, @track)
end
end
def confirm
update_state(:confirm, "Track #{@track.name} confirmed!")
end
def to_reject
update_state(:to_reject, "Track #{@track.name} marked as a possible rejection!")
end
def reject
update_state(:reject, "Track #{@track.name} rejected!")
end
def cancel
update_state(:cancel, "Track #{@track.name} canceled!")
end
private
def track_params
params.require(:track).permit(:name, :description, :color, :short_name, :cfp_active, :start_date, :end_date, :room_id)
end
def update_state(transition, notice)
errors = @track.update_state(transition)
if errors.blank?
flash[:notice] = notice
else
flash[:error] = errors
end
redirect_back_or_to(admin_conference_program_tracks_path(conference_id: @conference.short_title))
end
end
end

View file

@ -4,7 +4,7 @@ class TracksController < ApplicationController
load_and_authorize_resource through: :program, find_by: :short_name
def index
@tracks = current_user.tracks.where(program: @program)
@tracks = @tracks.where(submitter: current_user)
end
def show; end
@ -38,9 +38,33 @@ class TracksController < ApplicationController
end
end
def restart
update_state(:restart, "Track #{@track.name} re-submitted.")
end
def confirm
update_state(:confirm, "Track #{@track.name} confirmed.")
end
def withdraw
update_state(:withdraw, "Track #{@track.name} withdrawn.")
end
private
def track_params
params.require(:track).permit(:name, :description, :color, :short_name)
params.require(:track).permit(:name, :description, :color, :short_name, :start_date, :end_date)
end
def update_state(transition, notice)
errors = @track.update_state(transition)
if errors.blank?
flash[:notice] = notice
else
flash[:error] = errors
end
redirect_back_or_to(conference_program_tracks_path(conference_id: @conference.short_title))
end
end