Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ReservationController < ApplicationController
- skip_before_action :verify_authenticity_token, only: :create
- before_filter :require_admin, only: [:confirm_booking, :reject_booking]
- def index
- @halls_first_floor = Hall.first_floor.map { |hall| hall.to_hash }
- @halls_second_floor = Hall.second_floor.map { |hall| hall.to_hash }
- gon.reservation_bg = ActionController::Base.helpers.asset_path('reservation.png')
- respond_to do |format|
- format.html
- format.json do
- render json: { halls_first_floor: @halls_first_floor, halls_second_floor: @halls_second_floor }
- end
- end
- end
- def get_tables
- render json: { tables: Table.for_hall(params[:hall_id]).map { |table| table.to_hash(params[:time]) } }
- end
- def create
- booking = Booking.new(table_id: params[:table_id], hall_id: params[:hall_id], start_date: params[:start_date], name: params[:name], phone: params[:phone])
- if booking.save
- render json: { status: :ok }
- else
- render json: { status: :unprocessable_entity }
- end
- end
- def confirm_booking
- Booking.find(params[:id]).confirm!
- redirect_to :back
- end
- def reject_booking
- Booking.find(params[:id]).reject!
- redirect_to :back
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement