Class: Decidim::Kids::Permissions
- Inherits:
-
DefaultPermissions
- Object
- DefaultPermissions
- Decidim::Kids::Permissions
- Defined in:
- app/permissions/decidim/kids/permissions.rb
Instance Method Summary collapse
- #authorizations_action? ⇒ Boolean
- #conversation_action? ⇒ Boolean
- #minor_accounts_action? ⇒ Boolean
- #permissions ⇒ Object
Instance Method Details
#authorizations_action? ⇒ Boolean
39 40 41 42 43 44 45 46 47 48 |
# File 'app/permissions/decidim/kids/permissions.rb', line 39 def return unless .subject == :authorizations case .action when :all return allow! unless user.organization.minors_participation_enabled? toggle_allow(!user.minor?) end end |
#conversation_action? ⇒ Boolean
50 51 52 53 54 55 56 57 58 |
# File 'app/permissions/decidim/kids/permissions.rb', line 50 def conversation_action? return unless .subject == :conversation return unless user.organization.minors_participation_enabled? return unless [:create, :update].include?(.action) conversation = context.fetch(:conversation) interlocutor = context.fetch(:interlocutor, user) toggle_allow(conversation.participants.all? { |p| minor_conversation_participant?(interlocutor, p) }) end |
#minor_accounts_action? ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/permissions/decidim/kids/permissions.rb', line 18 def minor_accounts_action? return unless .subject == :minor_accounts if !user.organization.minors_participation_enabled? || user.minor? || !user.confirmed? disallow! else case .action when :index allow! when :create can_create_minor_account? when :edit can_edit_minor_account? when :delete can_destroy_minor_account? when :impersonate can_impersonate_minor_account? end end end |
#permissions ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/permissions/decidim/kids/permissions.rb', line 6 def # return Decidim::Kids::Admin::Permissions.new(user, permission_action, context).permissions if permission_action.scope == :admin return if .scope == :admin return unless user minor_accounts_action? conversation_action? end |