mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Add booths to non admin
This commit is contained in:
parent
033dbe4c40
commit
32c5af2a17
22 changed files with 426 additions and 86 deletions
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