All the little details

This commit is contained in:
2015-02-20 19:21:25 +01:00
parent cde551dc7f
commit d9e69beb5f
38 changed files with 256 additions and 57 deletions
@@ -1,7 +1,8 @@
module Suppliers
class EmployeeShiftsController < Suppliers::ApplicationController
def index
render json: current_supplier.employee_shifts, each_serializer: Suppliers::EmployeeShiftSerializer
@employee_shifts = EmployeeShift.for_supplier(current_supplier, relevant_from: 1.week.ago)
render json: @employee_shifts, each_serializer: Suppliers::EmployeeShiftSerializer
end
def create
@employee_shift.supplier = current_supplier
@@ -14,10 +15,16 @@ module Suppliers
render json: @employee_shift, serializer: Suppliers::EmployeeShiftSerializer
end
def destroy
head :forbidden and return unless @employee_shift.supplier_id == current_supplier.id
@employee_shift.destroy
head :ok
end
private
def employee_shift_params
params.require(:employee_shift).permit(:start_on, :end_on, :employee_id)
params.require(:employee_shift).permit(:start_from, :end_on, :employee_id, :description)
end
end