decidim-participatory_processes 0.28.5 → 0.29.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/participatory_process_groups/content_blocks/extra_data_cell.rb +4 -4
  3. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb +0 -2
  4. data/app/cells/decidim/participatory_processes/content_blocks/stats_cell.rb +1 -1
  5. data/app/cells/decidim/participatory_processes/process_filters/filter_tabs.erb +2 -2
  6. data/app/cells/decidim/participatory_processes/process_filters/show.erb +1 -1
  7. data/app/cells/decidim/participatory_processes/process_filters/type_filter.erb +1 -1
  8. data/app/cells/decidim/participatory_processes/process_filters_cell.rb +1 -2
  9. data/app/cells/decidim/participatory_processes/process_g_cell.rb +2 -2
  10. data/app/cells/decidim/participatory_processes/process_group_g_cell.rb +2 -2
  11. data/app/cells/decidim/participatory_processes/process_group_s_cell.rb +5 -1
  12. data/app/commands/decidim/participatory_processes/admin/copy_participatory_process.rb +5 -7
  13. data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +27 -99
  14. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_group.rb +10 -53
  15. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_step.rb +9 -36
  16. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_type.rb +4 -34
  17. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_step.rb +6 -37
  18. data/app/commands/decidim/participatory_processes/admin/import_participatory_process.rb +5 -4
  19. data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +10 -80
  20. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_group.rb +6 -55
  21. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb +8 -52
  22. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb +2 -38
  23. data/app/controllers/decidim/participatory_processes/admin/participatory_process_copies_controller.rb +1 -1
  24. data/app/controllers/decidim/participatory_processes/admin/participatory_process_groups_controller.rb +2 -2
  25. data/app/controllers/decidim/participatory_processes/admin/participatory_process_steps_controller.rb +2 -2
  26. data/app/controllers/decidim/participatory_processes/admin/participatory_process_types_controller.rb +2 -2
  27. data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb +1 -1
  28. data/app/controllers/decidim/participatory_processes/admin/participatory_space_private_users_controller.rb +1 -1
  29. data/app/controllers/decidim/participatory_processes/application_controller.rb +3 -0
  30. data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +1 -6
  31. data/app/events/decidim/participatory_process_role_assigned_event.rb +0 -5
  32. data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +3 -8
  33. data/app/helpers/decidim/participatory_processes/participatory_process_helper.rb +1 -1
  34. data/app/models/decidim/participatory_process.rb +1 -4
  35. data/app/models/decidim/participatory_process_step.rb +1 -1
  36. data/app/permissions/decidim/participatory_processes/permissions.rb +1 -1
  37. data/app/presenters/decidim/participatory_processes/participatory_process_group_presenter.rb +1 -1
  38. data/app/presenters/decidim/participatory_processes/participatory_process_presenter.rb +1 -5
  39. data/app/queries/decidim/participatory_processes/stats_participants_count.rb +4 -4
  40. data/app/serializers/decidim/participatory_processes/participatory_process_importer.rb +2 -5
  41. data/app/serializers/decidim/participatory_processes/participatory_process_serializer.rb +0 -3
  42. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/index.html.erb +1 -1
  43. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/show.html.erb +1 -1
  44. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/index.html.erb +1 -1
  45. data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +5 -17
  46. data/app/views/decidim/participatory_processes/participatory_processes/all_metrics.html.erb +4 -1
  47. data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +24 -20
  48. data/config/locales/ar.yml +3 -15
  49. data/config/locales/bg.yml +3 -4
  50. data/config/locales/ca.yml +5 -8
  51. data/config/locales/cs.yml +6 -14
  52. data/config/locales/de.yml +4 -7
  53. data/config/locales/el.yml +3 -5
  54. data/config/locales/en.yml +2 -5
  55. data/config/locales/es-MX.yml +3 -6
  56. data/config/locales/es-PY.yml +3 -6
  57. data/config/locales/es.yml +3 -6
  58. data/config/locales/eu.yml +51 -54
  59. data/config/locales/fi-plain.yml +3 -6
  60. data/config/locales/fi.yml +15 -18
  61. data/config/locales/fr-CA.yml +4 -7
  62. data/config/locales/fr.yml +4 -7
  63. data/config/locales/ga-IE.yml +0 -10
  64. data/config/locales/gl.yml +3 -16
  65. data/config/locales/hu.yml +3 -5
  66. data/config/locales/id-ID.yml +3 -13
  67. data/config/locales/is-IS.yml +1 -13
  68. data/config/locales/it.yml +3 -16
  69. data/config/locales/ja.yml +2 -5
  70. data/config/locales/lb.yml +3 -15
  71. data/config/locales/lt.yml +2 -4
  72. data/config/locales/lv.yml +3 -14
  73. data/config/locales/nl.yml +2 -15
  74. data/config/locales/no.yml +4 -6
  75. data/config/locales/pl.yml +3 -4
  76. data/config/locales/pt-BR.yml +3 -13
  77. data/config/locales/pt.yml +2 -21
  78. data/config/locales/ro-RO.yml +1 -10
  79. data/config/locales/ru.yml +1 -13
  80. data/config/locales/sk.yml +3 -14
  81. data/config/locales/sr-CS.yml +0 -1
  82. data/config/locales/sv.yml +147 -233
  83. data/config/locales/tr-TR.yml +3 -16
  84. data/config/locales/uk.yml +1 -13
  85. data/config/locales/zh-CN.yml +3 -14
  86. data/config/locales/zh-TW.yml +2 -4
  87. data/db/migrate/20240529161054_add_link_to_decidim_attachments.rb +7 -0
  88. data/decidim-participatory_processes.gemspec +2 -2
  89. data/lib/decidim/api/participatory_process_group_type.rb +1 -1
  90. data/lib/decidim/api/participatory_process_type.rb +1 -8
  91. data/lib/decidim/participatory_processes/content_blocks/registry_manager.rb +1 -1
  92. data/lib/decidim/participatory_processes/engine.rb +1 -0
  93. data/lib/decidim/participatory_processes/menu.rb +11 -0
  94. data/lib/decidim/participatory_processes/query_extensions.rb +0 -26
  95. data/lib/decidim/participatory_processes/seeds.rb +4 -12
  96. data/lib/decidim/participatory_processes/test/factories.rb +0 -3
  97. data/lib/decidim/participatory_processes/version.rb +1 -1
  98. data/lib/tasks/decidim_participatory_processes.rake +1 -1
  99. metadata +16 -22
  100. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb +0 -46
  101. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_type.rb +0 -49
  102. data/app/views/decidim/participatory_processes/participatory_processes/_statistics.html.erb +0 -0
  103. data/app/views/layouts/decidim/_process_header.html.erb +0 -17
  104. data/app/views/layouts/decidim/participatory_process.html.erb +0 -18
  105. data/config/locales/bn-BD.yml +0 -1
  106. data/config/locales/bs-BA.yml +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b42cf5043d1b4a4e9072c9483d66251779f552e1fdb42f8914446424bae2a92
4
- data.tar.gz: 714fd5cd6a26912588fbb8f9fed18556e5dccef70b8e03f489ec82e4ca34ebf1
3
+ metadata.gz: 74bcc53cf9af5f7366e74848c81f143d4c4266b1e737522e37bd476bfa028042
4
+ data.tar.gz: 41a8c994bb8744f33d0d3a4254a76608110821bbfa779707322a6dda50762675
5
5
  SHA512:
6
- metadata.gz: 6436203da9589a2580f042c8f7f033d538f56f1c1f60effcf93e045bc673e8626f289cd348b7d7dabdb2a22b580ba56f0d44f4b89fbbaf21a34565beb559651d
7
- data.tar.gz: dbb698b01738c0fdacac9b5ccde1e84c536d44507a9d9103e3626b773946b268ec5d83fa0a7b01004e76a9570b81f41f262c2d76644c824831f6f1b22dd0e743
6
+ metadata.gz: 0f02ba9e66f51df057c2efda5b4f4f681575309e96277f09deb245a14662a3c3ac8f4779482fa8fdd9f41b665e175bbb5fd33a7c3fb91dfd3bd1c45bd883421d
7
+ data.tar.gz: 51f96ec28f58654492cc654b825d1e48e7263ea3b0a8aa261d534ea966c74165243ca4db3e4e0d772f74e781b12ab51fa4a493f863f583e2a0151b1a36807c0b
@@ -15,7 +15,7 @@ module Decidim
15
15
  end
16
16
 
17
17
  def developer_group_item
18
- return if (text = decidim_sanitize translated_attribute(developer_group)).blank?
18
+ return if (text = decidim_sanitize_translated(developer_group)).blank?
19
19
 
20
20
  {
21
21
  title: t("decidim.participatory_process_groups.content_blocks.extra_data.developer_group"),
@@ -25,7 +25,7 @@ module Decidim
25
25
  end
26
26
 
27
27
  def target_item
28
- return if (text = decidim_sanitize translated_attribute(target)).blank?
28
+ return if (text = decidim_sanitize_translated(target)).blank?
29
29
 
30
30
  {
31
31
  title: t("decidim.participatory_process_groups.content_blocks.extra_data.target"),
@@ -35,7 +35,7 @@ module Decidim
35
35
  end
36
36
 
37
37
  def participatory_scope_item
38
- return if (text = decidim_sanitize translated_attribute(participatory_scope)).blank?
38
+ return if (text = decidim_sanitize_translated(participatory_scope)).blank?
39
39
 
40
40
  {
41
41
  title: t("decidim.participatory_process_groups.content_blocks.extra_data.participatory_scope"),
@@ -45,7 +45,7 @@ module Decidim
45
45
  end
46
46
 
47
47
  def participatory_structure_item
48
- return if (text = decidim_sanitize translated_attribute(participatory_structure)).blank?
48
+ return if (text = decidim_sanitize_translated(participatory_structure)).blank?
49
49
 
50
50
  {
51
51
  title: t("decidim.participatory_process_groups.content_blocks.extra_data.participatory_structure"),
@@ -4,8 +4,6 @@ module Decidim
4
4
  module ParticipatoryProcesses
5
5
  module ContentBlocks
6
6
  class HighlightedProcessesCell < Decidim::ContentBlocks::HighlightedParticipatorySpacesCell
7
- delegate :current_user, to: :controller
8
-
9
7
  def highlighted_spaces
10
8
  @highlighted_spaces ||= promoted_groups + highlighted_processes
11
9
  end
@@ -9,7 +9,7 @@ module Decidim
9
9
  private
10
10
 
11
11
  def stats
12
- @stats ||= resource.show_statistics && ParticipatoryProcessStatsPresenter.new(participatory_process: resource).collection
12
+ @stats ||= ParticipatoryProcessStatsPresenter.new(participatory_process: resource).collection
13
13
  end
14
14
  end
15
15
  end
@@ -1,7 +1,7 @@
1
- <span class="order-by__tabs ml-s">
1
+ <span>
2
2
  <% if should_show_tabs? %>
3
3
  <%= explanation %>
4
- <span class="muted mr-xs"><%= t("decidim.participatory_processes.participatory_processes.filters.see") %></span>
4
+ <span><%= t("decidim.participatory_processes.participatory_processes.filters.see") %></span>
5
5
  <% other_filters_with_value.each do |filter| %>
6
6
  <%= link_to filter_link(filter), remote: true, class: "order-by__tab" do %>
7
7
  <strong>
@@ -6,7 +6,7 @@
6
6
  </h3>
7
7
  <%= render :type_filter if participatory_process_types_for_select.present? %>
8
8
  </div>
9
- <hr class="mt-s mb-s">
9
+ <hr>
10
10
  </div>
11
11
  <% if process_count_by_filter["active"] == 0 && process_count_by_filter["upcoming"] == 0 %>
12
12
  <div class="row column">
@@ -1,4 +1,4 @@
1
- <div id="process-type-filter" class="inline-filters">
1
+ <div id="process-type-filter">
2
2
  <div id="inline-filter-sort" class="dropdown-pane" data-position="bottom" data-alignment="right" data-dropdown data-auto-focus="true">
3
3
  <ul>
4
4
  <% participatory_process_types_for_select.each do |title, id| %>
@@ -99,8 +99,7 @@ module Decidim
99
99
 
100
100
  content_tag(
101
101
  :span,
102
- I18n.t(explanation_text, scope: "decidim.participatory_processes.participatory_processes.filters.explanations"),
103
- class: "muted mr-s ml-s"
102
+ I18n.t(explanation_text, scope: "decidim.participatory_processes.participatory_processes.filters.explanations")
104
103
  )
105
104
  end
106
105
 
@@ -11,8 +11,8 @@ module Decidim
11
11
  Decidim::ParticipatoryProcesses::Engine.routes.url_helpers.participatory_process_path(model)
12
12
  end
13
13
 
14
- def resource_image_url
15
- model.attached_uploader(:hero_image).url
14
+ def resource_image_path
15
+ model.attached_uploader(:hero_image).path
16
16
  end
17
17
 
18
18
  def start_date
@@ -11,8 +11,8 @@ module Decidim
11
11
  Decidim::ParticipatoryProcesses::Engine.routes.url_helpers.participatory_process_group_path(model)
12
12
  end
13
13
 
14
- def resource_image_url
15
- model.attached_uploader(:hero_image).url
14
+ def resource_image_path
15
+ model.attached_uploader(:hero_image).path
16
16
  end
17
17
 
18
18
  def metadata_cell
@@ -7,8 +7,12 @@ module Decidim
7
7
  class ProcessGroupSCell < Decidim::CardSCell
8
8
  private
9
9
 
10
+ def resource_path
11
+ Decidim::ParticipatoryProcesses::Engine.routes.url_helpers.participatory_process_group_path(model)
12
+ end
13
+
10
14
  def metadata_cell
11
- "decidim/participatory_processes/process_metadata"
15
+ "decidim/participatory_processes/process_group_metadata"
12
16
  end
13
17
  end
14
18
  end
@@ -6,14 +6,14 @@ module Decidim
6
6
  # A command with all the business logic when copying a new participatory
7
7
  # process in the system.
8
8
  class CopyParticipatoryProcess < Decidim::Command
9
+ delegate :current_user, to: :form
9
10
  # Public: Initializes the command.
10
11
  #
11
12
  # form - A form object with the params.
12
13
  # participatory_process - A participatory_process we want to duplicate
13
- def initialize(form, participatory_process, current_user)
14
+ def initialize(form, participatory_process)
14
15
  @form = form
15
16
  @participatory_process = participatory_process
16
- @current_user = current_user
17
17
  end
18
18
 
19
19
  # Executes the command. Broadcasts these events:
@@ -25,7 +25,7 @@ module Decidim
25
25
  def call
26
26
  return broadcast(:invalid) if form.invalid?
27
27
 
28
- Decidim.traceability.perform_action!("duplicate", @participatory_process, @current_user) do
28
+ Decidim.traceability.perform_action!("duplicate", @participatory_process, current_user) do
29
29
  ParticipatoryProcess.transaction do
30
30
  copy_participatory_process
31
31
  copy_participatory_process_attachments
@@ -68,11 +68,9 @@ module Decidim
68
68
  end
69
69
 
70
70
  def copy_participatory_process_attachments
71
- [:hero_image, :banner_image].each do |attribute|
72
- next unless @participatory_process.attached_uploader(attribute).attached?
71
+ return unless @participatory_process.attached_uploader(:hero_image).attached?
73
72
 
74
- @copied_process.send(attribute).attach(@participatory_process.send(attribute).blob)
75
- end
73
+ @copied_process.send(:hero_image).attach(@participatory_process.send(:hero_image).blob)
76
74
  end
77
75
 
78
76
  def copy_participatory_process_steps
@@ -5,118 +5,46 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new participatory
7
7
  # process in the system.
8
- class CreateParticipatoryProcess < Decidim::Command
9
- # Public: Initializes the command.
10
- #
11
- # form - A form object with the params.
12
- def initialize(form)
13
- @form = form
14
- end
15
-
16
- # Executes the command. Broadcasts these events:
17
- #
18
- # - :ok when everything is valid.
19
- # - :invalid if the form was not valid and we could not proceed.
20
- #
21
- # Returns nothing.
22
- def call
23
- return broadcast(:invalid) if form.invalid?
24
-
25
- create_participatory_process
26
-
27
- if process.persisted?
28
- add_admins_as_followers(process)
29
- link_related_processes
30
- Decidim::ContentBlocksCreator.new(process).create_default!
31
-
32
- broadcast(:ok, process)
33
- else
34
- form.errors.add(:hero_image, process.errors[:hero_image]) if process.errors.include? :hero_image
35
- form.errors.add(:banner_image, process.errors[:banner_image]) if process.errors.include? :banner_image
36
- broadcast(:invalid)
37
- end
38
- end
8
+ class CreateParticipatoryProcess < Decidim::Commands::CreateResource
9
+ fetch_file_attributes :hero_image
39
10
 
40
- private
11
+ fetch_form_attributes :organization, :title, :subtitle, :weight, :slug, :hashtag, :description,
12
+ :short_description, :promoted, :scopes_enabled, :scope, :announcement,
13
+ :scope_type_max_depth, :private_space, :developer_group, :local_area, :area, :target,
14
+ :participatory_scope, :participatory_structure, :meta_scope, :start_date, :end_date,
15
+ :participatory_process_group, :participatory_process_type
41
16
 
42
- attr_reader :form, :process
17
+ protected
43
18
 
44
- def create_participatory_process
45
- @process = ParticipatoryProcess.new
46
- @process.assign_attributes(attributes)
47
-
48
- return process unless process.valid?
49
-
50
- transaction do
51
- process.save!
52
-
53
- log_process_creation(process)
54
-
55
- process.steps.create!(
56
- title: TranslationsHelper.multi_translation(
57
- "decidim.admin.participatory_process_steps.default_title",
58
- form.current_organization.available_locales
59
- ),
60
- active: true
61
- )
62
-
63
- process
64
- end
19
+ def run_after_hooks
20
+ create_steps
21
+ add_admins_as_followers
22
+ link_related_processes
23
+ Decidim::ContentBlocksCreator.new(resource).create_default!
65
24
  end
66
25
 
67
- def attributes
68
- {
69
- organization: form.current_organization,
70
- title: form.title,
71
- subtitle: form.subtitle,
72
- weight: form.weight,
73
- slug: form.slug,
74
- hashtag: form.hashtag,
75
- description: form.description,
76
- short_description: form.short_description,
77
- hero_image: form.hero_image,
78
- banner_image: form.banner_image,
79
- promoted: form.promoted,
80
- scopes_enabled: form.scopes_enabled,
81
- scope: form.scope,
82
- scope_type_max_depth: form.scope_type_max_depth,
83
- private_space: form.private_space,
84
- developer_group: form.developer_group,
85
- local_area: form.local_area,
86
- area: form.area,
87
- target: form.target,
88
- participatory_scope: form.participatory_scope,
89
- participatory_structure: form.participatory_structure,
90
- meta_scope: form.meta_scope,
91
- start_date: form.start_date,
92
- end_date: form.end_date,
93
- participatory_process_group: form.participatory_process_group,
94
- participatory_process_type: form.participatory_process_type,
95
- show_metrics: form.show_metrics,
96
- show_statistics: form.show_statistics,
97
- announcement: form.announcement
98
- }
99
- end
26
+ def resource_class = Decidim::ParticipatoryProcess
100
27
 
101
- def log_process_creation(process)
102
- Decidim::ActionLogger.log(
103
- "create",
104
- form.current_user,
105
- process,
106
- process.versions.last.id
28
+ def create_steps
29
+ resource.steps.create!(
30
+ title: TranslationsHelper.multi_translation(
31
+ "decidim.admin.participatory_process_steps.default_title",
32
+ form.current_organization.available_locales
33
+ ),
34
+ active: true
107
35
  )
108
36
  end
109
37
 
110
- def add_admins_as_followers(process)
111
- process.organization.admins.each do |admin|
38
+ def add_admins_as_followers
39
+ resource.organization.admins.each do |admin|
112
40
  form = Decidim::FollowForm
113
- .from_params(followable_gid: process.to_signed_global_id.to_s)
41
+ .from_params(followable_gid: resource.to_signed_global_id.to_s)
114
42
  .with_context(
115
- current_organization: process.organization,
43
+ current_organization: resource.organization,
116
44
  current_user: admin
117
45
  )
118
46
 
119
- Decidim::CreateFollow.new(form, admin).call
47
+ Decidim::CreateFollow.new(form).call
120
48
  end
121
49
  end
122
50
 
@@ -125,7 +53,7 @@ module Decidim
125
53
  end
126
54
 
127
55
  def link_related_processes
128
- process.link_participatory_space_resources(related_processes, "related_processes")
56
+ resource.link_participatory_space_resources(related_processes, "related_processes")
129
57
  end
130
58
  end
131
59
  end
@@ -5,65 +5,22 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new participatory
7
7
  # process group in the system.
8
- class CreateParticipatoryProcessGroup < Decidim::Command
9
- # Public: Initializes the command.
10
- #
11
- # form - A form object with the params.
12
- def initialize(form)
13
- @form = form
14
- end
15
-
16
- # Executes the command. Broadcasts these events:
17
- #
18
- # - :ok when everything is valid.
19
- # - :invalid if the form was not valid and we could not proceed.
20
- #
21
- # Returns nothing.
22
- def call
23
- return broadcast(:invalid) if form.invalid?
8
+ class CreateParticipatoryProcessGroup < Decidim::Commands::CreateResource
9
+ fetch_file_attributes :hero_image
24
10
 
25
- group = create_participatory_process_group
11
+ fetch_form_attributes :organization, :title, :description, :hashtag, :group_url, :target, :promoted,
12
+ :developer_group, :local_area, :meta_scope, :participatory_scope, :participatory_structure
26
13
 
27
- if group.persisted?
28
- Decidim::ContentBlocksCreator.new(group).create_default!
14
+ protected
29
15
 
30
- broadcast(:ok, group)
31
- else
32
- form.errors.add(:hero_image, group.errors[:hero_image]) if group.errors.include? :hero_image
33
- form.errors.add(:banner_image, group.errors[:banner_image]) if group.errors.include? :banner_image
34
- broadcast(:invalid)
35
- end
16
+ def run_after_hooks
17
+ Decidim::ContentBlocksCreator.new(resource).create_default!
36
18
  end
37
19
 
38
- private
39
-
40
- attr_reader :form
20
+ def resource_class = Decidim::ParticipatoryProcessGroup
41
21
 
42
- def create_participatory_process_group
43
- transaction do
44
- Decidim.traceability.perform_action!(
45
- "create",
46
- ParticipatoryProcessGroup,
47
- form.current_user
48
- ) do
49
- ParticipatoryProcessGroup.create(
50
- organization: form.current_organization,
51
- title: form.title,
52
- description: form.description,
53
- hashtag: form.hashtag,
54
- group_url: form.group_url,
55
- hero_image: form.hero_image, # Keep after organization
56
- participatory_processes:,
57
- developer_group: form.developer_group,
58
- local_area: form.local_area,
59
- meta_scope: form.meta_scope,
60
- participatory_scope: form.participatory_scope,
61
- participatory_structure: form.participatory_structure,
62
- target: form.target,
63
- promoted: form.promoted
64
- )
65
- end
66
- end
22
+ def attributes
23
+ super.merge({ participatory_processes: })
67
24
  end
68
25
 
69
26
  def participatory_processes
@@ -4,47 +4,20 @@ module Decidim
4
4
  module ParticipatoryProcesses
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new participatory
7
- # process in the system.
8
- class CreateParticipatoryProcessStep < Decidim::Command
9
- # Public: Initializes the command.
10
- #
11
- # form - A form object with the params.
12
- # participatory_process - The ParticipatoryProcess that will hold the
13
- # step
14
- def initialize(form, participatory_process)
15
- @form = form
16
- @participatory_process = participatory_process
17
- end
18
-
19
- # Executes the command. Broadcasts these events:
20
- #
21
- # - :ok when everything is valid.
22
- # - :invalid if the form was not valid and we could not proceed.
23
- #
24
- # Returns nothing.
25
- def call
26
- return broadcast(:invalid) if form.invalid?
7
+ # process step in the system.
8
+ class CreateParticipatoryProcessStep < Decidim::Commands::CreateResource
9
+ fetch_form_attributes :title, :description, :start_date, :end_date
27
10
 
28
- create_participatory_process_step
29
- broadcast(:ok)
11
+ def attributes
12
+ super.merge({
13
+ participatory_process: form.current_participatory_space,
14
+ active: form.current_participatory_space.steps.empty?
15
+ })
30
16
  end
31
17
 
32
18
  private
33
19
 
34
- attr_reader :form
35
-
36
- def create_participatory_process_step
37
- Decidim.traceability.create!(
38
- ParticipatoryProcessStep,
39
- @form.current_user,
40
- title: form.title,
41
- description: form.description,
42
- start_date: form.start_date,
43
- end_date: form.end_date,
44
- participatory_process: @participatory_process,
45
- active: @participatory_process.steps.empty?
46
- )
47
- end
20
+ def resource_class = Decidim::ParticipatoryProcessStep
48
21
  end
49
22
  end
50
23
  end
@@ -5,42 +5,12 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new participatory
7
7
  # process type in the system.
8
- class CreateParticipatoryProcessType < Decidim::Command
9
- # Public: Initializes the command.
10
- #
11
- # form - A form object with the params.
12
- def initialize(form)
13
- @form = form
14
- end
8
+ class CreateParticipatoryProcessType < Decidim::Commands::CreateResource
9
+ fetch_form_attributes :title, :organization
15
10
 
16
- # Executes the command. Broadcasts these events:
17
- #
18
- # - :ok when everything is valid.
19
- # - :invalid if the form was not valid and we could not proceed.
20
- #
21
- # Returns nothing.
22
- def call
23
- return broadcast(:invalid) if form.invalid?
11
+ protected
24
12
 
25
- create_participatory_process_type!
26
-
27
- broadcast(:ok)
28
- end
29
-
30
- private
31
-
32
- attr_reader :form
33
-
34
- def create_participatory_process_type!
35
- transaction do
36
- Decidim.traceability.create!(
37
- Decidim::ParticipatoryProcessType,
38
- form.current_user,
39
- organization: form.current_organization,
40
- title: form.title
41
- )
42
- end
43
- end
13
+ def resource_class = Decidim::ParticipatoryProcessType
44
14
  end
45
15
  end
46
16
  end
@@ -3,48 +3,17 @@
3
3
  module Decidim
4
4
  module ParticipatoryProcesses
5
5
  module Admin
6
- # A command that sets all steps in a participatory process as inactive
7
- class DestroyParticipatoryProcessStep < Decidim::Command
8
- # Public: Initializes the command.
9
- #
10
- # step - A ParticipatoryProcessStep that will be deactivated
11
- # current_user - the user performing the action
12
- def initialize(step, current_user)
13
- @step = step
14
- @participatory_process = step.participatory_process
15
- @current_user = current_user
16
- end
17
-
18
- # Executes the command. Broadcasts these events:
19
- #
20
- # - :ok when everything is valid.
21
- # - :invalid if the data was not valid and we could not proceed.
22
- #
23
- # Returns nothing.
24
- def call
25
- return broadcast(:invalid, :active_step) if active_step?
26
-
27
- transaction do
28
- Decidim.traceability.perform_action!(:delete, step, current_user) do
29
- step.destroy!
30
- step
31
- end
32
-
33
- reorder_steps
34
- end
35
-
36
- broadcast(:ok)
37
- end
38
-
6
+ # A command that deletes a participatory process step
7
+ class DestroyParticipatoryProcessStep < Decidim::Commands::DestroyResource
39
8
  private
40
9
 
41
- attr_reader :step, :participatory_process, :current_user
10
+ def participatory_process = resource.participatory_space
42
11
 
43
- def active_step?
44
- participatory_process.steps.count > 1 && step.active?
12
+ def invalid?
13
+ participatory_process.steps.count > 1 && resource.active?
45
14
  end
46
15
 
47
- def reorder_steps
16
+ def run_after_hooks
48
17
  steps = participatory_process.steps.reload
49
18
 
50
19
  ReorderParticipatoryProcessSteps
@@ -6,6 +6,7 @@ module Decidim
6
6
  # A command with all the business logic when copying a new participatory
7
7
  # process in the system.
8
8
  class ImportParticipatoryProcess < Decidim::Command
9
+ delegate :current_user, to: :form
9
10
  # Public: Initializes the command.
10
11
  #
11
12
  # form - A form object with the params.
@@ -36,10 +37,10 @@ module Decidim
36
37
  attr_reader :form
37
38
 
38
39
  def import_participatory_process
39
- importer = Decidim::ParticipatoryProcesses::ParticipatoryProcessImporter.new(form.current_organization, form.current_user)
40
+ importer = Decidim::ParticipatoryProcesses::ParticipatoryProcessImporter.new(form.current_organization, current_user)
40
41
  participatory_processes.each do |original_process|
41
- Decidim.traceability.perform_action!("import", Decidim::ParticipatoryProcess, form.current_user) do
42
- @imported_process = importer.import(original_process, form.current_user, title: form.title, slug: form.slug)
42
+ Decidim.traceability.perform_action!("import", Decidim::ParticipatoryProcess, current_user) do
43
+ @imported_process = importer.import(original_process, current_user, title: form.title, slug: form.slug)
43
44
  importer.import_participatory_process_steps(original_process["participatory_process_steps"]) if form.import_steps?
44
45
  importer.import_categories(original_process["participatory_process_categories"]) if form.import_categories?
45
46
  importer.import_folders_and_attachments(original_process["attachments"]) if form.import_attachments?
@@ -66,7 +67,7 @@ module Decidim
66
67
  current_user: admin
67
68
  )
68
69
 
69
- Decidim::CreateFollow.new(form, admin).call
70
+ Decidim::CreateFollow.new(form).call
70
71
  end
71
72
  end
72
73
  end