decidim-admin 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-admin might be problematic. Click here for more details.

Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/decidim/admin/_variables.scss +2 -0
  3. data/app/assets/stylesheets/decidim/admin/extra/_cards.scss +6 -0
  4. data/app/assets/stylesheets/decidim/admin/modules/_typography.scss +4 -0
  5. data/app/commands/decidim/admin/create_participatory_process_admin.rb +3 -5
  6. data/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
  7. data/app/controllers/decidim/admin/application_controller.rb +1 -1
  8. data/app/controllers/decidim/admin/categories_controller.rb +9 -9
  9. data/app/controllers/decidim/admin/concerns/participatory_process_admin.rb +1 -8
  10. data/app/controllers/decidim/admin/exports_controller.rb +2 -2
  11. data/app/controllers/decidim/admin/feature_permissions_controller.rb +2 -2
  12. data/app/controllers/decidim/admin/features/base_controller.rb +0 -5
  13. data/app/controllers/decidim/admin/features_controller.rb +4 -4
  14. data/app/controllers/decidim/admin/moderations_controller.rb +1 -1
  15. data/app/controllers/decidim/admin/participatory_process_attachments_controller.rb +2 -2
  16. data/app/controllers/decidim/admin/participatory_process_copies_controller.rb +3 -9
  17. data/app/controllers/decidim/admin/participatory_process_publications_controller.rb +4 -4
  18. data/app/controllers/decidim/admin/participatory_process_step_activations_controller.rb +2 -2
  19. data/app/controllers/decidim/admin/participatory_process_step_ordering_controller.rb +2 -2
  20. data/app/controllers/decidim/admin/participatory_process_steps_controller.rb +6 -6
  21. data/app/controllers/decidim/admin/participatory_process_user_roles_controller.rb +13 -15
  22. data/app/controllers/decidim/admin/participatory_processes_controller.rb +16 -18
  23. data/app/controllers/decidim/admin/users_controller.rb +4 -4
  24. data/app/forms/decidim/admin/participatory_process_user_role_form.rb +2 -2
  25. data/app/models/decidim/admin/abilities/{admin_user.rb → admin_ability.rb} +3 -6
  26. data/app/models/decidim/admin/abilities/{base.rb → base_ability.rb} +1 -4
  27. data/app/models/decidim/admin/abilities/{participatory_process_admin.rb → participatory_process_admin_ability.rb} +18 -28
  28. data/app/models/decidim/admin/abilities/participatory_process_collaborator_ability.rb +19 -0
  29. data/app/models/decidim/admin/abilities/participatory_process_moderator_ability.rb +23 -0
  30. data/app/queries/decidim/admin/process_admins.rb +1 -1
  31. data/app/views/decidim/admin/categories/index.html.erb +9 -9
  32. data/app/views/decidim/admin/categories/new.html.erb +1 -1
  33. data/app/views/decidim/admin/features/_form.html.erb +1 -1
  34. data/app/views/decidim/admin/features/edit.html.erb +1 -1
  35. data/app/views/decidim/admin/features/new.html.erb +1 -1
  36. data/app/views/decidim/admin/participatory_process_copies/new.html.erb +1 -1
  37. data/app/views/decidim/admin/participatory_process_groups/index.html.erb +5 -1
  38. data/app/views/decidim/admin/participatory_process_steps/index.html.erb +9 -9
  39. data/app/views/decidim/admin/participatory_process_user_roles/index.html.erb +6 -6
  40. data/app/views/decidim/admin/participatory_processes/edit.html.erb +6 -6
  41. data/app/views/decidim/admin/participatory_processes/index.html.erb +11 -1
  42. data/app/views/layouts/decidim/admin/participatory_process.html.erb +18 -18
  43. data/config/locales/ca.yml +4 -3
  44. data/config/locales/en.yml +1 -0
  45. data/config/locales/es.yml +1 -2
  46. data/db/migrate/20170714083651_rename_participatory_process_user_roles_table.rb +7 -0
  47. data/lib/decidim/admin/engine.rb +8 -6
  48. data/lib/decidim/admin/test/factories.rb +1 -1
  49. metadata +12 -14
  50. data/app/models/decidim/admin/abilities/collaborator_user.rb +0 -20
  51. data/app/models/decidim/admin/participatory_process_user_role.rb +0 -15
  52. data/app/queries/decidim/admin/manageable_participatory_processes_for_user.rb +0 -42
  53. data/app/queries/decidim/admin/process_admin_roles_for_process.rb +0 -36
  54. data/db/seeds.rb +0 -24
@@ -2,8 +2,8 @@
2
2
  <div class="card-divider">
3
3
  <h2 class="card-title">
4
4
  <%= t(".process_admins_title", scope: "decidim.admin") %>
5
- <% if can? :create, Decidim::Admin::ParticipatoryProcessUserRole %>
6
- <%= link_to t("actions.new", scope: "decidim.admin", name: t("models.participatory_process_user_role.name", scope: "decidim.admin")), new_participatory_process_user_role_path(participatory_process), class: 'button tiny button--title new' %>
5
+ <% if can? :create, Decidim::ParticipatoryProcessUserRole %>
6
+ <%= link_to t("actions.new", scope: "decidim.admin", name: t("models.participatory_process_user_role.name", scope: "decidim.admin")), new_participatory_process_user_role_path(current_participatory_process), class: 'button tiny button--title new' %>
7
7
  <% end %>
8
8
  </h2>
9
9
  </div>
@@ -22,7 +22,7 @@
22
22
  </tr>
23
23
  </thead>
24
24
  <tbody>
25
- <% process_admin_roles.each do |role| %>
25
+ <% @participatory_process_user_roles.each do |role| %>
26
26
  <tr>
27
27
  <td>
28
28
  <%= role.user.name %><br />
@@ -45,15 +45,15 @@
45
45
  </td>
46
46
  <td class="table-list__actions">
47
47
  <% if can?(:invite, role) && role.user.invited_to_sign_up? %>
48
- <%= icon_link_to "reload", resend_invitation_participatory_process_user_role_path(participatory_process, role), t("actions.resend_invitation", scope: "decidim.admin"), class: "resend-invitation", method: :post %>
48
+ <%= icon_link_to "reload", resend_invitation_participatory_process_user_role_path(current_participatory_process, role), t("actions.resend_invitation", scope: "decidim.admin"), class: "resend-invitation", method: :post %>
49
49
  <% end %>
50
50
 
51
51
  <% if can? :update, role %>
52
- <%= icon_link_to "pencil", edit_participatory_process_user_role_path(participatory_process, role), t("actions.edit", scope: "decidim.admin"), class: "action-icon--edit" %>
52
+ <%= icon_link_to "pencil", edit_participatory_process_user_role_path(current_participatory_process, role), t("actions.edit", scope: "decidim.admin"), class: "action-icon--edit" %>
53
53
  <% end %>
54
54
 
55
55
  <% if can? :destroy, role %>
56
- <%= icon_link_to "circle-x", participatory_process_user_role_path(participatory_process, role), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } %>
56
+ <%= icon_link_to "circle-x", participatory_process_user_role_path(current_participatory_process, role), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } %>
57
57
  <% end %>
58
58
  </td>
59
59
  </tr>
@@ -3,16 +3,16 @@
3
3
  <div class="button--double form-general-submit">
4
4
  <%= f.submit t(".update"), class: "button" %>
5
5
 
6
- <% if can? :publish, participatory_process %>
7
- <% if participatory_process.published? %>
8
- <%= link_to t("actions.unpublish", scope: "decidim.admin"), participatory_process_publish_path(participatory_process), method: :delete, class: "button muted" %>
6
+ <% if can? :publish, current_participatory_process %>
7
+ <% if current_participatory_process.published? %>
8
+ <%= link_to t("actions.unpublish", scope: "decidim.admin"), participatory_process_publish_path(current_participatory_process), method: :delete, class: "button muted" %>
9
9
  <% else %>
10
- <%= link_to t("actions.publish", scope: "decidim.admin"), participatory_process_publish_path(participatory_process), method: :post, class: "button hollow" %>
10
+ <%= link_to t("actions.publish", scope: "decidim.admin"), participatory_process_publish_path(current_participatory_process), method: :post, class: "button hollow" %>
11
11
  <% end %>
12
12
  <% end %>
13
13
 
14
- <% if can? :destroy, participatory_process %>
15
- <%= link_to t("decidim.admin.actions.destroy"), participatory_process, method: :delete, class: "alert button", data: { confirm: t("decidim.admin.actions.confirm_destroy") } %>
14
+ <% if can? :destroy, current_participatory_process %>
15
+ <%= link_to t("decidim.admin.actions.destroy"), current_participatory_process, method: :delete, class: "alert button", data: { confirm: t("decidim.admin.actions.confirm_destroy") } %>
16
16
  <% end %>
17
17
  </div>
18
18
  <% end %>
@@ -24,7 +24,15 @@
24
24
  <%= icon "star" %>
25
25
  </span>
26
26
  <% end %>
27
- <%= link_to translated_attribute(process.title), edit_participatory_process_path(process) %><br />
27
+ <% if can? :update, process %>
28
+ <%= link_to translated_attribute(process.title), edit_participatory_process_path(process) %><br />
29
+ <% elsif can? :preview, process %>
30
+ <%= link_to translated_attribute(process.title), decidim.participatory_process_path(process) %><br />
31
+ <% elsif can? :read, Decidim::Moderation %>
32
+ <%= link_to translated_attribute(process.title), decidim_admin.participatory_process_moderations_path(process) %><br />
33
+ <% else %>
34
+ <%= translated_attribute(process.title) %>
35
+ <% end %>
28
36
  </td>
29
37
  <td>
30
38
  <%= l process.created_at, format: :short %>
@@ -37,7 +45,9 @@
37
45
  <% end %>
38
46
  </td>
39
47
  <td class="table-list__actions">
48
+ <% if can? :create, process %>
40
49
  <%= icon_link_to "clipboard", new_participatory_process_copy_path(process), t("actions.duplicate", scope: "decidim.admin"), class: "action-icon--copy" %>
50
+ <% end %>
41
51
 
42
52
  <% if can? :update, process %>
43
53
  <%= icon_link_to "pencil", edit_participatory_process_path(process), t("actions.configure", scope: "decidim.admin"), class: "action-icon--new" %>
@@ -1,21 +1,21 @@
1
1
  <% content_for :secondary_nav do %>
2
2
  <div class="secondary-nav secondary-nav--subnav">
3
3
  <ul>
4
- <% if can? :update, participatory_process %>
5
- <li <% if is_active_link?(decidim_admin.edit_participatory_process_path(participatory_process)) %> class="is-active" <% end %>>
6
- <%= aria_selected_link_to t("info", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.edit_participatory_process_path(participatory_process) %>
4
+ <% if can? :update, current_participatory_process %>
5
+ <li <% if is_active_link?(decidim_admin.edit_participatory_process_path(current_participatory_process)) %> class="is-active" <% end %>>
6
+ <%= aria_selected_link_to t("info", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.edit_participatory_process_path(current_participatory_process) %>
7
7
  </li>
8
8
  <% end %>
9
9
  <% if can? :read, Decidim::ParticipatoryProcessStep %>
10
- <li <% if is_active_link?(decidim_admin.participatory_process_steps_path(participatory_process)) %> class="is-active" <% end %>>
11
- <%= aria_selected_link_to t("steps", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_steps_path(participatory_process) %>
10
+ <li <% if is_active_link?(decidim_admin.participatory_process_steps_path(current_participatory_process)) %> class="is-active" <% end %>>
11
+ <%= aria_selected_link_to t("steps", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_steps_path(current_participatory_process) %>
12
12
  </li>
13
13
  <% end %>
14
14
  <% if can? :read, Decidim::Feature %>
15
- <li <% if is_active_link?(decidim_admin.participatory_process_features_path(participatory_process)) %> class="is-active" <% end %>>
16
- <%= aria_selected_link_to t("features", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_features_path(participatory_process) %>
15
+ <li <% if is_active_link?(decidim_admin.participatory_process_features_path(current_participatory_process)) %> class="is-active" <% end %>>
16
+ <%= aria_selected_link_to t("features", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_features_path(current_participatory_process) %>
17
17
  <ul>
18
- <% participatory_process.features.each do |feature| %>
18
+ <% current_participatory_process.features.each do |feature| %>
19
19
  <% if feature.manifest.admin_engine %>
20
20
  <li <% if is_active_link?(manage_feature_path(feature)) %> class="is-active" <% end %>>
21
21
  <%= link_to manage_feature_path(feature) do %>
@@ -31,23 +31,23 @@
31
31
  </li>
32
32
  <% end %>
33
33
  <% if can? :read, Decidim::Category %>
34
- <li <% if is_active_link?(decidim_admin.participatory_process_categories_path(participatory_process)) %> class="is-active" <% end %>>
35
- <%= aria_selected_link_to t("categories", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_categories_path(participatory_process) %>
34
+ <li <% if is_active_link?(decidim_admin.participatory_process_categories_path(current_participatory_process)) %> class="is-active" <% end %>>
35
+ <%= aria_selected_link_to t("categories", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_categories_path(current_participatory_process) %>
36
36
  </li>
37
37
  <% end %>
38
38
  <% if can? :read, Decidim::Attachment %>
39
- <li <% if is_active_link?(decidim_admin.participatory_process_attachments_path(participatory_process.id)) %> class="is-active" <% end %>>
40
- <%= aria_selected_link_to t("attachments", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_attachments_path(participatory_process.id) %>
39
+ <li <% if is_active_link?(decidim_admin.participatory_process_attachments_path(current_participatory_process.id)) %> class="is-active" <% end %>>
40
+ <%= aria_selected_link_to t("attachments", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_attachments_path(current_participatory_process.id) %>
41
41
  </li>
42
42
  <% end %>
43
- <% if can? :read, Decidim::Admin::ParticipatoryProcessUserRole %>
44
- <li <% if is_active_link?(decidim_admin.participatory_process_user_roles_path(participatory_process)) %> class="is-active" <% end %>>
45
- <%= aria_selected_link_to t("process_admins", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_user_roles_path(participatory_process) %>
43
+ <% if can? :read, Decidim::ParticipatoryProcessUserRole %>
44
+ <li <% if is_active_link?(decidim_admin.participatory_process_user_roles_path(current_participatory_process)) %> class="is-active" <% end %>>
45
+ <%= aria_selected_link_to t("process_admins", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_user_roles_path(current_participatory_process) %>
46
46
  </li>
47
47
  <% end %>
48
48
  <% if can? :read, Decidim::Moderation %>
49
- <li <% if is_active_link?(decidim_admin.participatory_process_moderations_path(participatory_process.id)) %> class="is-active" <% end %>>
50
- <%= aria_selected_link_to t("moderations", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_moderations_path(participatory_process.id) %>
49
+ <li <% if is_active_link?(decidim_admin.participatory_process_moderations_path(current_participatory_process.id)) %> class="is-active" <% end %>>
50
+ <%= aria_selected_link_to t("moderations", scope: "decidim.admin.menu.participatory_processes_submenu"), decidim_admin.participatory_process_moderations_path(current_participatory_process.id) %>
51
51
  </li>
52
52
  <% end %>
53
53
  </ul>
@@ -57,7 +57,7 @@
57
57
  <%= render "layouts/decidim/admin/application" do %>
58
58
  <div class="process-title">
59
59
  <div class="process-title-content">
60
- <%= translated_attribute(participatory_process.title) %>
60
+ <%= translated_attribute(current_participatory_process.title) %>
61
61
  </div>
62
62
  </div>
63
63
  <%= yield %>
@@ -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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-07-12 00:00:00.000000000 Z
13
+ date: 2017-08-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-core
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.4.0
21
+ version: 0.4.1
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.4.0
28
+ version: 0.4.1
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rails
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -158,14 +158,14 @@ dependencies:
158
158
  requirements:
159
159
  - - '='
160
160
  - !ruby/object:Gem::Version
161
- version: 0.4.0
161
+ version: 0.4.1
162
162
  type: :development
163
163
  prerelease: false
164
164
  version_requirements: !ruby/object:Gem::Requirement
165
165
  requirements:
166
166
  - - '='
167
167
  - !ruby/object:Gem::Version
168
- version: 0.4.0
168
+ version: 0.4.1
169
169
  description: Organization administration to manage a single organization.
170
170
  email:
171
171
  - josepjaume@gmail.com
@@ -333,14 +333,12 @@ files:
333
333
  - app/jobs/decidim/admin/newsletter_delivery_job.rb
334
334
  - app/jobs/decidim/admin/newsletter_job.rb
335
335
  - app/mailers/decidim/admin/application_mailer.rb
336
- - app/models/decidim/admin/abilities/admin_user.rb
337
- - app/models/decidim/admin/abilities/base.rb
338
- - app/models/decidim/admin/abilities/collaborator_user.rb
339
- - app/models/decidim/admin/abilities/participatory_process_admin.rb
336
+ - app/models/decidim/admin/abilities/admin_ability.rb
337
+ - app/models/decidim/admin/abilities/base_ability.rb
338
+ - app/models/decidim/admin/abilities/participatory_process_admin_ability.rb
339
+ - app/models/decidim/admin/abilities/participatory_process_collaborator_ability.rb
340
+ - app/models/decidim/admin/abilities/participatory_process_moderator_ability.rb
340
341
  - app/models/decidim/admin/application_record.rb
341
- - app/models/decidim/admin/participatory_process_user_role.rb
342
- - app/queries/decidim/admin/manageable_participatory_processes_for_user.rb
343
- - app/queries/decidim/admin/process_admin_roles_for_process.rb
344
342
  - app/queries/decidim/admin/process_admins.rb
345
343
  - app/queries/decidim/admin/user_groups_evaluation.rb
346
344
  - app/views/decidim/admin/attachments/_form.html.erb
@@ -434,7 +432,7 @@ files:
434
432
  - config/routes.rb
435
433
  - db/migrate/20161102144648_add_admin_participatory_process_user_roles.rb
436
434
  - db/migrate/20170128112958_change_user_groups_verified_to_timestamp.rb
437
- - db/seeds.rb
435
+ - db/migrate/20170714083651_rename_participatory_process_user_roles_table.rb
438
436
  - lib/decidim/admin.rb
439
437
  - lib/decidim/admin/engine.rb
440
438
  - lib/decidim/admin/features.rb
@@ -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