Sha256: 65276a5ae95832bef848460398fb89b508cc23ceb28a25ec4702d91c644642ee

Contents?: true

Size: 661 Bytes

Versions: 11

Compression:

Stored size: 661 Bytes

Contents

module Locomotive
  class MembershipPolicy < ApplicationPolicy

    def index?
      site_admin_or_designer?
    end

    def create?
      site_admin_or_designer?
    end

    def update?
      site_admin_or_designer? && change_role?
    end

    def destroy?
      site_admin_or_designer? && change_role?
    end

    # The role cannot be set higher than the current one (we use the index in
    # the roles array to check role presidence)
    def change_role?
      roles = Locomotive::Membership::ROLES
      roles.index(resource.role.to_s) <= roles.index(membership.role.to_s)
    end

    def permitted_attributes
      [:email, :role]
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/policies/locomotive/membership_policy.rb
locomotivecms-4.2.0.alpha1 app/policies/locomotive/membership_policy.rb
locomotivecms-4.1.1 app/policies/locomotive/membership_policy.rb
locomotivecms-4.1.0 app/policies/locomotive/membership_policy.rb
locomotivecms-4.1.0.rc1 app/policies/locomotive/membership_policy.rb
locomotivecms-4.0.3 app/policies/locomotive/membership_policy.rb
locomotivecms-4.0.2 app/policies/locomotive/membership_policy.rb
locomotivecms-4.0.1 app/policies/locomotive/membership_policy.rb
locomotivecms-4.0.0 app/policies/locomotive/membership_policy.rb
locomotivecms-4.0.0.rc0 app/policies/locomotive/membership_policy.rb
locomotivecms-4.0.0.alpha3 app/policies/locomotive/membership_policy.rb