Create booth_type controller and update booth params
This commit is contained in:
parent
c9ae859bcf
commit
319b8b5bf7
3 changed files with 61 additions and 3 deletions
55
app/controllers/admin/booth_types_controller.rb
Normal file
55
app/controllers/admin/booth_types_controller.rb
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Admin
|
||||||
|
class BoothTypesController < Admin::BaseController
|
||||||
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource :program, through: :conference, singleton: true
|
||||||
|
load_and_authorize_resource :booth_type, through: :program
|
||||||
|
|
||||||
|
def index; end
|
||||||
|
|
||||||
|
def edit; end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@booth_type = @conference.program.booth_types.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@booth_type = @conference.program.booth_types.new(booth_type_params)
|
||||||
|
if @booth_type.save
|
||||||
|
redirect_to admin_conference_program_booth_types_path(conference_id: @conference),
|
||||||
|
notice: "#{(t'booth').capitalize} type successfully created."
|
||||||
|
else
|
||||||
|
flash.now[:error] = "Creating #{t 'booth'} type failed: #{@booth_type.errors.full_messages.join('. ')}."
|
||||||
|
render :new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if @booth_type.update_attributes(booth_type_params)
|
||||||
|
redirect_to admin_conference_program_booth_types_path(conference_id: @conference),
|
||||||
|
notice: "#{(t'booth').capitalize} type successfully updated."
|
||||||
|
else
|
||||||
|
flash.now[:error] = "Update #{t 'booth'} type failed: #{@booth_type.errors.full_messages.join('. ')}."
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
if @booth_type.destroy
|
||||||
|
redirect_to admin_conference_program_booth_types_path(conference_id: @conference),
|
||||||
|
notice: "#{(t'booth').capitalize} type successfully deleted."
|
||||||
|
else
|
||||||
|
redirect_to admin_conference_program_booth_types_path(conference_id: @conference),
|
||||||
|
error: "Destroying #{t 'booth'} type failed! "\
|
||||||
|
"#{@booth_type.errors.full_messages.join('. ')}."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def booth_type_params
|
||||||
|
params.require(:booth_type).permit(:title, :description)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -8,6 +8,7 @@ module Admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@file_name = "#{(t 'booth').pluralize}_for_#{@conference.short_title}"
|
@file_name = "#{(t 'booth').pluralize}_for_#{@conference.short_title}"
|
||||||
|
@booth_types = @conference.program.booth_types
|
||||||
@booth_export_option = params[:booth_export_option]
|
@booth_export_option = params[:booth_export_option]
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
|
@ -25,7 +26,9 @@ module Admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show; end
|
def show
|
||||||
|
@booth_types = @conference.program.booth_types
|
||||||
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@url = admin_conference_booths_path(@conference.short_title)
|
@url = admin_conference_booths_path(@conference.short_title)
|
||||||
|
|
@ -130,7 +133,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def booth_params
|
def booth_params
|
||||||
params.require(:booth).permit(:title, :description, :reasoning, :state, :picture, :conference_id,
|
params.require(:booth).permit(:title, :description, :reasoning, :state, :picture, :conference_id, :booth_type_id,
|
||||||
:created_at, :updated_at, :submitter_relationship, :website_url, :invite_responsible,
|
:created_at, :updated_at, :submitter_relationship, :website_url, :invite_responsible,
|
||||||
responsible_ids: [])
|
responsible_ids: [])
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ class BoothsController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def booth_params
|
def booth_params
|
||||||
params.require(:booth).permit(:title, :description, :reasoning, :state, :picture, :conference_id,
|
params.require(:booth).permit(:title, :description, :reasoning, :state, :picture, :conference_id, :booth_type_id,
|
||||||
:created_at, :updated_at, :submitter_relationship, :website_url, :invite_responsible,
|
:created_at, :updated_at, :submitter_relationship, :website_url, :invite_responsible,
|
||||||
responsible_ids: [])
|
responsible_ids: [])
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue