2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2017-07-20 14:20:46 +03:00
|
|
|
class BoothsController < ApplicationController
|
|
|
|
|
before_action :authenticate_user!
|
|
|
|
|
load_resource :conference, find_by: :short_title
|
|
|
|
|
load_and_authorize_resource through: :conference
|
|
|
|
|
skip_authorize_resource only: [:withdraw, :confirm, :restart]
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
@booths = current_user.booths.where(conference_id: @conference.id).uniq
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def show; end
|
|
|
|
|
|
|
|
|
|
def new
|
|
|
|
|
@url = conference_booths_path(@conference.short_title)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
@url = conference_booths_path(@conference.short_title)
|
|
|
|
|
|
|
|
|
|
@booth.submitter = current_user
|
|
|
|
|
|
|
|
|
|
if @booth.save
|
|
|
|
|
redirect_to conference_booths_path,
|
2019-07-22 00:59:17 +05:30
|
|
|
notice: "#{(t 'booth').capitalize} successfully created."
|
2017-07-20 14:20:46 +03:00
|
|
|
else
|
2019-07-22 00:59:17 +05:30
|
|
|
flash.now[:error] = "Creating #{t 'booth'} failed. #{@booth.errors.full_messages.to_sentence}."
|
2017-07-20 14:20:46 +03:00
|
|
|
render :new
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def edit
|
|
|
|
|
@url = conference_booth_path(@conference.short_title, @booth.id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
@url = conference_booth_path(@conference.short_title, @booth.id)
|
2022-02-14 17:53:58 +01:00
|
|
|
@booth.update(booth_params)
|
2017-07-20 14:20:46 +03:00
|
|
|
|
|
|
|
|
if @booth.save
|
|
|
|
|
redirect_to conference_booths_path,
|
|
|
|
|
notice: 'Booth successfully updated!'
|
|
|
|
|
else
|
2017-08-28 22:31:24 +05:30
|
|
|
flash.now[:error] = "Booth could not be updated. #{@booth.errors.full_messages.to_sentence}."
|
2019-07-21 20:37:53 +05:30
|
|
|
render :edit
|
2017-07-20 14:20:46 +03:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy; end
|
|
|
|
|
|
|
|
|
|
def withdraw
|
|
|
|
|
authorize! :update, @booth
|
|
|
|
|
@url = conference_booth_path(@conference.short_title, @booth.id)
|
|
|
|
|
|
|
|
|
|
@booth.withdraw!
|
|
|
|
|
|
|
|
|
|
if @booth.save
|
|
|
|
|
redirect_to conference_booths_path,
|
|
|
|
|
notice: 'Booth successfully withdrawn'
|
|
|
|
|
else
|
2017-08-28 22:31:24 +05:30
|
|
|
flash.now[:error] = "Booth could not be withdrawn. #{@booth.errors.full_messages.to_sentence}."
|
2017-07-20 14:20:46 +03:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def confirm
|
|
|
|
|
authorize! :update, @booth
|
|
|
|
|
@url = conference_booth_path(@conference.short_title, @booth.id)
|
|
|
|
|
|
|
|
|
|
@booth.confirm!
|
|
|
|
|
|
|
|
|
|
if @booth.save
|
|
|
|
|
redirect_to conference_booths_path,
|
|
|
|
|
notice: 'Booth successfully confirmed'
|
|
|
|
|
else
|
2017-08-28 22:31:24 +05:30
|
|
|
flash.now[:error] = "Booth could not be confirmed. #{@booth.errors.full_messages.to_sentence}."
|
2017-07-20 14:20:46 +03:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def restart
|
|
|
|
|
authorize! :update, @booth
|
|
|
|
|
@url = conference_booth_path(@conference.short_title, @booth.id)
|
|
|
|
|
|
|
|
|
|
@booth.restart!
|
|
|
|
|
|
|
|
|
|
if @booth.save
|
|
|
|
|
redirect_to conference_booths_path,
|
|
|
|
|
notice: 'Booth successfully re-submitted'
|
|
|
|
|
else
|
2017-08-28 22:31:24 +05:30
|
|
|
flash.now[:error] = "Booth could not be re-submitted. #{@booth.errors.full_messages.to_sentence}."
|
2017-07-20 14:20:46 +03:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def booth_params
|
2026-03-17 15:55:22 +01:00
|
|
|
params.require(:booth).permit(:title, :description, :reasoning, :picture, :website_url, :submitter_relationship, responsible_ids: [])
|
2017-07-20 14:20:46 +03:00
|
|
|
end
|
|
|
|
|
end
|