Sha256: 81da94721243e2930ae46c4613a2a41319826d856e37be9b49f69c6c8bf6e3c6

Contents?: true

Size: 413 Bytes

Versions: 8

Compression:

Stored size: 413 Bytes

Contents

module Pageflow
  class EntryTemplatePolicy < ApplicationPolicy
    def initialize(user, entry_template)
      @user = user
      @entry_template = entry_template
    end

    def create?
      update?
    end

    def update?
      allows?(%w(publisher manager))
    end

    private

    def allows?(roles)
      @user.memberships.where(role: roles, entity: @entry_template.site.account).any?
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pageflow-17.0.4 app/policies/pageflow/entry_template_policy.rb
pageflow-17.0.3 app/policies/pageflow/entry_template_policy.rb
pageflow-17.0.2 app/policies/pageflow/entry_template_policy.rb
pageflow-17.0.1 app/policies/pageflow/entry_template_policy.rb
pageflow-17.0.0 app/policies/pageflow/entry_template_policy.rb
pageflow-16.2.0 app/policies/pageflow/entry_template_policy.rb
pageflow-16.1.0 app/policies/pageflow/entry_template_policy.rb
pageflow-16.0.0 app/policies/pageflow/entry_template_policy.rb