parent
518e1cc62b
commit
5fe99dd041
26 changed files with 352 additions and 130 deletions
|
|
@ -1,23 +1,57 @@
|
|||
module Admin
|
||||
class LodgingsController < ApplicationController
|
||||
before_filter :verify_organizer
|
||||
before_action :set_lodging, only: [:edit, :update, :destroy]
|
||||
before_action :set_venue, only: [:index]
|
||||
|
||||
def index
|
||||
@venue = @conference.venue
|
||||
end
|
||||
|
||||
def show
|
||||
def new
|
||||
@lodging = @conference.venue.lodgings.build
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@lodging = @conference.venue.lodgings.build(lodging_params)
|
||||
|
||||
if @lodging.save
|
||||
redirect_to admin_conference_lodgings_path(@conference.short_title), notice: 'Lodging was successfully created.'
|
||||
else
|
||||
flash[:alert] = "A error prohibited this Lodging from being saved: #{@lodging.errors.full_messages.join('. ')}."
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@venue = @conference.venue
|
||||
if @venue.update_attributes(params[:venue])
|
||||
if @lodging.update_attributes(lodging_params)
|
||||
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
|
||||
notice: 'Lodgings were successfully updated.')
|
||||
notice: 'Lodging was successfully updated.')
|
||||
else
|
||||
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
|
||||
notice: 'Updating lodgings failed!')
|
||||
flash[:alert] = "A error prohibited this Lodging from being saved: #{@venue.errors.full_messages.join('. ')}."
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@lodging.destroy
|
||||
redirect_to admin_conference_lodgings_path, notice: 'Lodging was successfully destroyed.'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_lodging
|
||||
@lodging = Lodging.find(params[:id])
|
||||
end
|
||||
|
||||
def set_venue
|
||||
@venue = @conference.venue
|
||||
end
|
||||
|
||||
def lodging_params
|
||||
params[:lodging]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,19 +1,54 @@
|
|||
class Admin::RoomsController < ApplicationController
|
||||
before_filter :verify_organizer
|
||||
before_action :set_room, only: [:edit, :update, :destroy]
|
||||
before_action :set_conference
|
||||
|
||||
def show
|
||||
render :rooms_list
|
||||
def index
|
||||
@rooms = @conference.rooms
|
||||
end
|
||||
|
||||
def new
|
||||
@room = @conference.rooms.build
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@room = @conference.rooms.build(room_params)
|
||||
|
||||
if @room.save
|
||||
redirect_to admin_conference_rooms_path(@conference.short_title), notice: 'Room was successfully created.'
|
||||
else
|
||||
flash[:alert] = "A error prohibited this Rooms from being saved: #{@room.errors.full_messages.join('. ')}."
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @conference.update_attributes(params[:conference])
|
||||
redirect_to(admin_conference_rooms_path(
|
||||
conference_id: @conference.short_title),
|
||||
notice: 'Rooms were successfully updated.')
|
||||
if @room.update(room_params)
|
||||
redirect_to admin_conference_rooms_path(@conference.short_title), notice: 'Room was successfully updated.'
|
||||
else
|
||||
redirect_to(admin_conference_rooms_path(
|
||||
conference_id: @conference.short_title),
|
||||
notice: 'Room update failed.')
|
||||
flash[:alert] = "A error prohibited this Rooms from being saved: #{@room.errors.full_messages.join('. ')}."
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@room.destroy
|
||||
redirect_to admin_conference_rooms_path, notice: 'Room was successfully destroyed.'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_conference
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
end
|
||||
|
||||
def set_room
|
||||
@room = Room.find(params[:id])
|
||||
end
|
||||
|
||||
def room_params
|
||||
params[:room]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,30 +1,34 @@
|
|||
class Admin::VenueController < ApplicationController
|
||||
class Admin::VenuesController < ApplicationController
|
||||
before_filter :verify_organizer
|
||||
|
||||
def index
|
||||
end
|
||||
before_action :set_venue, only: [:update, :edit]
|
||||
|
||||
def update
|
||||
@venue = @conference.venue
|
||||
@venue.assign_attributes(params[:venue])
|
||||
@venue.assign_attributes(venue_params)
|
||||
venue_notify = (@venue.name_changed? || @venue.address_changed?) &&
|
||||
(!@venue.name.blank? && !@venue.address.blank?) &&
|
||||
(@conference.email_settings.send_on_venue_update &&
|
||||
!@conference.email_settings.venue_update_subject.blank? &&
|
||||
@conference.email_settings.venue_update_template)
|
||||
|
||||
if @venue.update_attributes(params[:venue])
|
||||
if @venue.save
|
||||
Mailbot.delay.send_email_on_venue_update(@conference) if venue_notify
|
||||
redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title),
|
||||
notice: 'Venue was successfully updated.')
|
||||
redirect_to(:back, notice: 'Venue was successfully updated.')
|
||||
else
|
||||
redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title),
|
||||
redirect_to(:back,
|
||||
notice: 'Venue Updation Failed!')
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
def edit
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def venue_params
|
||||
params[:venue]
|
||||
end
|
||||
|
||||
def set_venue
|
||||
@venue = @conference.venue
|
||||
render :venue_info
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue