Class: Pageflow::AccountPolicy
- Inherits:
-
ApplicationPolicy
- Object
- ApplicationPolicy
- Pageflow::AccountPolicy
- Defined in:
- app/policies/pageflow/account_policy.rb
Defined Under Namespace
Classes: Scope
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #add_member_to? ⇒ Boolean
- #admin? ⇒ Boolean
- #configure_folder_on? ⇒ Boolean
- #destroy_membership_on? ⇒ Boolean
- #edit_role_on? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(user, account) ⇒ AccountPolicy
constructor
A new instance of AccountPolicy.
- #publish? ⇒ Boolean
- #read? ⇒ Boolean
- #see_badge_belonging_to? ⇒ Boolean
- #see_entry_types? ⇒ Boolean
- #see_user_quota? ⇒ Boolean
- #update? ⇒ Boolean
- #update_feature_configuration_on? ⇒ Boolean
- #update_site_on_entry_of? ⇒ Boolean
Constructor Details
#initialize(user, account) ⇒ AccountPolicy
Returns a new instance of AccountPolicy.
51 52 53 54 55 |
# File 'app/policies/pageflow/account_policy.rb', line 51 def initialize(user, account) @user = user @account = account @query = AccountRoleQuery.new(user, account) end |
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
49 50 51 |
# File 'app/policies/pageflow/account_policy.rb', line 49 def query @query end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
49 50 51 |
# File 'app/policies/pageflow/account_policy.rb', line 49 def user @user end |
Instance Method Details
#add_member_to? ⇒ Boolean
85 86 87 88 89 |
# File 'app/policies/pageflow/account_policy.rb', line 85 def add_member_to? Pageflow.config.allow_multiaccount_users && (user.admin? || query.has_at_least_role?(:manager)) end |
#admin? ⇒ Boolean
109 110 111 |
# File 'app/policies/pageflow/account_policy.rb', line 109 def admin? user.admin? end |
#configure_folder_on? ⇒ Boolean
61 62 63 |
# File 'app/policies/pageflow/account_policy.rb', line 61 def configure_folder_on? publish? end |
#destroy_membership_on? ⇒ Boolean
105 106 107 |
# File 'app/policies/pageflow/account_policy.rb', line 105 def destroy_membership_on? add_member_to? end |
#edit_role_on? ⇒ Boolean
101 102 103 |
# File 'app/policies/pageflow/account_policy.rb', line 101 def edit_role_on? user.admin? || query.has_at_least_role?(:manager) end |
#index? ⇒ Boolean
119 120 121 122 123 |
# File 'app/policies/pageflow/account_policy.rb', line 119 def index? admin? || (Pageflow.config.allow_multiaccount_users && @user.memberships.on_accounts.as_manager.any?) end |
#publish? ⇒ Boolean
57 58 59 |
# File 'app/policies/pageflow/account_policy.rb', line 57 def publish? user.admin? || query.has_at_least_role?(:publisher) end |
#read? ⇒ Boolean
69 70 71 72 73 |
# File 'app/policies/pageflow/account_policy.rb', line 69 def read? user.admin? || (query.has_at_least_role?(:manager) && Pageflow.config.allow_multiaccount_users) end |
#see_badge_belonging_to? ⇒ Boolean
113 114 115 116 117 |
# File 'app/policies/pageflow/account_policy.rb', line 113 def see_badge_belonging_to? (@account.entries & user.entries).any? || query.has_at_least_role?(:previewer) || user.admin? end |
#see_entry_types? ⇒ Boolean
96 97 98 99 |
# File 'app/policies/pageflow/account_policy.rb', line 96 def see_entry_types? user.admin? || query.has_at_least_role?(:publisher) end |
#see_user_quota? ⇒ Boolean
91 92 93 94 |
# File 'app/policies/pageflow/account_policy.rb', line 91 def see_user_quota? user.admin? || query.has_at_least_role?(:manager) end |
#update? ⇒ Boolean
75 76 77 |
# File 'app/policies/pageflow/account_policy.rb', line 75 def update? read? end |
#update_feature_configuration_on? ⇒ Boolean
79 80 81 82 83 |
# File 'app/policies/pageflow/account_policy.rb', line 79 def update_feature_configuration_on? user.admin? || (!.only_admins_may_update_features && read?) end |
#update_site_on_entry_of? ⇒ Boolean
65 66 67 |
# File 'app/policies/pageflow/account_policy.rb', line 65 def update_site_on_entry_of? publish? end |