Commit 9260f745 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei

Fix request for service

Signed-off-by: Bruno Freitas Tissei's avatarBruno Freitas Tissei <bft15@inf.ufpr.br>
parent b6a87690
Pipeline #14867 failed with stage
in 1 minute and 17 seconds
......@@ -47,54 +47,56 @@ module Api::V1
end
return
elsif 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])))
else
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
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
end
return
else
@schedules = policy_scope(
Schedule.where(situation_id: [1, 2, 3])
.filter(params[:q], params[:page],
Professional.get_permission(current_user[1])))
return
else
@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
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
end
return
return
end
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