2017-06-10 23:50:31 +03:00
|
|
|
module Admin
|
|
|
|
|
class Admin::BoothsController < Admin::BaseController
|
|
|
|
|
load_and_authorize_resource :conference, find_by: :short_title
|
|
|
|
|
load_and_authorize_resource :booth, through: :conference
|
|
|
|
|
|
2017-06-18 23:33:54 +03:00
|
|
|
|
2017-06-10 23:50:31 +03:00
|
|
|
def index
|
|
|
|
|
@booths = @conference.booths
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def show; end
|
|
|
|
|
|
2017-06-18 23:33:54 +03:00
|
|
|
def new
|
|
|
|
|
@booth = Booth.new(conference: @conference)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
@booth = @conference.booths.build(booth_params)
|
|
|
|
|
|
|
|
|
|
if @booth.save
|
|
|
|
|
redirect_to admin_conference_booths_path,
|
|
|
|
|
notice: "Booth successfully created."
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = "Creating booth failed. #{@booth.errors.full_messages.join('. ')}."
|
|
|
|
|
render :new
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def edit; end
|
2017-06-10 23:50:31 +03:00
|
|
|
|
2017-06-18 23:33:54 +03:00
|
|
|
def update
|
|
|
|
|
@booth = @conference.booths
|
|
|
|
|
@booth.assign_attributes(booth_params)
|
2017-06-10 23:50:31 +03:00
|
|
|
|
2017-06-18 23:33:54 +03:00
|
|
|
|
|
|
|
|
if @booth.update_attributes(booth_params)
|
|
|
|
|
redirect_to admin_conference_booths_path,
|
|
|
|
|
notice: "Successfully updated booth for #{@booth.title}."
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = "An error prohibited the Booth for #{@booth.title} "\
|
|
|
|
|
"#{@booth.errors.full_messages.join('. ')}."
|
|
|
|
|
render :edit
|
|
|
|
|
end
|
|
|
|
|
end
|
2017-06-10 23:50:31 +03:00
|
|
|
|
|
|
|
|
def destroy; end
|
|
|
|
|
|
2017-06-18 23:33:54 +03:00
|
|
|
def accept
|
|
|
|
|
update_state(:accept, 'Booth accepted!')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def to_accept
|
|
|
|
|
update_state(:to_accept, 'Booth to accept')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def reject
|
|
|
|
|
update_state(:rejected, 'Booth rejected')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def reset
|
|
|
|
|
update_state(:reset, 'Booth is submitted')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def update_state(transition, notice)
|
|
|
|
|
alert = @booth.update_state(transition, notice)
|
|
|
|
|
|
|
|
|
|
if alert.blank?
|
|
|
|
|
flash[:notice] = notice
|
|
|
|
|
redirect_back_or_to(admin_conference_booths_path(conference_id: @conference.short_title)) && return
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = alert
|
|
|
|
|
return redirect_back_or_to(admin_conference_booths_path(conference_id: @conference.short_title)) && return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def booth_params
|
|
|
|
|
params.require(:booth).permit(:title, :description, :reasoning, :state, :logo_link, :conference_id)
|
|
|
|
|
end
|
2017-06-10 23:50:31 +03:00
|
|
|
end
|
|
|
|
|
end
|