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
@@ -150,7 +150,7 @@ ca:
150
150
  error: S'ha produït un error en crear aquesta categoria.
151
151
  success: Categoria creada correctament.
152
152
  destroy:
153
- error: S'ha produït un error en eliminar aquesta categoria. Si us plau, elimini qualsevol subcategoria en primer lloc, assegureu-vos que cap altra entitat pertany a aquesta categoria i torni a intentar-ho.
153
+ error: S'ha produït un error en eliminar aquesta categoria. Si us plau, elimina qualsevol subcategoria en primer lloc, assegura't que cap altra entitat pertany a aquesta categoria i torna a intentar-ho.
154
154
  success: Categoria eliminada correctament.
155
155
  edit:
156
156
  title: Edita categoria
@@ -281,6 +281,7 @@ ca:
281
281
  roles:
282
282
  admin: Administrador
283
283
  collaborator: Col·laborador
284
+ moderator: Moderador
284
285
  scope:
285
286
  fields:
286
287
  created_at: Data de creació
@@ -331,13 +332,13 @@ ca:
331
332
  form:
332
333
  interpolations_hint: 'Consell: Podeu utilitzar "%{name}" en qualsevol part del cos o assumpte i serà reemplaçat pel nom del destinatari.'
333
334
  index:
334
- confirm_delete: Esteu segur que voleu suprimir aquest butlletí?
335
+ confirm_delete: Segur que vols suprimir aquest butlletí?
335
336
  title: Butlletins
336
337
  new:
337
338
  save: Desar
338
339
  title: Nou butlletí
339
340
  show:
340
- confirm_deliver: Estàs segur de que vols enviar aquest butlletí? Aquesta acció no es pot desfer.
341
+ confirm_deliver: Segur que vols enviar aquest butlletí? Aquesta acció no es pot desfer.
341
342
  deliver: Enviar butlletí
342
343
  preview: Previsualitzar
343
344
  subject: Assumpte
@@ -282,6 +282,7 @@ en:
282
282
  roles:
283
283
  admin: Administrator
284
284
  collaborator: Collaborator
285
+ moderator: Moderator
285
286
  scope:
286
287
  fields:
287
288
  created_at: Created at
@@ -281,6 +281,7 @@ es:
281
281
  roles:
282
282
  admin: Administrador
283
283
  collaborator: Colaborador
284
+ moderator: Moderador
284
285
  scope:
285
286
  fields:
286
287
  created_at: Fecha de creación
@@ -553,8 +554,6 @@ es:
553
554
  participatory_processes:
554
555
  participatory_process_groups:
555
556
  none: Ninguno
556
- forms:
557
- required: Obligatorio
558
557
  layouts:
559
558
  decidim:
560
559
  admin:
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RenameParticipatoryProcessUserRolesTable < ActiveRecord::Migration[5.1]
4
+ def change
5
+ rename_table :decidim_admin_participatory_process_user_roles, :decidim_participatory_process_user_roles
6
+ end
7
+ end
@@ -13,8 +13,6 @@ require "foundation_rails_helper"
13
13
  require "autoprefixer-rails"
14
14
  require "rectify"
15
15
 
16
- require_dependency File.join(__dir__, "..", "..", "..", "app/models/decidim/admin/abilities/admin_user")
17
-
18
16
  module Decidim
19
17
  module Admin
20
18
  # Decidim's core Rails Engine.
@@ -33,9 +31,12 @@ module Decidim
33
31
 
34
32
  initializer "decidim_admin.inject_abilities_to_user" do |_app|
35
33
  Decidim.configure do |config|
36
- config.abilities += ["Decidim::Admin::Abilities::AdminUser"]
37
- config.abilities += ["Decidim::Admin::Abilities::ParticipatoryProcessAdmin"]
38
- config.abilities += ["Decidim::Admin::Abilities::CollaboratorUser"]
34
+ config.admin_abilities += [
35
+ "Decidim::Admin::Abilities::AdminAbility",
36
+ "Decidim::Admin::Abilities::ParticipatoryProcessAdminAbility",
37
+ "Decidim::Admin::Abilities::ParticipatoryProcessCollaboratorAbility",
38
+ "Decidim::Admin::Abilities::ParticipatoryProcessModeratorAbility"
39
+ ]
39
40
  end
40
41
  end
41
42
 
@@ -57,7 +58,8 @@ module Decidim
57
58
  decidim_admin.participatory_process_groups_path,
58
59
  icon_name: "layers",
59
60
  position: 3,
60
- active: :inclusive
61
+ active: :inclusive,
62
+ if: can?(:read, Decidim::ParticipatoryProcessGroup)
61
63
 
62
64
  menu.item I18n.t("menu.static_pages", scope: "decidim.admin"),
63
65
  decidim_admin.static_pages_path,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  FactoryGirl.define do
4
- factory :participatory_process_user_role, class: Decidim::Admin::ParticipatoryProcessUserRole do
4
+ factory :participatory_process_user_role, class: Decidim::ParticipatoryProcessUserRole do
5
5
  user
6
6
  participatory_process
7
7
  role "admin"
@@ -32,7 +32,7 @@ describe Decidim::Admin::CreateParticipatoryProcessAdmin do
32
32
  context "when everything is ok" do
33
33
  it "creates the user role" do
34
34
  subject.call
35
- roles = Decidim::Admin::ParticipatoryProcessUserRole.where(user: user)
35
+ roles = Decidim::ParticipatoryProcessUserRole.where(user: user)
36
36
 
37
37
  expect(roles.count).to eq 1
38
38
  expect(roles.first.role).to eq "admin"
@@ -40,7 +40,7 @@ describe Decidim::Admin::CreateParticipatoryProcessAdmin do
40
40
 
41
41
  it "creates a new user with no application admin privileges" do
42
42
  subject.call
43
- expect(Decidim::User.last.roles).not_to include("admin")
43
+ expect(Decidim::User.last).not_to be_admin
44
44
  end
45
45
 
46
46
  context "when there is no user with the given email" do
@@ -53,7 +53,7 @@ describe Decidim::Admin::CreateParticipatoryProcessAdmin do
53
53
 
54
54
  it "creates a new user with no application admin privileges" do
55
55
  subject.call
56
- expect(Decidim::User.last.roles).not_to include("admin")
56
+ expect(Decidim::User.last).not_to be_admin
57
57
  end
58
58
  end
59
59
 
@@ -65,7 +65,7 @@ describe Decidim::Admin::CreateParticipatoryProcessAdmin do
65
65
  it "doesn't get created twice" do
66
66
  expect { subject.call }.to broadcast(:ok)
67
67
 
68
- roles = Decidim::Admin::ParticipatoryProcessUserRole.where(user: user)
68
+ roles = Decidim::ParticipatoryProcessUserRole.where(user: user)
69
69
 
70
70
  expect(roles.count).to eq 1
71
71
  expect(roles.first.role).to eq "admin"
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe Decidim::Admin::Abilities::AdminUser do
5
+ describe Decidim::Admin::Abilities::AdminAbility do
6
6
  let(:user) { build(:user, :admin) }
7
7
 
8
8
  subject { described_class.new(user, {}) }
@@ -2,11 +2,11 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe Decidim::Admin::Abilities::ParticipatoryProcessAdmin do
5
+ describe Decidim::Admin::Abilities::ParticipatoryProcessAdminAbility do
6
6
  let(:user) { build(:user) }
7
7
  let(:user_process) { create :participatory_process, organization: user.organization }
8
8
 
9
- subject { described_class.new(user, {}) }
9
+ subject { described_class.new(user, current_participatory_process: user_process) }
10
10
 
11
11
  context "when the user does not admin any process" do
12
12
  it { is_expected.not_to be_able_to(:read, :admin_dashboard) }
@@ -30,7 +30,7 @@ describe Decidim::Admin::Abilities::ParticipatoryProcessAdmin do
30
30
  let(:unmanaged_process_moderation) { create(:moderation) }
31
31
 
32
32
  before do
33
- create :participatory_process_user_role, user: user, participatory_process: user_process
33
+ create :participatory_process_user_role, user: user, participatory_process: user_process, role: :admin
34
34
  end
35
35
 
36
36
  it { is_expected.to be_able_to(:read, :admin_dashboard) }
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe Decidim::Admin::Abilities::ParticipatoryProcessCollaboratorAbility do
6
+ let(:user) { build(:user) }
7
+ let(:user_process) { create :participatory_process, organization: user.organization }
8
+ let(:unmanaged_process) { create :participatory_process, organization: user.organization }
9
+
10
+ subject { described_class.new(user, current_participatory_process: user_process) }
11
+
12
+ before do
13
+ create :participatory_process_user_role, user: user, participatory_process: user_process, role: :collaborator
14
+ end
15
+
16
+ it { is_expected.to be_able_to(:preview, user_process) }
17
+ it { is_expected.not_to be_able_to(:preview, unmanaged_process) }
18
+ end
@@ -8,7 +8,7 @@ describe Decidim::Admin::ProcessAdmins do
8
8
  let!(:admin) { create(:user, :admin, :confirmed, organization: organization) }
9
9
  let!(:participatory_process_admin) do
10
10
  user = create(:user, :confirmed, organization: organization)
11
- Decidim::Admin::ParticipatoryProcessUserRole.create!(
11
+ Decidim::ParticipatoryProcessUserRole.create!(
12
12
  role: :admin,
13
13
  user: user,
14
14
  participatory_process: participatory_process
@@ -15,7 +15,7 @@ module Decidim
15
15
  )
16
16
  end
17
17
  let(:ability) do
18
- Decidim::Admin::Abilities::AdminUser.new(build(:user, :admin), {})
18
+ Decidim::Admin::Abilities::AdminAbility.new(build(:user, :admin), {})
19
19
  end
20
20
 
21
21
  before do
@@ -12,7 +12,7 @@ ca:
12
12
  budgets:
13
13
  actions:
14
14
  attachments: Adjunts
15
- confirm_destroy: Estàs segur que vols eliminar aquest projecte?
15
+ confirm_destroy: Segur que vols eliminar aquest projecte?
16
16
  destroy: Esborrar
17
17
  edit: Editar
18
18
  new: Nou
@@ -58,7 +58,7 @@ ca:
58
58
  ok: D'acord
59
59
  title: Pressupost superat
60
60
  budget_summary:
61
- are_you_sure: Estàs segur de que vols cancel·lar el teu vot?
61
+ are_you_sure: Segur que vols cancel·lar el teu vot?
62
62
  assigned: 'Assignat:'
63
63
  cancel_order: eliminar el teu vot i començar de nou
64
64
  checked_out:
@@ -0,0 +1,19 @@
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 admin user.
7
+ # Intended to be used with `cancancan`.
8
+ class AdminAbility < Decidim::Abilities::AdminAbility
9
+ def define_abilities
10
+ super
11
+
12
+ can :manage, Comment
13
+ can :unreport, Comment
14
+ can :hide, Comment
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,22 +3,20 @@
3
3
  module Decidim
4
4
  module Comments
5
5
  module Abilities
6
- # Defines the abilities related to comments for a logged in admin user.
6
+ # Defines the abilities related to comments for a logged in user.
7
7
  # Intended to be used with `cancancan`.
8
- class AdminUser
8
+ class CurrentUserAbility
9
9
  include CanCan::Ability
10
10
 
11
11
  attr_reader :user, :context
12
12
 
13
13
  def initialize(user, context)
14
- return unless user && user.role?(:admin)
14
+ return unless user
15
15
 
16
16
  @user = user
17
17
  @context = context
18
18
 
19
- can :manage, Comment
20
- can :unreport, Comment
21
- can :hide, Comment
19
+ can :report, Decidim::Comments::Comment
22
20
  end
23
21
  end
24
22
  end
@@ -0,0 +1,19 @@
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 ParticipatoryProcessAdminAbility < Decidim::Abilities::ParticipatoryProcessAdminAbility
9
+ def define_participatory_process_abilities
10
+ super
11
+
12
+ can [:manage, :unreport, :hide], Comment do |comment|
13
+ can_manage_process?(comment.feature.participatory_process)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
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 moderator user.
7
+ # Intended to be used with `cancancan`.
8
+ class ParticipatoryProcessModeratorAbility < Decidim::Abilities::ParticipatoryProcessModeratorAbility
9
+ def define_participatory_process_abilities
10
+ super
11
+
12
+ can [:unreport, :hide], Comment do |comment|
13
+ can_manage_process?(comment.feature.participatory_process)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -10,8 +10,11 @@ module Decidim
10
10
 
11
11
  initializer "decidim_comments.inject_abilities_to_user" do |_app|
12
12
  Decidim.configure do |config|
13
- config.admin_abilities += ["Decidim::Comments::Abilities::AdminUser"]
14
- config.admin_abilities += ["Decidim::Comments::Abilities::ProcessAdminUser"]
13
+ config.admin_abilities += [
14
+ "Decidim::Comments::Abilities::AdminAbility",
15
+ "Decidim::Comments::Abilities::ParticipatoryProcessAdminAbility",
16
+ "Decidim::Comments::Abilities::ParticipatoryProcessModeratorAbility"
17
+ ]
15
18
  end
16
19
  end
17
20
 
@@ -38,6 +38,12 @@ module Decidim
38
38
  end
39
39
  end
40
40
  end
41
+
42
+ initializer "decidim_comments.inject_abilities_to_user" do |_app|
43
+ Decidim.configure do |config|
44
+ config.abilities += ["Decidim::Comments::Abilities::CurrentUserAbility"]
45
+ end
46
+ end
41
47
  end
42
48
  end
43
49
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe Decidim::Comments::Abilities::AdminUser do
5
+ describe Decidim::Comments::Abilities::AdminAbility do
6
6
  let(:user) { build(:user, :admin) }
7
7
  let(:context) { {} }
8
8
 
@@ -2,10 +2,11 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe Decidim::Comments::Abilities::ProcessAdminUser do
5
+ describe Decidim::Comments::Abilities::ParticipatoryProcessAdminAbility do
6
6
  let(:user) { build(:user) }
7
7
  let(:user_process) { create :participatory_process, organization: user.organization }
8
- let(:context) { {} }
8
+ let!(:user_role) { create :participatory_process_user_role, user: user, participatory_process: user_process, role: :admin }
9
+ let(:context) { { current_participatory_process: user_process } }
9
10
 
10
11
  subject { described_class.new(user, context) }
11
12
 
@@ -3,6 +3,7 @@
3
3
  module Decidim
4
4
  module Meetings
5
5
  class MeetingWidgetsController < Decidim::WidgetsController
6
+ helper MeetingsHelper
6
7
  helper_method :model, :current_participatory_process
7
8
 
8
9
  private
@@ -5,7 +5,7 @@ module Decidim
5
5
  # Exposes the meeting resource so users can view them
6
6
  class MeetingsController < Decidim::Meetings::ApplicationController
7
7
  include FilterResource
8
-
8
+ include Paginable
9
9
  helper Decidim::WidgetUrlsHelper
10
10
 
11
11
  helper_method :meetings, :geocoded_meetings, :meeting
@@ -29,7 +29,7 @@ module Decidim
29
29
  end
30
30
 
31
31
  def meetings
32
- @meetings ||= search.results.page(params[:page]).per(12)
32
+ @meetings ||= paginate(search.results)
33
33
  end
34
34
 
35
35
  def geocoded_meetings
@@ -1,6 +1,6 @@
1
1
  <%= content_for(:title, translated_attribute(model.title)) %>
2
2
  <%= render partial: "decidim/meetings/meetings/datetime", locals: { meeting: model } %>
3
- <%== translated_attribute model.description %>
3
+ <%== meeting_description(model) %>
4
4
  <div class="address card__extra">
5
5
  <div class="address__icon">
6
6
  <%= icon "meetings", remove_icon_class: true, width: 40, height: 70 %>
@@ -8,6 +8,8 @@
8
8
  </div>
9
9
  <% end %>
10
10
 
11
+ <%= render partial: "decidim/shared/results_per_page" %>
12
+
11
13
  <div class="row small-up-1 medium-up-2 card-grid">
12
14
  <% meetings.each do |meeting| %>
13
15
  <div class="column">
@@ -25,7 +25,7 @@ ca:
25
25
  actions:
26
26
  attachments: Adjunts
27
27
  close: Tancar
28
- confirm_destroy: Esteu segur de que voleu suprimir aquesta trobada?
28
+ confirm_destroy: Segur que vols suprimir aquesta trobada?
29
29
  destroy: Esborra
30
30
  edit: Edita
31
31
  new: Nova