api integrated
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
class Api::BookingsController < ActionController::API
|
||||
class Api::BookingsController < Api::ApiController
|
||||
|
||||
|
||||
#Show customer by ID
|
||||
def create
|
||||
def index
|
||||
@customer = Customer.find_by(params[:id])
|
||||
end
|
||||
|
||||
def show
|
||||
@booking = Booking.find(params[:id])
|
||||
end
|
||||
|
||||
# private
|
||||
# def Bookings_params
|
||||
# params.permit(:id, :order_id)
|
||||
# end
|
||||
end
|
||||
|
||||
33
app/controllers/concerns/login_verification.rb
Normal file
33
app/controllers/concerns/login_verification.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
module LoginVerification
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_action :authenticate
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
# Authenticate the user with token based authentication
|
||||
def authenticate
|
||||
authenticate_session_token || render_unauthorized
|
||||
end
|
||||
|
||||
def authenticate_session_token
|
||||
token = session[:session_token]
|
||||
if (token)
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
Rails.logger.debug "token - " + token.to_s
|
||||
|
||||
@user = Employee.authenticate_by_token(token)
|
||||
if @user
|
||||
return true
|
||||
#Maybe log - login?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def render_unauthorized()
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
end
|
||||
78
app/controllers/settings/menu_items_controller.rb
Normal file
78
app/controllers/settings/menu_items_controller.rb
Normal file
@@ -0,0 +1,78 @@
|
||||
class Settings::MenuItemsController < ApplicationController
|
||||
before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy]
|
||||
before_action :set_settings_menu_category, only: [:index, :show, :edit, :new]
|
||||
# GET /settings/menu_items
|
||||
# GET /settings/menu_items.json
|
||||
def index
|
||||
@settings_menu_items = @category.menu_items
|
||||
end
|
||||
|
||||
# GET /settings/menu_items/1
|
||||
# GET /settings/menu_items/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /settings/menu_items/new
|
||||
def new
|
||||
@settings_menu_item = MenuItem.new
|
||||
end
|
||||
|
||||
# GET /settings/menu_items/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /settings/menu_items
|
||||
# POST /settings/menu_items.json
|
||||
def create
|
||||
@settings_menu_item = MenuItem.new(settings_menu_item_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu_item.save
|
||||
format.html { redirect_to @settings_menu_item, notice: 'Menu item was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_menu_item }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @settings_menu_item.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /settings/menu_items/1
|
||||
# PATCH/PUT /settings/menu_items/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_menu_item.update(settings_menu_item_params)
|
||||
format.html { redirect_to @settings_menu_item, notice: 'Menu item was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_menu_item }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @settings_menu_item.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /settings/menu_items/1
|
||||
# DELETE /settings/menu_items/1.json
|
||||
def destroy
|
||||
@settings_menu_item.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_menu_items_url, notice: 'Menu item was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_menu_item
|
||||
@settings_menu_item = MenuItem.find(params[:id])
|
||||
end
|
||||
|
||||
def set_settings_menu_category
|
||||
@category = MenuCategory.find(params[:menu_category_id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_item_params
|
||||
params.require(:settings_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user