Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

24 lines
580 B

class SalesLogPolicy
attr_reader :user, :log
def initialize(user, log)
@user = user
@log = log
end
def destroy?
return false unless log && user
# Can only delete editable logs
return false unless log.collection_period_open?
# Support users can delete any log
return true if user.support?
# Data coordinators can delete any log visible to them
return true if user.data_coordinator? && user.sales_logs.visible.include?(log)
# Data providers can only delete the log if it is assigned to them
log.created_by == user
end
end