employee login and authentication with session

This commit is contained in:
Min Zeya Phyo
2017-04-14 22:47:44 +06:30
parent c1e61c1a39
commit db75780267
27 changed files with 137 additions and 96 deletions

View File

@@ -1,6 +1,8 @@
class Api::Restaurant::RoomsController < ActionController::API
before_action :set_room, only: [:show]
def index
render json: SeatTable.order("order_by")
render json: Room.active.order("order_by")
end
# Description
@@ -11,11 +13,15 @@ class Api::Restaurant::RoomsController < ActionController::API
end
#Input Params
# table_id: table_id
# Output
# status: error | success, error_message: <Problem with moving table>
def update
def bill
end
def move
end
private
# Use callbacks to share common setup or constraints between actions.
def set_room
@table = Room.find(params[:id])
end
end

View File

@@ -1,6 +1,8 @@
class Api::Restaurant::SeatingsController < ActionController::API
before_action :set_table, only: [:show]
def index
render json: Zone.order("order_by")
render json: Table.active.order("order_by")
end
# Description
@@ -8,14 +10,19 @@ class Api::Restaurant::SeatingsController < ActionController::API
# Output
# status: {available, cleaning, occupied, reserved}, order_id : <current_order_id>
def show
end
#Input Params
# table_id: table_id
# Output
# status: error | success, error_message: <Problem with moving table>
def update
end
def bill
end
def move
end
private
# Use callbacks to share common setup or constraints between actions.
def set_table
@table = Table.find(params[:id])
end
end

View File

@@ -1,6 +1,7 @@
class Api::Restaurant::ZonesController < ActionController::API
def index
render json: Zone.where("is_active = true")
render json: Zone.includes([:tables, :rooms]).where("is_active = true")
end
end

View File

@@ -1,4 +1,4 @@
JSONclass ApplicationController < ActionController::Base
class ApplicationController < ActionController::Base
#before_action :check_installation
protect_from_forgery with: :exception

View File

@@ -28,11 +28,9 @@ class Settings::EmployeesController < ApplicationController
respond_to do |format|
if @employee.save
format.html { redirect_to @employee, notice: 'Employee was successfully created.' }
format.json { render :show, status: :created, location: @employee }
format.html { redirect_to settings_employees_path, notice: 'Employee was successfully created.' }
else
format.html { render :new }
format.json { render json: @employee.errors, status: :unprocessable_entity }
end
end
end
@@ -42,11 +40,9 @@ class Settings::EmployeesController < ApplicationController
def update
respond_to do |format|
if @employee.update(employee_params)
format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }
format.json { render :show, status: :ok, location: @employee }
format.html { redirect_to settings_employee_path(@employee), notice: 'Employee was successfully updated.' }
else
format.html { render :edit }
format.json { render json: @employee.errors, status: :unprocessable_entity }
end
end
end
@@ -56,8 +52,7 @@ class Settings::EmployeesController < ApplicationController
def destroy
@employee.destroy
respond_to do |format|
format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }
format.json { head :no_content }
format.html { redirect_to settings_employees_url, notice: 'Employee was successfully destroyed.' }
end
end
@@ -69,6 +64,6 @@ class Settings::EmployeesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def employee_params
params.require(:employee).permit(:name, :role, :password)
params.require(:employee).permit(:name, :role, :emp_id, :password)
end
end