Class: Decidim::ParticipatoryProcesses::Permissions

Inherits:
DefaultPermissions
  • Object
show all
Defined in:
app/permissions/decidim/participatory_processes/permissions.rb

Instance Method Summary collapse

Instance Method Details

#permissionsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/permissions/decidim/participatory_processes/permissions.rb', line 6

def permissions
  user_can_enter_processes_space_area?
  user_can_enter_process_groups_space_area?

  return permission_action if process && !process.is_a?(Decidim::ParticipatoryProcess)

  if read_admin_dashboard_action?
    user_can_read_admin_dashboard?
    return permission_action
  end

  if permission_action.scope == :public
    public_list_processes_action?
    public_list_process_groups_action?
    public_read_process_group_action?
    public_read_process_action?
    return permission_action
  end

  return permission_action unless user

  if !has_manageable_processes? && !user.admin?
    disallow!
    return permission_action
  end
  return permission_action unless permission_action.scope == :admin

  valid_process_group_action?

  user_can_read_process_list?
  user_can_read_current_process?
  user_can_create_process?

  # org admins and space admins can do everything in the admin section
  org_admin_action?
  participatory_process_type_action?

  return permission_action unless process

  user_can_read_private_users?

  moderator_action?
  collaborator_action?
  valuator_action?
  process_admin_action?

  permission_action
end