Base progress

This commit is contained in:
2015-09-16 11:50:55 +02:00
parent ef894f9e02
commit 6a085b1ca2
52 changed files with 3686 additions and 1818 deletions
@@ -5,25 +5,27 @@ module Suppliers
@employee_shifts.include_relations(:employee, :supplier)
# Only select shifts from currently linked and employees
@employee_shifts.select! do |shift|
current_supplier.employee_ids.include?(shift.employee.try(:id))
return false unless current_supplier.employee_ids.include?(shift.employee.try(:id))
shift.employee.enrich_with_settings current_supplier.settings_for(shift.employee)
true
end
render json: JSONAPI::Serializer.serialize(@employee_shifts, serializer: Suppliers::EmployeeShiftSerializer, is_collection: true, include: %w[employee])
render json: @employee_shifts, include: %w[employee]
end
def create
@employee_shift.supplier = current_supplier
@employee_shift.save
render json: JSONAPI::Serializer.serialize(@employee_shift, serializer: Suppliers::EmployeeShiftSerializer, include: %w[employee])
render json: @employee_shift, include: %w[employee]
end
def update
@employee_shift.update employee_shift_params
render json: JSONAPI::Serializer.serialize(@employee_shift, serializer: Suppliers::EmployeeShiftSerializer)
render json: @employee_shift
end
def destroy
head :forbidden and return unless @employee_shift.supplier_id == current_supplier.id
@employee_shift.destroy
head :ok
head :no_content
end
private