Commit a5300cdf authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei

Add schedule request as service

Signed-off-by: Bruno Freitas Tissei's avatarBruno Freitas Tissei <bft15@inf.ufpr.br>
parent 3e6d5319
......@@ -24,19 +24,54 @@ module Api::V1
render json: @schedules
return
else
@schedules = policy_scope(Schedule.filter(params[:q], params[:page],
Professional.get_permission(current_user[1])))
if @schedules.nil?
render json: {
errors: ["You don't have the permission to view schedules."]
}, status: 403
if not params[:service].nil?
@schedules = policy_scope(
Schedule.where.not(situation_id: [1, 2, 3])
.filter(params[:q], params[:page],
Professional.get_permission(current_user[1])))
if @schedules.empty?
render json: {
errors: ["No schedules found."]
}, status: 404
elsif @schedules.nil?
render json: {
errors: ["You don't have the permission to view schedules."]
}, status: 403
else
response = Hash.new
response[:num_entries] = @schedules.total_count
response[:entries] = @schedules.index_response
render json: response.to_json
end
return
else
response = Hash.new
response[:num_entries] = @schedules.total_count
response[:entries] = @schedules.index_response
@schedules = policy_scope(
Schedule.where(situation_id: [1, 2, 3])
.filter(params[:q], params[:page],
Professional.get_permission(current_user[1])))
if @schedules.empty?
render json: {
errors: ["No schedules found."]
}, status: 404
elsif @schedules.nil?
render json: {
errors: ["You don't have the permission to view schedules."]
}, status: 403
else
response = Hash.new
response[:num_entries] = @schedules.total_count
response[:entries] = @schedules.index_response
render json: response.to_json
end
render json: response.to_json
return
end
end
end
......
......@@ -186,7 +186,7 @@ class ServicePlace < ApplicationRecord
end
# Method surrounding create method for ServicePlace. It associates
# Method called when creating a service_place. It associates
# the address to the service place given a cep
def create_service_place
address = Address.get_address(self.cep)
......@@ -212,7 +212,5 @@ class ServicePlace < ApplicationRecord
self.errors["cep"] << "#{self.cep} is invalid."
return false
end
#yield
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment