Sha256: 2cc40448a1fe00dd554222281df00ea11195caf4f09ecec7f1ac84cb110ec746

Contents?: true

Size: 847 Bytes

Versions: 65

Compression:

Stored size: 847 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/letters"

module Renalware
  module Letters
    class LetterPolicy < BasePolicy
      alias_attribute :letter, :record

      def author?
        has_write_privileges?
      end

      def update?
        false
      end

      def submit_for_review?
        false
      end

      def reject?
        false
      end

      def approve?
        false
      end

      def complete?
        false
      end

      def destroy?
        return false if user_is_read_only?
        return false if %i(approved completed).include?(letter_state)

        user_is_admin? ||
          user_is_super_admin? ||
          letter.author == user ||
          letter.created_by == user
      end

      private

      def letter_state
        record.state.downcase.to_sym
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
renalware-core-2.0.87 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.86 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.85 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.84 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.83 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.82 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.81 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.80 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.79 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.78 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.77 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.76 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.75 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.74 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.73 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.72 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.71 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.70 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.69 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.68 app/policies/renalware/letters/letter_policy.rb