decidim-participatory_processes 0.11.2 → 0.12.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/participatory_processes/process_cell.rb +19 -0
  3. data/app/cells/decidim/participatory_processes/process_group_cell.rb +19 -0
  4. data/app/cells/decidim/participatory_processes/process_group_m/footer.erb +9 -0
  5. data/app/cells/decidim/participatory_processes/process_group_m_cell.rb +46 -0
  6. data/app/cells/decidim/participatory_processes/process_m/data.erb +21 -0
  7. data/app/cells/decidim/participatory_processes/process_m/footer.erb +15 -0
  8. data/app/cells/decidim/participatory_processes/process_m/tags.erb +6 -0
  9. data/app/cells/decidim/participatory_processes/process_m_cell.rb +64 -0
  10. data/app/controllers/decidim/participatory_processes/admin/application_controller.rb +14 -0
  11. data/app/controllers/decidim/participatory_processes/admin/concerns/participatory_process_admin.rb +11 -0
  12. data/app/controllers/decidim/participatory_processes/admin/moderations_controller.rb +4 -0
  13. data/app/controllers/decidim/participatory_processes/admin/participatory_process_attachment_collections_controller.rb +0 -4
  14. data/app/controllers/decidim/participatory_processes/admin/participatory_process_attachments_controller.rb +0 -4
  15. data/app/controllers/decidim/participatory_processes/admin/participatory_process_copies_controller.rb +2 -2
  16. data/app/controllers/decidim/participatory_processes/admin/participatory_process_groups_controller.rb +8 -8
  17. data/app/controllers/decidim/participatory_processes/admin/participatory_process_publications_controller.rb +2 -2
  18. data/app/controllers/decidim/participatory_processes/admin/participatory_process_step_activations_controller.rb +1 -1
  19. data/app/controllers/decidim/participatory_processes/admin/participatory_process_step_ordering_controller.rb +1 -1
  20. data/app/controllers/decidim/participatory_processes/admin/participatory_process_steps_controller.rb +7 -7
  21. data/app/controllers/decidim/participatory_processes/admin/participatory_process_user_roles_controller.rb +7 -7
  22. data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb +8 -12
  23. data/app/controllers/decidim/participatory_processes/admin/participatory_space_private_users_controller.rb +1 -1
  24. data/app/controllers/decidim/participatory_processes/application_controller.rb +16 -0
  25. data/app/controllers/decidim/participatory_processes/participatory_process_groups_controller.rb +5 -1
  26. data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +2 -2
  27. data/app/models/decidim/participatory_process.rb +11 -0
  28. data/app/models/decidim/participatory_process_group.rb +2 -0
  29. data/app/permissions/decidim/participatory_processes/permissions.rb +261 -0
  30. data/app/types/decidim/participatory_processes/participatory_process_type.rb +2 -2
  31. data/app/views/decidim/participatory_process_groups/_participatory_process_group.html.erb +1 -22
  32. data/app/views/decidim/participatory_processes/_participatory_process.html.erb +1 -28
  33. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/edit.html.erb +1 -1
  34. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/index.html.erb +4 -4
  35. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/index.html.erb +4 -4
  36. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/show.html.erb +2 -2
  37. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/index.html.erb +4 -4
  38. data/app/views/decidim/participatory_processes/admin/participatory_processes/edit.html.erb +2 -2
  39. data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +7 -7
  40. data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +0 -1
  41. data/app/views/layouts/decidim/admin/participatory_process.html.erb +15 -12
  42. data/app/views/layouts/decidim/admin/participatory_process_groups.html.erb +1 -1
  43. data/app/views/layouts/decidim/admin/participatory_processes.html.erb +7 -10
  44. data/config/locales/ca.yml +16 -0
  45. data/config/locales/en.yml +16 -0
  46. data/config/locales/es.yml +16 -0
  47. data/config/locales/eu.yml +16 -0
  48. data/config/locales/fi.yml +16 -0
  49. data/config/locales/fr.yml +16 -0
  50. data/config/locales/gl.yml +16 -0
  51. data/config/locales/it.yml +16 -0
  52. data/config/locales/nl.yml +16 -0
  53. data/config/locales/pl.yml +22 -0
  54. data/config/locales/pt-BR.yml +16 -0
  55. data/config/locales/pt.yml +16 -0
  56. data/config/locales/ru.yml +51 -14
  57. data/config/locales/sv.yml +16 -0
  58. data/config/locales/uk.yml +24 -2
  59. data/lib/decidim/participatory_processes/admin_engine.rb +2 -10
  60. data/lib/decidim/participatory_processes/engine.rb +3 -7
  61. data/lib/decidim/participatory_processes/participatory_space.rb +13 -1
  62. data/lib/decidim/participatory_processes/version.rb +1 -1
  63. metadata +19 -13
  64. data/app/models/decidim/participatory_processes/abilities/admin/admin_ability.rb +0 -22
  65. data/app/models/decidim/participatory_processes/abilities/admin_ability.rb +0 -16
  66. data/app/models/decidim/participatory_processes/abilities/everyone_ability.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1ce976fd7c72edae64245e4bd7495431ad061ed54e7fb75b1b9402b378b6a53
4
- data.tar.gz: 0d85ae50e4ef7c9ec6bb45240c6e7d901e547124e050a45746e116139d51af44
3
+ metadata.gz: b572b360266d1f7002929a9e0e5b978f95cf9b5aa47637ffeae6401e5c8cf9fb
4
+ data.tar.gz: c2e595283bd2e4047468df2e03e5288fc62007f22cd7f2168be9651ec1b82c9e
5
5
  SHA512:
6
- metadata.gz: bef07e0277114c51ed62fd1dfa34911b5260473f5f5065566ac1c542638abe5bbf7cc716fe7a7f520accd471da9bd6652d5946e957b8e1c2257baf57397f8e27
7
- data.tar.gz: 3a35e31a269015237215750a0da616bbb1b13071d807ba9a555c78564bf957fefede0f460119077ba9635e015bea06a004cbfe8ec0380eed01e4b0adb8a832fd
6
+ metadata.gz: 68b035e70da9d95ce8ad4f08714841ba0c03a33c209b488bfcd3ee4c76a2bcce6b7f6852aa49e332f01ba42dc41cf633f64864d5bdbe609efeef1105fa2b0465
7
+ data.tar.gz: c2e1af8fb6d987a771129ff652875122fece4470f6b0554d89f9a6dd9bde72ee39b2592df4b17e4fc145ecc1cd9def1ef0d49ed3b149d6991944b7bf3881715a
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # This cell renders the process card for an instance of a Process
6
+ # the default size is the Medium Card (:m)
7
+ class ProcessCell < Decidim::ViewModel
8
+ def show
9
+ cell card_size, model
10
+ end
11
+
12
+ private
13
+
14
+ def card_size
15
+ "decidim/participatory_processes/process_m"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # This cell renders the process card for an instance of a ProcessGroup
6
+ # the default size is the Medium Card (:m)
7
+ class ProcessGroupCell < Decidim::ViewModel
8
+ def show
9
+ cell card_size, model
10
+ end
11
+
12
+ private
13
+
14
+ def card_size
15
+ "decidim/participatory_processes/process_group_m"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ <div class="card__footer card__footer--spaces">
2
+ <div class="card__support">
3
+ <%= link_to(
4
+ t("layouts.decidim.participatory_process_groups.participatory_process_group.browse"),
5
+ resource_path,
6
+ class: "card__button button button--sc secondary light small"
7
+ ) %>
8
+ </div>
9
+ </div>
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # This cell renders the Medium (:m) process group card
6
+ # for an given instance of a ProcessGroup
7
+ class ProcessGroupMCell < Decidim::CardMCell
8
+ private
9
+
10
+ def has_image?
11
+ true
12
+ end
13
+
14
+ def resource_image_path
15
+ model.hero_image.url
16
+ end
17
+
18
+ def title
19
+ translated_attribute model.name
20
+ end
21
+
22
+ def resource_path
23
+ Decidim::ParticipatoryProcesses::Engine.routes.url_helpers.participatory_process_group_path(model)
24
+ end
25
+
26
+ def step_title
27
+ translated_attribute model.active_step.title
28
+ end
29
+
30
+ def card_classes
31
+ ["card--process", "card--stack"].join(" ")
32
+ end
33
+
34
+ def statuses
35
+ super << :processes_count
36
+ end
37
+
38
+ def processes_count_status
39
+ content_tag(
40
+ :strong,
41
+ t("layouts.decidim.participatory_process_groups.participatory_process_group.processes_count")
42
+ ) + " " + model.participatory_processes.count.to_s
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,21 @@
1
+ <div class="card__icondata">
2
+ <ul class="card-data">
3
+ <li class="card-data__item">
4
+ <%= icon "datetime", class: "icon--big" %>
5
+ </li>
6
+ <li class="card-data__item">
7
+ <div class="card-data__item--centerblock">
8
+ <strong><%= t("activemodel.attributes.participatory_process.start_date") %></strong>
9
+ <br />
10
+ <%= start_date ? l(start_date, format: :decidim_short) : t("decidim.participatory_processes.show.unspecified") %>
11
+ </div>
12
+ </li>
13
+ <li class="card-data__item">
14
+ <div class="card-data__item--centerblock">
15
+ <strong><%= t("activemodel.attributes.participatory_process.end_date") %></strong>
16
+ <br />
17
+ <%= end_date ? l(end_date, format: :decidim_short) : t("decidim.participatory_processes.show.unspecified") %>
18
+ </div>
19
+ </li>
20
+ </ul>
21
+ </div>
@@ -0,0 +1,15 @@
1
+ <div class="card__footer card__footer--spaces">
2
+ <div class="card__support">
3
+ <% if has_step? %>
4
+ <div class="card__support__data--left">
5
+ <div class="text-uppercase"><%= t("layouts.decidim.participatory_processes.participatory_process.active_step") %></div>
6
+ <div class="text-ellipsis"><strong><%= step_title %></strong></div>
7
+ </div>
8
+ <% end %>
9
+ <%= link_to(
10
+ t("layouts.decidim.participatory_processes.participatory_process.take_part"),
11
+ resource_path,
12
+ class: "card__button button button--sc secondary light small"
13
+ ) %>
14
+ </div>
15
+ </div>
@@ -0,0 +1,6 @@
1
+ <%= link_to(
2
+ "##{model.hashtag}",
3
+ "https://twitter.com/hashtag/#{model.hashtag}",
4
+ class: "card__text--category",
5
+ target: "_blank"
6
+ ) %>
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # This cell renders the Medium (:m) process card
6
+ # for an given instance of a Process
7
+ class ProcessMCell < Decidim::CardMCell
8
+ private
9
+
10
+ def has_image?
11
+ true
12
+ end
13
+
14
+ def has_state?
15
+ model.past?
16
+ end
17
+
18
+ def has_badge?
19
+ false
20
+ end
21
+
22
+ def has_step?
23
+ model.active_step.present?
24
+ end
25
+
26
+ def state_classes
27
+ return unless model.past?
28
+ ["alert"]
29
+ end
30
+
31
+ def resource_path
32
+ Decidim::ParticipatoryProcesses::Engine.routes.url_helpers.participatory_process_path(model)
33
+ end
34
+
35
+ def resource_image_path
36
+ model.hero_image.url
37
+ end
38
+
39
+ def step_title
40
+ translated_attribute model.active_step.title
41
+ end
42
+
43
+ def base_card_class
44
+ "card--process"
45
+ end
46
+
47
+ def statuses
48
+ [:creation_date, :follow]
49
+ end
50
+
51
+ def resource_icon
52
+ icon "processes", class: "icon--big"
53
+ end
54
+
55
+ def start_date
56
+ model.start_date
57
+ end
58
+
59
+ def end_date
60
+ model.end_date
61
+ end
62
+ end
63
+ end
64
+ end
@@ -5,6 +5,20 @@ module Decidim
5
5
  module Admin
6
6
  # The main admin application controller for participatory processes
7
7
  class ApplicationController < Decidim::Admin::ApplicationController
8
+ private
9
+
10
+ def permissions_context
11
+ super.merge(
12
+ current_participatory_space: try(:current_participatory_space)
13
+ )
14
+ end
15
+
16
+ def permission_class_chain
17
+ [
18
+ Decidim::ParticipatoryProcesses::Permissions,
19
+ Decidim::Admin::Permissions
20
+ ]
21
+ end
8
22
  end
9
23
  end
10
24
  end
@@ -26,7 +26,18 @@ module Decidim
26
26
  organization_processes.find_by!(slug: params[:participatory_process_slug] || params[:slug])
27
27
  end
28
28
 
29
+ def permissions_context
30
+ super.merge(current_participatory_space: current_participatory_space)
31
+ end
32
+
29
33
  alias_method :current_participatory_process, :current_participatory_space
34
+
35
+ def permission_class_chain
36
+ [
37
+ Decidim::ParticipatoryProcesses::Permissions,
38
+ Decidim::Admin::Permissions
39
+ ]
40
+ end
30
41
  end
31
42
  end
32
43
  end
@@ -6,6 +6,10 @@ module Decidim
6
6
  # This controller allows admins to manage moderations in a participatory process.
7
7
  class ModerationsController < Decidim::Admin::ModerationsController
8
8
  include Concerns::ParticipatoryProcessAdmin
9
+
10
+ def permissions_context
11
+ super.merge(current_participatory_space: current_participatory_space)
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -17,10 +17,6 @@ module Decidim
17
17
  def collection_for
18
18
  current_participatory_process
19
19
  end
20
-
21
- def authorization_object
22
- @attachment_collection || AttachmentCollection
23
- end
24
20
  end
25
21
  end
26
22
  end
@@ -17,10 +17,6 @@ module Decidim
17
17
  def attached_to
18
18
  current_participatory_process
19
19
  end
20
-
21
- def authorization_object
22
- @attachment || Attachment
23
- end
24
20
  end
25
21
  end
26
22
  end
@@ -9,12 +9,12 @@ module Decidim
9
9
  include Concerns::ParticipatoryProcessAdmin
10
10
 
11
11
  def new
12
- authorize! :new, Decidim::ParticipatoryProcess
12
+ enforce_permission_to :create, :process
13
13
  @form = form(ParticipatoryProcessCopyForm).from_model(current_participatory_process)
14
14
  end
15
15
 
16
16
  def create
17
- authorize! :create, Decidim::ParticipatoryProcess
17
+ enforce_permission_to :create, :process
18
18
  @form = form(ParticipatoryProcessCopyForm).from_params(params)
19
19
 
20
20
  CopyParticipatoryProcess.call(@form, current_participatory_process) do
@@ -5,26 +5,26 @@ module Decidim
5
5
  module Admin
6
6
  # Controller that allows managing participatory process groups.
7
7
  #
8
- class ParticipatoryProcessGroupsController < Decidim::Admin::ApplicationController
8
+ class ParticipatoryProcessGroupsController < Decidim::ParticipatoryProcesses::Admin::ApplicationController
9
9
  helper ProcessesForSelectHelper
10
10
 
11
11
  helper_method :collection, :participatory_process_group
12
12
 
13
13
  def index
14
- authorize! :read, ParticipatoryProcessGroup
14
+ enforce_permission_to :read, :process_group
15
15
  end
16
16
 
17
17
  def show
18
- authorize! :read, participatory_process_group
18
+ enforce_permission_to :read, :process_group, process_group: participatory_process_group
19
19
  end
20
20
 
21
21
  def new
22
- authorize! :new, Decidim::ParticipatoryProcessGroup
22
+ enforce_permission_to :create, :process_group
23
23
  @form = form(ParticipatoryProcessGroupForm).instance
24
24
  end
25
25
 
26
26
  def create
27
- authorize! :new, Decidim::ParticipatoryProcessGroup
27
+ enforce_permission_to :create, :process_group
28
28
  @form = form(ParticipatoryProcessGroupForm).from_params(params)
29
29
 
30
30
  CreateParticipatoryProcessGroup.call(@form) do
@@ -42,13 +42,13 @@ module Decidim
42
42
 
43
43
  def edit
44
44
  @participatory_process_group = collection.find(params[:id])
45
- authorize! :update, @participatory_process_group
45
+ enforce_permission_to :update, :process_group, process_group: @participatory_process_group
46
46
  @form = form(ParticipatoryProcessGroupForm).from_model(@participatory_process_group)
47
47
  end
48
48
 
49
49
  def update
50
50
  @participatory_process_group = collection.find(params[:id])
51
- authorize! :update, @participatory_process_group
51
+ enforce_permission_to :update, :process_group, process_group: @participatory_process_group
52
52
  @form = form(ParticipatoryProcessGroupForm).from_params(params)
53
53
 
54
54
  UpdateParticipatoryProcessGroup.call(@participatory_process_group, @form) do
@@ -66,7 +66,7 @@ module Decidim
66
66
 
67
67
  def destroy
68
68
  @participatory_process_group = collection.find(params[:id])
69
- authorize! :destroy, @participatory_process_group
69
+ enforce_permission_to :destroy, :process_group, process_group: @participatory_process_group
70
70
  @participatory_process_group.destroy!
71
71
 
72
72
  flash[:notice] = I18n.t("participatory_process_groups.destroy.success", scope: "decidim.admin")
@@ -9,7 +9,7 @@ module Decidim
9
9
  include Concerns::ParticipatoryProcessAdmin
10
10
 
11
11
  def create
12
- authorize! :publish, current_participatory_process
12
+ enforce_permission_to :publish, :process, process: current_participatory_process
13
13
 
14
14
  PublishParticipatoryProcess.call(current_participatory_process, current_user) do
15
15
  on(:ok) do
@@ -25,7 +25,7 @@ module Decidim
25
25
  end
26
26
 
27
27
  def destroy
28
- authorize! :publish, current_participatory_process
28
+ enforce_permission_to :publish, :process, process: current_participatory_process
29
29
 
30
30
  UnpublishParticipatoryProcess.call(current_participatory_process, current_user) do
31
31
  on(:ok) do
@@ -9,7 +9,7 @@ module Decidim
9
9
  include Concerns::ParticipatoryProcessAdmin
10
10
 
11
11
  def create
12
- authorize! :activate, process_step
12
+ enforce_permission_to :activate, :process_step, process_step: process_step
13
13
 
14
14
  ActivateParticipatoryProcessStep.call(process_step, current_user) do
15
15
  on(:ok) do
@@ -9,7 +9,7 @@ module Decidim
9
9
  include Concerns::ParticipatoryProcessAdmin
10
10
 
11
11
  def create
12
- authorize! :reorder, Decidim::ParticipatoryProcessStep
12
+ enforce_permission_to :reorder, :process_step
13
13
  ReorderParticipatoryProcessSteps.call(collection, params[:items_ids]) do
14
14
  on(:invalid) do
15
15
  flash.now[:alert] = I18n.t("participatory_process_steps.ordering.error", scope: "decidim.admin")
@@ -9,16 +9,16 @@ module Decidim
9
9
  include Concerns::ParticipatoryProcessAdmin
10
10
 
11
11
  def index
12
- authorize! :read, Decidim::ParticipatoryProcessStep
12
+ enforce_permission_to :read, :process_step
13
13
  end
14
14
 
15
15
  def new
16
- authorize! :create, Decidim::ParticipatoryProcessStep
16
+ enforce_permission_to :create, :process_step
17
17
  @form = form(ParticipatoryProcessStepForm).instance
18
18
  end
19
19
 
20
20
  def create
21
- authorize! :create, Decidim::ParticipatoryProcessStep
21
+ enforce_permission_to :create, :process_step
22
22
  @form = form(ParticipatoryProcessStepForm).from_params(params)
23
23
 
24
24
  CreateParticipatoryProcessStep.call(@form, current_participatory_process) do
@@ -36,13 +36,13 @@ module Decidim
36
36
 
37
37
  def edit
38
38
  @participatory_process_step = collection.find(params[:id])
39
- authorize! :update, @participatory_process_step
39
+ enforce_permission_to :update, :process_step, process_step: @participatory_process_step
40
40
  @form = form(ParticipatoryProcessStepForm).from_model(@participatory_process_step)
41
41
  end
42
42
 
43
43
  def update
44
44
  @participatory_process_step = collection.find(params[:id])
45
- authorize! :update, @participatory_process_step
45
+ enforce_permission_to :update, :process_step, process_step: @participatory_process_step
46
46
  @form = form(ParticipatoryProcessStepForm).from_params(params)
47
47
 
48
48
  UpdateParticipatoryProcessStep.call(@participatory_process_step, @form) do
@@ -60,12 +60,12 @@ module Decidim
60
60
 
61
61
  def show
62
62
  @participatory_process_step = collection.find(params[:id])
63
- authorize! :read, @participatory_process_step
63
+ enforce_permission_to :read, :process_step, process_step: @participatory_process_step
64
64
  end
65
65
 
66
66
  def destroy
67
67
  @participatory_process_step = collection.find(params[:id])
68
- authorize! :destroy, @participatory_process_step
68
+ enforce_permission_to :destroy, :process_step, process_step: @participatory_process_step
69
69
 
70
70
  DestroyParticipatoryProcessStep.call(@participatory_process_step, current_user) do
71
71
  on(:ok) do