decidim-participatory_processes 0.19.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/participatory_processes/admin/participatory_processes.js.es6 +6 -0
  3. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/_all_processes.erb +4 -1
  4. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/show.erb +5 -9
  5. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/single_process.erb +10 -5
  6. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb +1 -1
  7. data/app/cells/decidim/participatory_processes/process_filters/show.erb +2 -2
  8. data/app/cells/decidim/participatory_processes/process_group_m/footer.erb +4 -5
  9. data/app/cells/decidim/participatory_processes/process_m/data.erb +1 -1
  10. data/app/cells/decidim/participatory_processes/process_m/footer.erb +5 -6
  11. data/app/cells/decidim/participatory_processes/process_m/tags.erb +2 -2
  12. data/app/cells/decidim/participatory_processes/process_m_cell.rb +2 -0
  13. data/app/cells/decidim/participatory_processes/statistic/show.erb +9 -0
  14. data/app/cells/decidim/participatory_processes/statistic_cell.rb +20 -0
  15. data/app/cells/decidim/participatory_processes/statistics/show.erb +17 -0
  16. data/app/cells/decidim/participatory_processes/statistics_cell.rb +18 -0
  17. data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +10 -11
  18. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb +2 -1
  19. data/app/commands/decidim/participatory_processes/admin/import_participatory_process.rb +72 -0
  20. data/app/commands/decidim/participatory_processes/admin/notify_role_assigned_to_participatory_process.rb +22 -0
  21. data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +16 -5
  22. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_admin.rb +3 -1
  23. data/app/controllers/concerns/decidim/participatory_processes/admin/filterable.rb +27 -0
  24. data/app/controllers/decidim/participatory_processes/admin/participatory_process_exports_controller.rb +20 -0
  25. data/app/controllers/decidim/participatory_processes/admin/participatory_process_imports_controller.rb +31 -0
  26. data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb +6 -16
  27. data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +27 -4
  28. data/app/events/decidim/participatory_process_role_assigned_event.rb +28 -0
  29. data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +13 -0
  30. data/app/forms/decidim/participatory_processes/admin/participatory_process_import_form.rb +80 -0
  31. data/app/functions/decidim/participatory_processes/participatory_process_finder.rb +10 -0
  32. data/app/functions/decidim/participatory_processes/participatory_process_list.rb +11 -0
  33. data/app/helpers/decidim/participatory_processes/admin/participatory_process_helper.rb +23 -0
  34. data/app/models/decidim/participatory_process.rb +25 -1
  35. data/app/models/decidim/participatory_process_user_role.rb +32 -0
  36. data/app/permissions/decidim/participatory_processes/permissions.rb +15 -2
  37. data/app/presenters/decidim/participatory_processes/participatory_process_group_presenter.rb +22 -0
  38. data/app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb +2 -2
  39. data/app/presenters/decidim/participatory_processes/participatory_process_presenter.rb +25 -0
  40. data/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb +32 -22
  41. data/app/queries/decidim/participatory_processes/stats_followers_count.rb +46 -0
  42. data/app/queries/decidim/participatory_processes/stats_participants_count.rb +98 -0
  43. data/app/serializers/decidim/participatory_processes/participatory_process_importer.rb +180 -0
  44. data/app/serializers/decidim/participatory_processes/participatory_process_serializer.rb +154 -0
  45. data/app/services/decidim/participatory_processes/participatory_process_search.rb +2 -1
  46. data/app/types/decidim/participatory_processes/participatory_process_group_type.rb +20 -0
  47. data/app/types/decidim/participatory_processes/participatory_process_input_filter.rb +13 -0
  48. data/app/types/decidim/participatory_processes/participatory_process_input_sort.rb +15 -0
  49. data/app/types/decidim/participatory_processes/participatory_process_step_type.rb +7 -4
  50. data/app/types/decidim/participatory_processes/participatory_process_type.rb +8 -4
  51. data/app/views/decidim/participatory_process_steps/_participatory_process_step.html.erb +1 -1
  52. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/index.html.erb +8 -0
  53. data/app/views/decidim/participatory_processes/admin/participatory_process_imports/_form.html.erb +49 -0
  54. data/app/views/decidim/participatory_processes/admin/participatory_process_imports/new.html.erb +7 -0
  55. data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +31 -0
  56. data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +27 -12
  57. data/app/views/decidim/participatory_processes/admin/shared/_secondary_nav.html.erb +17 -0
  58. data/app/views/decidim/participatory_processes/participatory_process_groups/show.html.erb +3 -2
  59. data/app/views/decidim/participatory_processes/participatory_process_steps/index.html.erb +8 -3
  60. data/app/views/decidim/participatory_processes/participatory_processes/_metrics.html.erb +2 -2
  61. data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process.html.erb +7 -5
  62. data/app/views/decidim/participatory_processes/participatory_processes/_statistics.html.erb +0 -10
  63. data/app/views/decidim/participatory_processes/participatory_processes/{statistics.html.erb → all_metrics.html.erb} +0 -0
  64. data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +38 -12
  65. data/app/views/layouts/decidim/_process_header.html.erb +1 -1
  66. data/app/views/layouts/decidim/_process_header_steps.html.erb +1 -1
  67. data/app/views/layouts/decidim/_process_navigation.html.erb +1 -1
  68. data/app/views/layouts/decidim/admin/participatory_process.html.erb +2 -2
  69. data/app/views/layouts/decidim/admin/participatory_process_groups.html.erb +0 -11
  70. data/config/locales/ar.yml +18 -5
  71. data/config/locales/bg-BG.yml +19 -0
  72. data/config/locales/ca.yml +63 -16
  73. data/config/locales/cs.yml +60 -13
  74. data/config/locales/da-DK.yml +1 -0
  75. data/config/locales/de.yml +55 -4
  76. data/config/locales/el-GR.yml +1 -0
  77. data/config/locales/el.yml +453 -0
  78. data/config/locales/en.yml +53 -6
  79. data/config/locales/es-MX.yml +51 -4
  80. data/config/locales/es-PY.yml +51 -4
  81. data/config/locales/es.yml +52 -5
  82. data/config/locales/et-EE.yml +1 -0
  83. data/config/locales/eu.yml +6 -4
  84. data/config/locales/fi-plain.yml +51 -4
  85. data/config/locales/fi.yml +122 -75
  86. data/config/locales/fr-CA.yml +453 -0
  87. data/config/locales/fr.yml +51 -4
  88. data/config/locales/ga-IE.yml +1 -0
  89. data/config/locales/gl.yml +6 -4
  90. data/config/locales/hr-HR.yml +1 -0
  91. data/config/locales/hu.yml +37 -8
  92. data/config/locales/id-ID.yml +6 -4
  93. data/config/locales/is-IS.yml +215 -0
  94. data/config/locales/it.yml +57 -6
  95. data/config/locales/ja-JP.yml +445 -0
  96. data/config/locales/lt-LT.yml +1 -0
  97. data/config/locales/lv-LV.yml +445 -0
  98. data/config/locales/mt-MT.yml +1 -0
  99. data/config/locales/nl.yml +66 -19
  100. data/config/locales/no.yml +438 -0
  101. data/config/locales/pl.yml +60 -9
  102. data/config/locales/pt-BR.yml +7 -5
  103. data/config/locales/pt.yml +175 -124
  104. data/config/locales/ro-RO.yml +461 -0
  105. data/config/locales/ru.yml +5 -3
  106. data/config/locales/sk-SK.yml +451 -0
  107. data/config/locales/sk.yml +451 -0
  108. data/config/locales/sl.yml +5 -0
  109. data/config/locales/sr-CS.yml +33 -0
  110. data/config/locales/sv.yml +160 -109
  111. data/config/locales/tr-TR.yml +6 -4
  112. data/config/locales/uk.yml +5 -3
  113. data/db/migrate/20200114142253_add_scope_type_to_participatory_processes.rb +7 -0
  114. data/db/migrate/20200204154917_add_show_metrics_to_participatory_processes.rb +7 -0
  115. data/db/migrate/20200320105908_index_foreign_keys_in_decidim_attachments.rb +7 -0
  116. data/db/migrate/20200320105924_index_foreign_keys_in_decidim_participatory_process_user_roles.rb +7 -0
  117. data/db/migrate/20200320105925_index_foreign_keys_in_decidim_participatory_processes.rb +8 -0
  118. data/db/seeds/city.jpeg +0 -0
  119. data/db/seeds/city2.jpeg +0 -0
  120. data/lib/decidim/participatory_processes/admin_engine.rb +9 -9
  121. data/lib/decidim/participatory_processes/engine.rb +21 -4
  122. data/lib/decidim/participatory_processes/participatory_space.rb +21 -1
  123. data/lib/decidim/participatory_processes/query_extensions.rb +40 -0
  124. data/lib/decidim/participatory_processes/test/factories.rb +20 -0
  125. data/lib/decidim/participatory_processes/version.rb +1 -1
  126. metadata +61 -11
  127. data/app/views/decidim/participatory_processes/participatory_process_widgets/show.html.erb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 646d727853472148cfd6d07d0c14be42a98cdd19483580e5527c59db120ff39c
4
- data.tar.gz: e0176468c3e47893f3bc0a94e018a137ec4effbba1a60053f4404c415000f9e0
3
+ metadata.gz: 4c87d3748ed5ddda107431eccbde08c257a669a9b0b6b87010cfc6dd1f6f5450
4
+ data.tar.gz: 5a984b08e37fb702a0f8cc425189782e7acc298fe0f933d02b68c2f171ec9106
5
5
  SHA512:
6
- metadata.gz: 34eb3115b0c3dbd79aa59b1999b0d3bc7f7fb32e4f68bcd7e396a022b414bbb22ddbff4b56fef690e8bb092917965da1ae0acdfd728cc8392a56710f0548389c
7
- data.tar.gz: b72946fb10ba7591c464f9818493f8181e412bd3ef4411a05732023b1f0247bec60357ebd03bb693f9c8d00bb9ee257be6ed5c5b820ebdb4812a5013b0737ca5
6
+ metadata.gz: 04cb2351dd62f27e32155fe620953c7524216925686bef5be09d6fe30bfdebcdc12d45a79e577f414438c06cee0bc0a7f8396976386058bc2f40a21e5e21baa5
7
+ data.tar.gz: 30dbc6a09f4f3f5c5f417b0a1c9be50c4bca044b415aea17364dd9623bd86f4c188635528e87f74a9d4ed97a0cb8a0f8142eed1706415f3264118d9237585eb7
@@ -2,11 +2,17 @@ $(() => {
2
2
  ((exports) => {
3
3
  const $participatoryProcessScopeEnabled = $("#participatory_process_scopes_enabled");
4
4
  const $participatoryProcessScopeId = $("#participatory_process_scope_id");
5
+ const $participatoryProcessScopeTypeId = $("#participatory_process_scope_type_max_depth_id");
5
6
 
6
7
  if ($(".edit_participatory_process, .new_participatory_process").length > 0) {
7
8
  $participatoryProcessScopeEnabled.on("change", (event) => {
8
9
  const checked = event.target.checked;
9
10
  exports.theDataPicker.enabled($participatoryProcessScopeId, checked);
11
+ if (checked === true) {
12
+ $participatoryProcessScopeTypeId.removeAttr("disabled");
13
+ } else {
14
+ $participatoryProcessScopeTypeId.attr("disabled", true)
15
+ }
10
16
  })
11
17
  exports.theDataPicker.enabled($participatoryProcessScopeId, $participatoryProcessScopeEnabled.prop("checked"));
12
18
  }
@@ -1,6 +1,9 @@
1
1
  <div class="row" id="see-all-processes">
2
2
  <div class="columns small-centered small-12
3
3
  smallmedium-8 medium-6 large-4">
4
- <%= link_to t("see_all_processes", scope: i18n_scope), decidim_participatory_processes.participatory_processes_path, class: "button expanded hollow button--sc home-section__cta" %>
4
+ <%= link_to t("see_all_processes", scope: i18n_scope),
5
+ decidim_participatory_processes.participatory_processes_path,
6
+ class: "button expanded hollow button--sc home-section__cta",
7
+ title: t("processes_button_title", scope: i18n_scope) %>
5
8
  </div>
6
9
  </div>
@@ -6,15 +6,11 @@
6
6
  large-up-4 card-grid">
7
7
  <% highlighted_processes.each do |process| %>
8
8
  <div class="column">
9
- <article class="card card--process card--mini">
10
- <%= link_to decidim_participatory_processes.participatory_process_path(process), class: "card__link" do %>
11
- <div class="card__image-top"
12
- style="background-image:url(<%= process.hero_image.url %>)"></div>
13
- <% end %>
9
+ <%= link_to decidim_participatory_processes.participatory_process_path(process), class: "card card--process card--mini" do %>
10
+ <div aria-hidden="true" class="card__image-top"
11
+ style="background-image:url(<%= process.hero_image.url %>)"></div>
14
12
  <div class="card__content">
15
- <%= link_to decidim_participatory_processes.participatory_process_path(process), class: "card__link" do %>
16
- <h4 class="card__title"><%= translated_attribute process.title %></h4>
17
- <% end %>
13
+ <span class="card__title card__link"><%= translated_attribute process.title %></span>
18
14
  <% if process.active_step %>
19
15
  <span class="card--process__small">
20
16
  <%= t("active_step", scope: i18n_scope) %>
@@ -22,7 +18,7 @@
22
18
  </span>
23
19
  <% end %>
24
20
  </div>
25
- </article>
21
+ <% end %>
26
22
  </div>
27
23
  <% end %>
28
24
  </div>
@@ -1,17 +1,21 @@
1
1
  <% process = highlighted_processes.first %>
2
+ <% title_id = "process_title" %>
2
3
  <section class="wrapper-home home-section">
3
4
  <div class="row" id="highlighted-processes">
4
5
  <h3 class="section-heading"><%= t("active_processes", scope: i18n_scope) %></h3>
5
6
  <div class="row collapse">
6
- <article class="card card--full card--process">
7
+ <div class="card card--full card--process">
7
8
  <div class="row collapse card--process__row">
8
9
  <div class="column large-6 card--process__column">
9
10
  <div class="card__content">
10
11
  <%= link_to decidim_participatory_processes.participatory_process_path(process), class: "card__link" do %>
11
- <h2 class="card__title"><%= translated_attribute process.title %></h2>
12
+ <h2 class="card__title" id="<%= title_id %>"><%= decidim_html_escape(translated_attribute(process.title)) %></h2>
12
13
  <% end %>
13
14
  <%= decidim_sanitize translated_attribute(process.short_description) %>
14
- <%= link_to t("more_information", scope: i18n_scope), decidim_participatory_processes.participatory_process_path(process), class: "button secondary small hollow" %>
15
+ <%= link_to decidim_participatory_processes.participatory_process_path(process), class: "button small hollow" do %>
16
+ <span class="show-for-sr"><%= decidim_html_escape(translated_attribute(process.title)) %></span>
17
+ <%= t("more_information", scope: i18n_scope) %>
18
+ <% end %>
15
19
  </div>
16
20
  </div>
17
21
  <div class="column large-6 card--process__column">
@@ -19,7 +23,8 @@
19
23
  <div class="card__content row collapse">
20
24
  <div class="large-6 large-offset-6 columns">
21
25
  <%= link_to decidim_participatory_processes.participatory_process_path(process), class: "button expanded button--sc" do %>
22
- <%= t("participate", scope: i18n_scope) %>
26
+ <span class="show-for-sr"><%= t("participate_in", resource_name: translated_attribute(process.title), scope: i18n_scope) %></span>
27
+ <span aria-hidden="true"><%= t("participate", scope: i18n_scope) %></span>
23
28
  <% if process.active_step %>
24
29
  <span class="button__info">
25
30
  <%= t("active_step", scope: i18n_scope) %>
@@ -32,7 +37,7 @@
32
37
  </div>
33
38
  </div>
34
39
  </div>
35
- </article>
40
+ </div>
36
41
  </div>
37
42
  </div>
38
43
  <%= render "_all_processes" %>
@@ -29,7 +29,7 @@ module Decidim
29
29
  OrganizationPublishedParticipatoryProcesses.new(current_organization, current_user) |
30
30
  HighlightedParticipatoryProcesses.new |
31
31
  FilteredParticipatoryProcesses.new("active")
32
- ).query.limit(max_results)
32
+ ).query.includes([:organization]).limit(max_results)
33
33
  end
34
34
 
35
35
  def i18n_scope
@@ -1,8 +1,8 @@
1
1
  <div class="row collapse order-by">
2
- <h2 class="order-by__text section-heading">
2
+ <h3 class="order-by__text section-heading">
3
3
  <%= title %>
4
4
  <%= render :filter_tabs %>
5
- </h2>
5
+ </h3>
6
6
  </div>
7
7
  <% if process_count_by_filter["active"] == 0 && process_count_by_filter["upcoming"] == 0 %>
8
8
  <div class="row column">
@@ -1,9 +1,8 @@
1
1
  <div class="card__footer card__footer--spaces">
2
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
- ) %>
3
+ <%= link_to(resource_path, class: "card__button button button--sc small") do %>
4
+ <span class="show-for-sr"><%= t("browse_resource", resource_name: title, scope: "layouts.decidim.participatory_process_groups.participatory_process_group") %></span>
5
+ <%= t("layouts.decidim.participatory_process_groups.participatory_process_group.browse") %>
6
+ <% end %>
8
7
  </div>
9
8
  </div>
@@ -1,7 +1,7 @@
1
1
  <div class="card__icondata">
2
2
  <ul class="card-data">
3
3
  <li class="card-data__item">
4
- <%= icon "datetime", class: "icon--big" %>
4
+ <%= icon "datetime", class: "icon--big", role: "img", aria_label: t("decidim.participatory_processes.show.dates") %>
5
5
  </li>
6
6
  <li class="card-data__item">
7
7
  <div class="card-data__item--centerblock">
@@ -2,14 +2,13 @@
2
2
  <div class="card__support">
3
3
  <% if has_step? %>
4
4
  <div class="card__support__data--left">
5
- <div class="text-uppercase"><%= t("layouts.decidim.participatory_processes.participatory_process.active_step") %></div>
5
+ <div><%= t("layouts.decidim.participatory_processes.participatory_process.active_step") %></div>
6
6
  <div class="text-ellipsis"><strong><%= step_title %></strong></div>
7
7
  </div>
8
8
  <% end %>
9
- <%= link_to(
10
- t(model.cta_button_text_key, scope: "layouts.decidim.participatory_processes.participatory_process"),
11
- resource_path,
12
- class: "card__button button button--sc secondary light small"
13
- ) %>
9
+ <%= link_to(resource_path, class: "card__button button button--sc small") do %>
10
+ <span class="show-for-sr"><%= t(model.cta_button_text_key_accessible, resource_name: title, scope: "layouts.decidim.participatory_processes.participatory_process") %></span>
11
+ <%= t(model.cta_button_text_key, scope: "layouts.decidim.participatory_processes.participatory_process") %>
12
+ <% end %>
14
13
  </div>
15
14
  </div>
@@ -1,7 +1,7 @@
1
1
  <% if model.hashtag.present? %>
2
2
  <%= link_to(
3
- "##{model.hashtag}",
4
- "https://twitter.com/hashtag/#{model.hashtag}",
3
+ "##{decidim_html_escape(model.hashtag)}",
4
+ "https://twitter.com/hashtag/#{decidim_html_escape(model.hashtag)}",
5
5
  class: "card__text--category",
6
6
  target: "_blank"
7
7
  ) %>
@@ -5,6 +5,8 @@ module Decidim
5
5
  # This cell renders the Medium (:m) process card
6
6
  # for an given instance of a Process
7
7
  class ProcessMCell < Decidim::CardMCell
8
+ include Decidim::SanitizeHelper
9
+
8
10
  private
9
11
 
10
12
  def has_image?
@@ -0,0 +1,9 @@
1
+ <div class="process-stats__data">
2
+ <span class="process-stats__number">
3
+ <%= stat_number %>
4
+ </span>
5
+
6
+ <h4 class="process-stats__title">
7
+ <%= stat_title %>
8
+ </h4>
9
+ </div>
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # This cell renders a Statistic of a ParticipatoryProcesses
6
+ class StatisticCell < Decidim::ViewModel
7
+ include ActionView::Helpers::NumberHelper
8
+
9
+ private
10
+
11
+ def stat_number
12
+ number_with_delimiter(model[:stat_number])
13
+ end
14
+
15
+ def stat_title
16
+ t(model[:stat_title], scope: "decidim.participatory_processes.statistics")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ <section class="row statistics" id="participatory_process-statistics">
2
+ <div class="columns large-8">
3
+ <div class="row column">
4
+ <h3 class="section-heading">
5
+ <%= stats_heading %>
6
+ </h3>
7
+
8
+ <div class="process-stats">
9
+ <% if model.present? %>
10
+ <%= cell("decidim/participatory_processes/statistic", collection: model) %>
11
+ <% else %>
12
+ <span class="muted"><%= no_stats %></span>
13
+ <% end %>
14
+ </div>
15
+ </div>
16
+ </div>
17
+ </section>
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ # This cell renders the Statistics of a ParticipatoryProcesses
6
+ class StatisticsCell < Decidim::ViewModel
7
+ private
8
+
9
+ def stats_heading
10
+ t("statistics.headline", scope: "decidim.participatory_processes")
11
+ end
12
+
13
+ def no_stats
14
+ t("statistics.no_stats", scope: "decidim.participatory_processes")
15
+ end
16
+ end
17
+ end
18
+ end
@@ -22,10 +22,11 @@ module Decidim
22
22
  def call
23
23
  return broadcast(:invalid) if form.invalid?
24
24
 
25
- process = create_participatory_process
25
+ create_participatory_process
26
26
 
27
27
  if process.persisted?
28
28
  add_admins_as_followers(process)
29
+ link_related_processes
29
30
  broadcast(:ok, process)
30
31
  else
31
32
  form.errors.add(:hero_image, process.errors[:hero_image]) if process.errors.include? :hero_image
@@ -36,10 +37,10 @@ module Decidim
36
37
 
37
38
  private
38
39
 
39
- attr_reader :form
40
+ attr_reader :form, :process
40
41
 
41
42
  def create_participatory_process
42
- process = ParticipatoryProcess.new(
43
+ @process = ParticipatoryProcess.new(
43
44
  organization: form.current_organization,
44
45
  title: form.title,
45
46
  subtitle: form.subtitle,
@@ -52,6 +53,7 @@ module Decidim
52
53
  promoted: form.promoted,
53
54
  scopes_enabled: form.scopes_enabled,
54
55
  scope: form.scope,
56
+ scope_type_max_depth: form.scope_type_max_depth,
55
57
  private_space: form.private_space,
56
58
  developer_group: form.developer_group,
57
59
  local_area: form.local_area,
@@ -106,15 +108,12 @@ module Decidim
106
108
  end
107
109
  end
108
110
 
109
- def create_participatory_process_users(process)
110
- return unless form.private_process
111
+ def related_processes
112
+ @related_processes ||= Decidim::ParticipatoryProcess.where(id: form.related_process_ids)
113
+ end
111
114
 
112
- form.users.each do |user|
113
- ParticipatoryProcessUser.create!(
114
- participatory_process: process,
115
- user: user
116
- )
117
- end
115
+ def link_related_processes
116
+ process.link_participatory_space_resources(related_processes, "related_processes")
118
117
  end
119
118
  end
120
119
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new participatory
7
7
  # process admin in the system.
8
- class CreateParticipatoryProcessAdmin < Rectify::Command
8
+ class CreateParticipatoryProcessAdmin < NotifyRoleAssignedToParticipatoryProcess
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -61,6 +61,7 @@ module Decidim
61
61
  role_params,
62
62
  extra_info
63
63
  )
64
+ send_notification user
64
65
  end
65
66
 
66
67
  def existing_role
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ module Admin
6
+ # A command with all the business logic when copying a new participatory
7
+ # process in the system.
8
+ class ImportParticipatoryProcess < Rectify::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # form - A form object with the params.
12
+ # participatory_process - A participatory_process we want to duplicate
13
+ def initialize(form)
14
+ @form = form
15
+ end
16
+
17
+ # Executes the command. Broadcasts these events:
18
+ #
19
+ # - :ok when everything is valid.
20
+ # - :invalid if the form wasn't valid and we couldn't proceed.
21
+ #
22
+ # Returns nothing.
23
+ def call
24
+ return broadcast(:invalid) if form.invalid?
25
+
26
+ transaction do
27
+ import_participatory_process
28
+ add_admins_as_followers(@imported_process)
29
+ end
30
+
31
+ broadcast(:ok, @imported_process)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :form
37
+
38
+ def import_participatory_process
39
+ importer = Decidim::ParticipatoryProcesses::ParticipatoryProcessImporter.new(form.current_organization, form.current_user)
40
+ participatory_processes.each do |original_process|
41
+ @imported_process = importer.import(original_process, form.current_user, title: form.title, slug: form.slug)
42
+ importer.import_participatory_process_steps(original_process["participatory_process_steps"]) if form.import_steps?
43
+ importer.import_categories(original_process["participatory_process_categories"]) if form.import_categories?
44
+ importer.import_folders_and_attachments(original_process["attachments"]) if form.import_attachments?
45
+ importer.import_components(original_process["components"]) if form.import_components?
46
+ end
47
+ end
48
+
49
+ def participatory_processes
50
+ document_parsed(form.document_text)
51
+ end
52
+
53
+ def document_parsed(document_text)
54
+ JSON.parse(document_text)
55
+ end
56
+
57
+ def add_admins_as_followers(process)
58
+ process.organization.admins.each do |admin|
59
+ form = Decidim::FollowForm
60
+ .from_params(followable_gid: process.to_signed_global_id.to_s)
61
+ .with_context(
62
+ current_organization: process.organization,
63
+ current_user: admin
64
+ )
65
+
66
+ Decidim::CreateFollow.new(form, admin).call
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ module Admin
6
+ # A command to notify users when a role is assigned for a participatory process
7
+ class NotifyRoleAssignedToParticipatoryProcess < Rectify::Command
8
+ def send_notification(user)
9
+ Decidim::EventsManager.publish(
10
+ event: "decidim.events.participatory_process.role_assigned",
11
+ event_class: Decidim::ParticipatoryProcessRoleAssignedEvent,
12
+ resource: form.current_participatory_space,
13
+ affected_users: [user],
14
+ extra: {
15
+ role: form.role
16
+ }
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -41,13 +41,14 @@ module Decidim
41
41
 
42
42
  def update_participatory_process
43
43
  @participatory_process.assign_attributes(attributes)
44
- if @participatory_process.valid?
45
- @participatory_process.save!
44
+ return unless @participatory_process.valid?
45
+
46
+ @participatory_process.save!
46
47
 
47
- Decidim.traceability.perform_action!(:update, @participatory_process, form.current_user) do
48
- @participatory_process
49
- end
48
+ Decidim.traceability.perform_action!(:update, @participatory_process, form.current_user) do
49
+ @participatory_process
50
50
  end
51
+ link_related_processes
51
52
  end
52
53
 
53
54
  def attributes
@@ -65,6 +66,7 @@ module Decidim
65
66
  short_description: form.short_description,
66
67
  scopes_enabled: form.scopes_enabled,
67
68
  scope: form.scope,
69
+ scope_type_max_depth: form.scope_type_max_depth,
68
70
  private_space: form.private_space,
69
71
  developer_group: form.developer_group,
70
72
  local_area: form.local_area,
@@ -76,10 +78,19 @@ module Decidim
76
78
  start_date: form.start_date,
77
79
  end_date: form.end_date,
78
80
  participatory_process_group: form.participatory_process_group,
81
+ show_metrics: form.show_metrics,
79
82
  show_statistics: form.show_statistics,
80
83
  announcement: form.announcement
81
84
  }
82
85
  end
86
+
87
+ def related_processes
88
+ @related_processes ||= Decidim::ParticipatoryProcess.where(id: form.related_process_ids)
89
+ end
90
+
91
+ def link_related_processes
92
+ @participatory_process.link_participatory_space_resources(related_processes, "related_processes")
93
+ end
83
94
  end
84
95
  end
85
96
  end