mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
* Consistent route/model/controller/view layout * Get rid of unused photos, speakers, dietchoices, social_events controllers * Drop unused :public from Rooms and :description from CallForPapers
53 lines
1.5 KiB
Ruby
53 lines
1.5 KiB
Ruby
module Admin
|
|
class LodgingsController < Admin::BaseController
|
|
load_and_authorize_resource :conference, find_by: :short_title
|
|
load_and_authorize_resource :lodging, through: :conference
|
|
|
|
def index
|
|
end
|
|
|
|
def new
|
|
@lodging = @conference.lodgings.new
|
|
end
|
|
|
|
def create
|
|
@lodging = @conference.lodgings.new(lodging_params)
|
|
if @lodging.save
|
|
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
|
|
notice: 'Lodging successfully created.')
|
|
else
|
|
flash[:error] = "Creating Lodging failed: #{@lodging.errors.full_messages.join('. ')}."
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def edit; end
|
|
|
|
def update
|
|
if @lodging.update_attributes(lodging_params)
|
|
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
|
|
notice: 'Lodging successfully updated.')
|
|
else
|
|
flash[:error] = "Update Lodging failed: #{@lodging.errors.full_messages.join('. ')}."
|
|
render :edit
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
if @lodging.destroy
|
|
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
|
|
notice: 'Lodging successfully deleted.')
|
|
else
|
|
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
|
|
error: 'Deleting lodging failed.' \
|
|
"#{@lodging.errors.full_messages.join('. ')}.")
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def lodging_params
|
|
params[:lodging]
|
|
end
|
|
end
|
|
end
|