Sha256: 5f1d047db182ea296d7e9f44f6f264d3c6d119bc67f43e45ac1cb2d12552eb2a

Contents?: true

Size: 691 Bytes

Versions: 89

Compression:

Stored size: 691 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/clinics"

module Renalware
  module Clinics
    class ClinicVisitPolicy < BasePolicy
      def destroy?
        return false unless record.persisted?

        record.created_at > Renalware.config.new_clinic_visit_deletion_window.ago &&
          (user_created_record? || user_is_super_admin?)
      end

      def edit?
        return false unless record.persisted?

        record.created_at > Renalware.config.new_clinic_visit_edit_window.ago &&
          (user_created_record? || user_is_super_admin?)
      end

      private

      def user_created_record?
        record.created_by_id == user.id
      end
    end
  end
end

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.1.0 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.167 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.166 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.165 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.164 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.163 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.162 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.161 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.160 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.159 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.158 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.157 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.156 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.155 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.153 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.152 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.151 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.149 app/policies/renalware/clinics/clinic_visit_policy.rb
renalware-core-2.0.148 app/policies/renalware/clinics/clinic_visit_policy.rb