2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2014-08-06 21:14:00 +03:00
|
|
|
module Admin
|
2014-08-13 14:37:05 +03:00
|
|
|
class RoomsController < Admin::BaseController
|
2014-08-12 11:51:59 +03:00
|
|
|
load_and_authorize_resource :conference, find_by: :short_title
|
2015-11-07 11:43:36 +02:00
|
|
|
load_and_authorize_resource :venue, through: :conference, singleton: true
|
|
|
|
|
load_and_authorize_resource through: :venue
|
2014-08-12 11:51:59 +03:00
|
|
|
|
2015-10-25 13:29:02 +02:00
|
|
|
def index; end
|
2013-01-07 09:04:09 +01:00
|
|
|
|
2014-11-12 11:37:28 +01:00
|
|
|
def edit; end
|
|
|
|
|
|
|
|
|
|
def new
|
2015-11-07 11:43:36 +02:00
|
|
|
@room = @venue.rooms.new
|
2014-11-12 11:37:28 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create
|
2015-11-07 11:43:36 +02:00
|
|
|
@room = @venue.rooms.new(room_params)
|
2014-11-12 11:37:28 +01:00
|
|
|
if @room.save
|
2016-03-11 02:08:00 +05:30
|
|
|
redirect_to admin_conference_venue_rooms_path(conference_id: @conference.short_title),
|
|
|
|
|
notice: 'Room successfully created.'
|
2014-11-12 11:37:28 +01:00
|
|
|
else
|
2017-04-03 18:34:37 +03:00
|
|
|
flash.now[:error] = "Creating Room failed: #{@room.errors.full_messages.join('. ')}."
|
2014-11-12 11:37:28 +01:00
|
|
|
render :new
|
|
|
|
|
end
|
2014-08-06 21:14:00 +03:00
|
|
|
end
|
2013-01-07 09:04:09 +01:00
|
|
|
|
2014-08-06 21:14:00 +03:00
|
|
|
def update
|
2022-02-14 17:53:58 +01:00
|
|
|
if @room.update(room_params)
|
2016-03-11 02:08:00 +05:30
|
|
|
redirect_to admin_conference_venue_rooms_path(conference_id: @conference.short_title),
|
|
|
|
|
notice: 'Room successfully updated.'
|
2014-08-06 21:14:00 +03:00
|
|
|
else
|
2017-04-03 18:34:37 +03:00
|
|
|
flash.now[:error] = "Update Room failed: #{@room.errors.full_messages.join('. ')}."
|
2014-11-12 11:37:28 +01:00
|
|
|
render :edit
|
2014-08-06 21:14:00 +03:00
|
|
|
end
|
2013-01-07 09:04:09 +01:00
|
|
|
end
|
2014-11-12 11:37:28 +01:00
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
if @room.destroy
|
2016-03-11 02:08:00 +05:30
|
|
|
redirect_to admin_conference_venue_rooms_path(conference_id: @conference.short_title),
|
|
|
|
|
notice: 'Room successfully deleted.'
|
2014-11-12 11:37:28 +01:00
|
|
|
else
|
2016-03-11 02:08:00 +05:30
|
|
|
redirect_to admin_conference_venue_rooms_path(conference_id: @conference.short_title),
|
|
|
|
|
error: "Destroying room failed! #{@room.errors.full_messages.join('. ')}."
|
2014-11-12 11:37:28 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def room_params
|
2015-10-28 18:05:15 +02:00
|
|
|
params.require(:room).permit(:name, :size)
|
2014-11-12 11:37:28 +01:00
|
|
|
end
|
2013-01-07 09:04:09 +01:00
|
|
|
end
|
|
|
|
|
end
|