...
 
Commits (2)
......@@ -20,7 +20,7 @@ class SchedulePolicy < ApplicationPolicy
permission = Professional.get_permission(user[1])
if permission == "citizen"
return nil
return scope.where(citizen_id: citizen.id)
end
professional = citizen.professional
......@@ -29,7 +29,7 @@ class SchedulePolicy < ApplicationPolicy
city_id = service_place.city_id
city_hall_id = service_place.city_hall_id
return case permission
when "adm_c3sl"
scope.all
......@@ -52,13 +52,13 @@ class SchedulePolicy < ApplicationPolicy
end
end
def show?
citizen = user[0]
permission = Professional.get_permission(user[1])
if permission == "citizen"
return ((record.citizen_id == citizen.id) or
return ((record.citizen_id == citizen.id) or
(record.citizen.responsible_id == citizen.id))
end
......@@ -75,11 +75,11 @@ class SchedulePolicy < ApplicationPolicy
when permission == "adm_prefeitura"
return ((record.service_place.city_hall_id == service_place.city_hall_id))
when permission == "adm_local"
return ((record.service_place.id == service_place.id))
when permission == "atendendente_local"
when permission == "atendendente_local"
return ((record.service_place.id == service_place.id))
when permission == "responsavel_atendimento"
......@@ -117,7 +117,7 @@ class SchedulePolicy < ApplicationPolicy
return ((record.service_place.id == service_place.id) and
(record.situation.description == "Agendado"))
when permission == "atendendente_local"
when permission == "atendendente_local"
return ((record.service_place.id == service_place.id) and
(record.situation.description == "Agendado"))
......@@ -137,7 +137,7 @@ class SchedulePolicy < ApplicationPolicy
# TODO: Check for permissions between schedule and citizen being scheduled.
# It involves either the future relation between schedule and citizen or
# It involves either the future relation between schedule and citizen or
# simply the location related to the shift which the schedule is related to.
# (record.shift.service_place.city_id)
#
......@@ -157,7 +157,7 @@ class SchedulePolicy < ApplicationPolicy
if permission == "citizen"
dependants_ids = Citizen.where(responsible_id: citizen.id).pluck(:id)
# Return false if the target is neither the current citizen nor one
# Return false if the target is neither the current citizen nor one
# of his dependants
return (schedulee.id == citizen.id or (dependants_ids.include?(schedulee.id)))
end
......