Add booths to non admin
This commit is contained in:
parent
033dbe4c40
commit
32c5af2a17
22 changed files with 426 additions and 86 deletions
|
|
@ -7,9 +7,13 @@ module Admin
|
|||
|
||||
def show; end
|
||||
|
||||
def new; end
|
||||
def new
|
||||
@url = admin_conference_booths_path(@conference.short_title)
|
||||
end
|
||||
|
||||
def create
|
||||
@url = admin_conference_booths_path(@conference.short_title)
|
||||
|
||||
@booth = @conference.booths.new(booth_params)
|
||||
|
||||
@booth.submitter = current_user
|
||||
|
|
@ -23,9 +27,13 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def edit; end
|
||||
def edit
|
||||
@url = admin_conference_booth_path(@conference.short_title, @booth.id)
|
||||
end
|
||||
|
||||
def update
|
||||
@url = admin_conference_booth_path(@conference.short_title, @booth.id)
|
||||
|
||||
@booth.update_attributes(booth_params)
|
||||
|
||||
if @booth.save
|
||||
|
|
@ -38,16 +46,6 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @booth.destroy
|
||||
redirect_to admin_conference_booths_path,
|
||||
notice: 'Booth successfully destroyed.'
|
||||
else
|
||||
redirect_to admin_conference_booths_path,
|
||||
error: "Booth couldn't be deleted. #{@booth.errors.full_messages.join('. ')}."
|
||||
end
|
||||
end
|
||||
|
||||
def accept
|
||||
update_state(:accept, 'Booth accepted!')
|
||||
end
|
||||
|
|
|
|||
97
app/controllers/booths_controller.rb
Normal file
97
app/controllers/booths_controller.rb
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
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,
|
||||
notice: 'Booth successfully created.'
|
||||
else
|
||||
flash[:error] = "Creating booth failed. #{@booth.errors.full_messages.to_sentence}."
|
||||
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)
|
||||
@booth.update_attributes(booth_params)
|
||||
|
||||
if @booth.save
|
||||
redirect_to conference_booths_path,
|
||||
notice: 'Booth successfully updated!'
|
||||
else
|
||||
flash[:error] = "Booth could not be updated. #{@booth.errors.full_messages.to_sentence}."
|
||||
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
|
||||
flash[:error] = "Booth could not be withdrawn. #{@booth.errors.full_messages.to_sentence}."
|
||||
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
|
||||
flash[:error] = "Booth could not be confirmed. #{@booth.errors.full_messages.to_sentence}."
|
||||
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
|
||||
flash[:error] = "Booth could not be re-submitted. #{@booth.errors.full_messages.to_sentence}."
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def booth_params
|
||||
params.require(:booth).permit(:title, :description, :reasoning, :state, :picture, :conference_id,
|
||||
:created_at, :updated_at, :submitter_relationship, :website_url, responsible_ids: [])
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue