decidim 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim might be problematic. Click here for more details.

Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1626 -0
  3. data/Gemfile.lock +82 -82
  4. data/decidim-admin/app/assets/stylesheets/decidim/admin/_variables.scss +2 -0
  5. data/decidim-admin/app/assets/stylesheets/decidim/admin/extra/_cards.scss +6 -0
  6. data/decidim-admin/app/assets/stylesheets/decidim/admin/modules/_typography.scss +4 -0
  7. data/decidim-admin/app/commands/decidim/admin/create_participatory_process_admin.rb +3 -5
  8. data/decidim-admin/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
  9. data/decidim-admin/app/controllers/decidim/admin/application_controller.rb +1 -1
  10. data/decidim-admin/app/controllers/decidim/admin/categories_controller.rb +9 -9
  11. data/decidim-admin/app/controllers/decidim/admin/concerns/participatory_process_admin.rb +1 -8
  12. data/decidim-admin/app/controllers/decidim/admin/exports_controller.rb +2 -2
  13. data/decidim-admin/app/controllers/decidim/admin/feature_permissions_controller.rb +2 -2
  14. data/decidim-admin/app/controllers/decidim/admin/features/base_controller.rb +0 -5
  15. data/decidim-admin/app/controllers/decidim/admin/features_controller.rb +4 -4
  16. data/decidim-admin/app/controllers/decidim/admin/moderations_controller.rb +1 -1
  17. data/decidim-admin/app/controllers/decidim/admin/participatory_process_attachments_controller.rb +2 -2
  18. data/decidim-admin/app/controllers/decidim/admin/participatory_process_copies_controller.rb +3 -9
  19. data/decidim-admin/app/controllers/decidim/admin/participatory_process_publications_controller.rb +4 -4
  20. data/decidim-admin/app/controllers/decidim/admin/participatory_process_step_activations_controller.rb +2 -2
  21. data/decidim-admin/app/controllers/decidim/admin/participatory_process_step_ordering_controller.rb +2 -2
  22. data/decidim-admin/app/controllers/decidim/admin/participatory_process_steps_controller.rb +6 -6
  23. data/decidim-admin/app/controllers/decidim/admin/participatory_process_user_roles_controller.rb +13 -15
  24. data/decidim-admin/app/controllers/decidim/admin/participatory_processes_controller.rb +16 -18
  25. data/decidim-admin/app/controllers/decidim/admin/users_controller.rb +4 -4
  26. data/decidim-admin/app/forms/decidim/admin/participatory_process_user_role_form.rb +2 -2
  27. data/decidim-admin/app/models/decidim/admin/abilities/{admin_user.rb → admin_ability.rb} +3 -6
  28. data/decidim-admin/app/models/decidim/admin/abilities/{base.rb → base_ability.rb} +1 -4
  29. data/decidim-admin/app/models/decidim/admin/abilities/{participatory_process_admin.rb → participatory_process_admin_ability.rb} +18 -28
  30. data/decidim-admin/app/models/decidim/admin/abilities/participatory_process_collaborator_ability.rb +19 -0
  31. data/decidim-admin/app/models/decidim/admin/abilities/participatory_process_moderator_ability.rb +23 -0
  32. data/decidim-admin/app/queries/decidim/admin/process_admins.rb +1 -1
  33. data/decidim-admin/app/views/decidim/admin/categories/index.html.erb +9 -9
  34. data/decidim-admin/app/views/decidim/admin/categories/new.html.erb +1 -1
  35. data/decidim-admin/app/views/decidim/admin/features/_form.html.erb +1 -1
  36. data/decidim-admin/app/views/decidim/admin/features/edit.html.erb +1 -1
  37. data/decidim-admin/app/views/decidim/admin/features/new.html.erb +1 -1
  38. data/decidim-admin/app/views/decidim/admin/participatory_process_copies/new.html.erb +1 -1
  39. data/decidim-admin/app/views/decidim/admin/participatory_process_groups/index.html.erb +5 -1
  40. data/decidim-admin/app/views/decidim/admin/participatory_process_steps/index.html.erb +9 -9
  41. data/decidim-admin/app/views/decidim/admin/participatory_process_user_roles/index.html.erb +6 -6
  42. data/decidim-admin/app/views/decidim/admin/participatory_processes/edit.html.erb +6 -6
  43. data/decidim-admin/app/views/decidim/admin/participatory_processes/index.html.erb +11 -1
  44. data/decidim-admin/app/views/layouts/decidim/admin/participatory_process.html.erb +18 -18
  45. data/decidim-admin/config/locales/ca.yml +4 -3
  46. data/decidim-admin/config/locales/en.yml +1 -0
  47. data/decidim-admin/config/locales/es.yml +1 -2
  48. data/decidim-admin/db/migrate/20170714083651_rename_participatory_process_user_roles_table.rb +7 -0
  49. data/decidim-admin/lib/decidim/admin/engine.rb +8 -6
  50. data/decidim-admin/lib/decidim/admin/test/factories.rb +1 -1
  51. data/decidim-admin/spec/commands/create_participatory_process_admin_spec.rb +4 -4
  52. data/decidim-admin/spec/models/abilities/{admin_user_spec.rb → admin_ability_spec.rb} +1 -1
  53. data/decidim-admin/spec/models/abilities/{participatory_process_admin_spec.rb → participatory_process_admin_ability_spec.rb} +3 -3
  54. data/decidim-admin/spec/models/abilities/participatory_process_collaborator_ability_spec.rb +18 -0
  55. data/decidim-admin/spec/queries/process_admins_spec.rb +1 -1
  56. data/decidim-admin/spec/views/decidim/static_pages/_form.html.erb_spec.rb +1 -1
  57. data/decidim-budgets/config/locales/ca.yml +2 -2
  58. data/decidim-comments/app/models/decidim/comments/abilities/admin_ability.rb +19 -0
  59. data/decidim-comments/app/models/decidim/comments/abilities/{admin_user.rb → current_user_ability.rb} +4 -6
  60. data/decidim-comments/app/models/decidim/comments/abilities/participatory_process_admin_ability.rb +19 -0
  61. data/decidim-comments/app/models/decidim/comments/abilities/participatory_process_moderator_ability.rb +19 -0
  62. data/decidim-comments/lib/decidim/comments/admin_engine.rb +5 -2
  63. data/decidim-comments/lib/decidim/comments/engine.rb +6 -0
  64. data/decidim-comments/spec/models/abilities/{admin_user_spec.rb → admin_ability_spec.rb} +1 -1
  65. data/decidim-comments/spec/models/abilities/{process_admin_user_spec.rb → participatory_process_admin_ability_spec.rb} +3 -2
  66. data/decidim-meetings/app/controllers/decidim/meetings/meeting_widgets_controller.rb +1 -0
  67. data/decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb +2 -2
  68. data/decidim-meetings/app/views/decidim/meetings/meeting_widgets/show.html.erb +1 -1
  69. data/decidim-meetings/app/views/decidim/meetings/meetings/_meetings.html.erb +2 -0
  70. data/decidim-meetings/config/locales/ca.yml +1 -1
  71. data/decidim-meetings/spec/features/explore_meetings_spec.rb +11 -0
  72. data/decidim-proposals/app/controllers/decidim/proposals/proposals_controller.rb +2 -1
  73. data/decidim-proposals/app/forms/decidim/proposals/admin/proposal_answer_form.rb +1 -1
  74. data/decidim-proposals/app/helpers/decidim/proposals/application_helper.rb +23 -11
  75. data/decidim-proposals/app/models/decidim/proposals/abilities/{admin_user.rb → admin_ability.rb} +5 -12
  76. data/decidim-proposals/app/models/decidim/proposals/abilities/{current_user.rb → current_user_ability.rb} +1 -2
  77. data/decidim-proposals/app/models/decidim/proposals/abilities/{process_admin_user.rb → participatory_process_admin_ability.rb} +10 -22
  78. data/decidim-proposals/app/models/decidim/proposals/abilities/participatory_process_moderator_ability.rb +19 -0
  79. data/decidim-proposals/app/models/decidim/proposals/proposal.rb +8 -0
  80. data/decidim-proposals/app/services/decidim/proposals/proposal_search.rb +5 -2
  81. data/decidim-proposals/app/views/decidim/proposals/admin/proposal_answers/edit.html.erb +1 -1
  82. data/decidim-proposals/app/views/decidim/proposals/proposals/_filters.html.erb +1 -1
  83. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal_badge.html.erb +1 -1
  84. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposals.html.erb +10 -1
  85. data/decidim-proposals/config/locales/ca.yml +3 -0
  86. data/decidim-proposals/config/locales/en.yml +3 -0
  87. data/decidim-proposals/config/locales/es.yml +3 -0
  88. data/decidim-proposals/lib/decidim/proposals/admin_engine.rb +5 -2
  89. data/decidim-proposals/lib/decidim/proposals/engine.rb +1 -1
  90. data/decidim-proposals/lib/decidim/proposals/feature.rb +4 -0
  91. data/decidim-proposals/lib/decidim/proposals/proposal_serializer.rb +4 -0
  92. data/decidim-proposals/spec/features/proposals_spec.rb +12 -5
  93. data/decidim-proposals/spec/models/decidim/proposals/abilities/{admin_user_spec.rb → admin_ability_spec.rb} +1 -1
  94. data/decidim-proposals/spec/models/decidim/proposals/abilities/{process_admin_user_spec.rb → participatory_process_admin_ability.rb} +10 -2
  95. data/decidim-proposals/spec/services/decidim/proposals/proposal_serializer_spec.rb +7 -0
  96. data/decidim-proposals/spec/shared/manage_proposals_examples.rb +21 -0
  97. data/decidim-results/app/controllers/decidim/results/results_controller.rb +2 -1
  98. data/decidim-results/app/views/decidim/results/results/_results.html.erb +2 -0
  99. data/decidim-results/config/locales/ca.yml +1 -1
  100. data/decidim-results/spec/features/comments_spec.rb +1 -1
  101. data/decidim-results/spec/features/explore_results_spec.rb +11 -0
  102. data/decidim-surveys/app/models/decidim/surveys/abilities/admin_ability.rb +17 -0
  103. data/decidim-surveys/app/models/decidim/surveys/abilities/{current_user.rb → current_user_ability.rb} +1 -1
  104. data/decidim-surveys/app/models/decidim/surveys/abilities/participatory_process_admin_ability.rb +19 -0
  105. data/decidim-surveys/config/locales/ca.yml +1 -1
  106. data/decidim-surveys/lib/decidim/surveys/admin_engine.rb +4 -2
  107. data/decidim-surveys/lib/decidim/surveys/engine.rb +1 -1
  108. data/decidim-surveys/spec/models/decidim/surveys/abilities/{admin_user_spec.rb → admin_ability_spec.rb} +1 -1
  109. data/decidim-surveys/spec/models/decidim/surveys/abilities/{current_user_spec.rb → current_user_ability_spec.rb} +1 -1
  110. data/decidim-surveys/spec/models/decidim/surveys/abilities/{process_admin_user_spec.rb → participatory_process_admin_ability_spec.rb} +3 -2
  111. data/decidim-system/app/commands/decidim/system/register_organization.rb +2 -2
  112. data/decidim-system/spec/commands/decidim/system/register_organization_spec.rb +1 -1
  113. data/docs/getting_started.md +1 -1
  114. data/lib/generators/decidim/templates/initializer.rb +2 -2
  115. data/package.json +1 -3
  116. data/yarn.lock +21 -18
  117. metadata +52 -54
  118. data/decidim-admin/app/models/decidim/admin/abilities/collaborator_user.rb +0 -20
  119. data/decidim-admin/app/models/decidim/admin/participatory_process_user_role.rb +0 -15
  120. data/decidim-admin/app/queries/decidim/admin/manageable_participatory_processes_for_user.rb +0 -42
  121. data/decidim-admin/app/queries/decidim/admin/process_admin_roles_for_process.rb +0 -36
  122. data/decidim-admin/db/seeds.rb +0 -24
  123. data/decidim-admin/spec/models/abilities/collaborator_user_spec.rb +0 -67
  124. data/decidim-admin/spec/models/participatory_process_user_role_spec.rb +0 -39
  125. data/decidim-admin/spec/queries/manageable_participatory_processes_for_user_spec.rb +0 -39
  126. data/decidim-admin/spec/queries/process_admin_roles_for_process_spec.rb +0 -19
  127. data/decidim-comments/app/models/decidim/comments/abilities/process_admin_user.rb +0 -34
  128. data/decidim-meetings/app/views/decidim/meetings/meeting_widgets/.erb +0 -16
  129. data/decidim-surveys/app/models/decidim/surveys/abilities/admin_user.rb +0 -34
  130. data/decidim-surveys/app/models/decidim/surveys/abilities/process_admin_user.rb +0 -44
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Admin
5
- module Abilities
6
- # Defines the abilities for a collaborator user in the admin
7
- # section. Intended to be used with `cancancan`.
8
- class CollaboratorUser
9
- include CanCan::Ability
10
-
11
- def initialize(user, _context)
12
- return unless user && user.role?(:collaborator)
13
-
14
- can :manage, :admin_dashboard
15
- can :preview, ParticipatoryProcess
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Admin
5
- # Defines a relation between a user and a participatory process, and what
6
- # kind of relation does the user has.
7
- class ParticipatoryProcessUserRole < ApplicationRecord
8
- belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User", optional: true
9
- belongs_to :participatory_process, foreign_key: "decidim_participatory_process_id", class_name: "Decidim::ParticipatoryProcess", optional: true
10
-
11
- ROLES = %w(admin collaborator).freeze
12
- validates :role, inclusion: { in: ROLES }, uniqueness: { scope: [:user, :participatory_process] }
13
- end
14
- end
15
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Admin
5
- # A class used to find the ParticipatoryProcesses that the given user can
6
- # manage.
7
- class ManageableParticipatoryProcessesForUser < Rectify::Query
8
- # Syntactic sugar to initialize the class and return the queried objects.
9
- #
10
- # user - a User that needs to find which processes can manage
11
- def self.for(user)
12
- new(user).query
13
- end
14
-
15
- # Initializes the class.
16
- #
17
- # user - a User that needs to find which processes can manage
18
- def initialize(user)
19
- @user = user
20
- end
21
-
22
- # Finds the ParticipatoryProcesses that the given user can manage.
23
- #
24
- # Returns an ActiveRecord::Relation.
25
- def query
26
- return user.organization.participatory_processes if user.role?(:admin) || user.role?(:collaborator)
27
-
28
- ParticipatoryProcess.where(id: process_ids)
29
- end
30
-
31
- private
32
-
33
- attr_reader :user
34
-
35
- def process_ids
36
- ParticipatoryProcessUserRole
37
- .where(user: user, role: :admin)
38
- .pluck(:decidim_participatory_process_id)
39
- end
40
- end
41
- end
42
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Admin
5
- # A class used to find the roles of the users that can manage a given
6
- # participatory process in a process admin role (that is, processs that are
7
- # not organization admins).
8
- class ProcessAdminRolesForProcess < Rectify::Query
9
- # Syntactic sugar to initialize the class and return the queried objects.
10
- #
11
- # process - a process that needs to find its process admins
12
- def self.for(process)
13
- new(process).query
14
- end
15
-
16
- # Initializes the class.
17
- #
18
- # process - a process that needs to find its process admins
19
- def initialize(process)
20
- @process = process
21
- end
22
-
23
- # Finds the UserRoles of the users that can manage the given process.
24
- #
25
- # Returns an ActiveRecord::Relation.
26
- def query
27
- ParticipatoryProcessUserRole
28
- .where(participatory_process: process, role: [:admin, :collaborator])
29
- end
30
-
31
- private
32
-
33
- attr_reader :process
34
- end
35
- end
36
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if !Rails.env.production? || ENV["SEED"]
4
- staging_organization = Decidim::Organization.order(id: :asc).first
5
-
6
- process_admin = Decidim::User.create!(
7
- name: "Process Admin",
8
- email: "process_admin@example.org",
9
- password: "decidim123456",
10
- password_confirmation: "decidim123456",
11
- confirmed_at: Time.current,
12
- locale: I18n.default_locale,
13
- organization: staging_organization,
14
- tos_agreement: true,
15
- comments_notifications: true,
16
- replies_notifications: true
17
- )
18
-
19
- Decidim::Admin::ParticipatoryProcessUserRole.create!(
20
- user: process_admin,
21
- participatory_process: Decidim::ParticipatoryProcess.order(id: :asc).first,
22
- role: "admin"
23
- )
24
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe Decidim::Admin::Abilities::CollaboratorUser do
6
- let(:user) { build(:user, :collaborator) }
7
-
8
- subject { described_class.new(user, {}) }
9
-
10
- context "when the user is not a collaborator" do
11
- let(:user) { build(:user) }
12
-
13
- it "doesn't have any permission" do
14
- expect(subject.permissions[:can]).to be_empty
15
- expect(subject.permissions[:cannot]).to be_empty
16
- end
17
- end
18
-
19
- it { is_expected.to be_able_to(:preview, Decidim::ParticipatoryProcess) }
20
-
21
- context "when a page is a default one" do
22
- let(:page) { build(:static_page, :default) }
23
- let(:form) { Decidim::Admin::StaticPageForm.new(slug: page.slug) }
24
-
25
- it { is_expected.not_to be_able_to(:update_slug, page) }
26
- it { is_expected.not_to be_able_to(:update_slug, form) }
27
- it { is_expected.not_to be_able_to(:destroy, page) }
28
- it { is_expected.not_to be_able_to(:destroy, form) }
29
- end
30
-
31
- context "when a page is not default one" do
32
- let(:page) { build(:static_page) }
33
- let(:form) { Decidim::Admin::StaticPageForm.new(slug: page.slug) }
34
-
35
- it { is_expected.not_to be_able_to(:update_slug, page) }
36
- it { is_expected.not_to be_able_to(:update_slug, form) }
37
- it { is_expected.not_to be_able_to(:destroy, page) }
38
- it { is_expected.not_to be_able_to(:destroy, form) }
39
- end
40
-
41
- context "when the organization is the one they belong to" do
42
- let(:organization) { user.organization }
43
-
44
- it { is_expected.not_to be_able_to(:update, organization) }
45
- it { is_expected.not_to be_able_to(:read, organization) }
46
- end
47
-
48
- context "when the organization is different form the one they belong to" do
49
- let(:organization) { build(:organization) }
50
-
51
- it { is_expected.not_to be_able_to(:update, organization) }
52
- it { is_expected.not_to be_able_to(:read, organization) }
53
- end
54
-
55
- context "when destroying a user" do
56
- context "when the user is themselves" do
57
- let(:user_to_destroy) { user }
58
- it { is_expected.not_to be_able_to(:destroy, user_to_destroy) }
59
- end
60
-
61
- context "when it is another user" do
62
- let(:user_to_destroy) { build(:user) }
63
-
64
- it { is_expected.not_to be_able_to(:destroy, user_to_destroy) }
65
- end
66
- end
67
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- module Decidim
6
- module Admin
7
- describe ParticipatoryProcessUserRole do
8
- let(:participatory_process_user_role) { build(:participatory_process_user_role, role: role) }
9
- let(:role) { "admin" }
10
-
11
- subject { participatory_process_user_role }
12
-
13
- it { is_expected.to be_valid }
14
-
15
- context "when the role is not admin" do
16
- let(:role) { "fake_role" }
17
-
18
- it { is_expected.not_to be_valid }
19
- end
20
-
21
- context "when a role already exists" do
22
- let(:participatory_process_user_role) do
23
- build(
24
- :participatory_process_user_role,
25
- role: existing_role.role,
26
- user: existing_role.user,
27
- participatory_process: existing_role.participatory_process
28
- )
29
- end
30
-
31
- let!(:existing_role) do
32
- create(:participatory_process_user_role, role: role)
33
- end
34
-
35
- it { is_expected.not_to be_valid }
36
- end
37
- end
38
- end
39
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe Decidim::Admin::ManageableParticipatoryProcessesForUser do
6
- let!(:organization_process) { create :participatory_process, organization: user.organization }
7
- let!(:external_process) { create :participatory_process }
8
-
9
- subject { described_class.new(user) }
10
-
11
- context "when the user is an admin" do
12
- let(:user) { create :user, :admin }
13
-
14
- it "returns only the organization processes" do
15
- expect(subject.query).to eq [organization_process]
16
- end
17
- end
18
-
19
- context "when the user is a collaborator" do
20
- let(:user) { create :user, :collaborator }
21
-
22
- it "returns only the organization processes" do
23
- expect(subject.query).to eq [organization_process]
24
- end
25
- end
26
-
27
- context "when the user is not an admin" do
28
- let(:user) { create :user }
29
- let!(:organization_process2) { create :participatory_process, organization: user.organization }
30
-
31
- before do
32
- create :participatory_process_user_role, user: user, participatory_process: organization_process
33
- end
34
-
35
- it "returns the processes the user can admin" do
36
- expect(subject.query).to eq [organization_process]
37
- end
38
- end
39
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe Decidim::Admin::ProcessAdminRolesForProcess do
6
- let(:organization) { create :organization }
7
- let!(:process1) { create :participatory_process, organization: organization }
8
- let!(:process2) { create :participatory_process, organization: organization }
9
- let!(:user_role1) { create :participatory_process_user_role, participatory_process: process1, role: :admin }
10
- let!(:user_role2) { create :participatory_process_user_role, participatory_process: process2 }
11
- let!(:user_role3) { create :participatory_process_user_role, participatory_process: process1, role: :collaborator }
12
-
13
- subject { described_class.new(process1) }
14
-
15
- it "returns only the user roles for the given process" do
16
- expect(subject.query).to include user_role1
17
- expect(subject.query).to include user_role3
18
- end
19
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Comments
5
- module Abilities
6
- # Defines the abilities related to comments for a logged in process admin user.
7
- # Intended to be used with `cancancan`.
8
- class ProcessAdminUser
9
- include CanCan::Ability
10
-
11
- attr_reader :user, :context
12
-
13
- def initialize(user, context)
14
- return unless user && !user.role?(:admin)
15
-
16
- @user = user
17
- @context = context
18
-
19
- can :manage, Comment do |comment|
20
- participatory_processes.include?(comment.feature.participatory_process)
21
- end
22
- can :unreport, Comment
23
- can :hide, Comment
24
- end
25
-
26
- private
27
-
28
- def participatory_processes
29
- @participatory_processes ||= Decidim::Admin::ManageableParticipatoryProcessesForUser.for(@user)
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,16 +0,0 @@
1
- <div class="column">
2
- <article class="card card--meeting">
3
- <div class="card__content">
4
- <%= link_to model, class: "card__link" do %>
5
- <h5 class="card__title"><%= translated_attribute model.title %></h5>
6
- <% end %>
7
- <%== translated_attribute model.description %>
8
- <div class="address card__extra">
9
- <div class="address__icon">
10
- <%= icon "meetings", remove_icon_class: true, width: 40, height: 70 %>
11
- </div>
12
- <%= render partial: "decidim/shared/address_details", locals: { icon_name: "meetings", geolocalizable: model } %>
13
- </div>
14
- </div>
15
- </article>
16
- </div>
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Surveys
5
- module Abilities
6
- # Defines the abilities related to surveys for a logged in admin user.
7
- # Intended to be used with `cancancan`.
8
- class AdminUser
9
- include CanCan::Ability
10
-
11
- attr_reader :user, :context
12
-
13
- def initialize(user, context)
14
- return unless user && user.role?(:admin)
15
-
16
- @user = user
17
- @context = context
18
-
19
- can :manage, Survey
20
- end
21
-
22
- private
23
-
24
- def current_settings
25
- context.fetch(:current_settings, nil)
26
- end
27
-
28
- def feature_settings
29
- context.fetch(:feature_settings, nil)
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Surveys
5
- module Abilities
6
- # Defines the abilities related to surveys for a logged in process admin user.
7
- # Intended to be used with `cancancan`.
8
- class ProcessAdminUser
9
- include CanCan::Ability
10
-
11
- attr_reader :user, :context
12
-
13
- def initialize(user, context)
14
- return unless user && !user.role?(:admin)
15
-
16
- @user = user
17
- @context = context
18
-
19
- can :manage, Survey do |survey|
20
- participatory_processes.include?(survey.feature.participatory_process)
21
- end
22
- end
23
-
24
- private
25
-
26
- def current_settings
27
- context.fetch(:current_settings, nil)
28
- end
29
-
30
- def feature_settings
31
- context.fetch(:feature_settings, nil)
32
- end
33
-
34
- def current_feature
35
- context.fetch(:current_feature, nil)
36
- end
37
-
38
- def participatory_processes
39
- @participatory_processes ||= Decidim::Admin::ManageableParticipatoryProcessesForUser.for(@user)
40
- end
41
- end
42
- end
43
- end
44
- end