Class: Decidim::DecidimAwesome::Admin::Permissions

Inherits:
Decidim::DefaultPermissions
  • Object
show all
Includes:
ConfigConstraintsHelpers
Defined in:
app/permissions/decidim/decidim_awesome/admin/permissions.rb

Constant Summary

Constants included from ConfigConstraintsHelpers

ConfigConstraintsHelpers::OTHER_MANIFESTS

Instance Method Summary collapse

Methods included from ConfigConstraintsHelpers

#check, #component_manifests, #components_list, #enabled_configs, #md5, #participatory_space_manifests, #participatory_spaces_list, #translate_constraint_value

Instance Method Details

#permissionsObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/permissions/decidim/decidim_awesome/admin/permissions.rb', line 9

def permissions
  return permission_action if permission_action.scope != :admin
  return permission_action unless user
  return permission_action if user.read_attribute("admin").blank?
  return permission_action unless permission_action.action == :edit_config

  if permission_action.subject == :admin_accountability && DecidimAwesome.admin_accountability.respond_to?(:include?)
    if global?
      toggle_allow(DecidimAwesome.admin_accountability.include?(:admin_roles))
    else
      toggle_allow(DecidimAwesome.admin_accountability.include?(:participatory_space_roles))
    end
  elsif permission_action.subject == :private_data && config_enabled?(:proposal_private_custom_fields)
    if private_data.present?
      allow! if private_data.destroyable?
    else
      allow!
    end
  else
    toggle_allow(config_enabled?(*permission_action.subject))
  end

  permission_action
end