decidim-participatory_processes 0.27.6 → 0.28.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/cells/decidim/participatory_process_groups/content_block_cell.rb +5 -1
  4. data/app/cells/decidim/participatory_process_groups/content_blocks/extra_data/recent_users.erb +1 -0
  5. data/app/cells/decidim/participatory_process_groups/content_blocks/extra_data_cell.rb +71 -0
  6. data/app/cells/decidim/participatory_process_groups/content_blocks/main_data/content.erb +30 -0
  7. data/app/cells/decidim/participatory_process_groups/content_blocks/main_data_cell.rb +77 -0
  8. data/app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb +47 -0
  9. data/app/cells/decidim/participatory_process_groups/content_blocks/statistics_cell.rb +2 -2
  10. data/app/cells/decidim/participatory_process_groups/process_filters_cell.rb +4 -4
  11. data/app/cells/decidim/participatory_processes/content_block_cell.rb +21 -0
  12. data/app/cells/decidim/participatory_processes/content_blocks/extra_data/active_step.erb +1 -0
  13. data/app/cells/decidim/participatory_processes/content_blocks/extra_data_cell.rb +60 -0
  14. data/app/cells/decidim/participatory_processes/content_blocks/hero_cell.rb +29 -0
  15. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb +14 -27
  16. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_settings_form/show.erb +1 -1
  17. data/app/cells/decidim/participatory_processes/content_blocks/main_data_cell.rb +34 -0
  18. data/app/cells/decidim/participatory_processes/content_blocks/metadata_cell.rb +23 -0
  19. data/app/cells/decidim/participatory_processes/content_blocks/metrics_cell.rb +25 -0
  20. data/app/cells/decidim/participatory_processes/content_blocks/processes_settings_form/show.erb +3 -0
  21. data/app/cells/decidim/participatory_processes/content_blocks/processes_settings_form_cell.rb +28 -0
  22. data/app/cells/decidim/participatory_processes/content_blocks/related_processes/content.erb +1 -0
  23. data/app/cells/decidim/participatory_processes/content_blocks/related_processes_cell.rb +53 -0
  24. data/app/cells/decidim/participatory_processes/content_blocks/stats_cell.rb +17 -0
  25. data/app/cells/decidim/participatory_processes/filtered_participatory_processes_cell.rb +1 -1
  26. data/app/cells/decidim/participatory_processes/process_cell.rb +2 -2
  27. data/app/cells/decidim/participatory_processes/process_dropdown_metadata/metadata.erb +22 -0
  28. data/app/cells/decidim/participatory_processes/process_dropdown_metadata_cell.rb +39 -0
  29. data/app/cells/decidim/participatory_processes/process_filters/show.erb +4 -5
  30. data/app/cells/decidim/participatory_processes/process_filters/type_filter.erb +1 -1
  31. data/app/cells/decidim/participatory_processes/process_filters_cell.rb +6 -6
  32. data/app/cells/decidim/participatory_processes/process_g_cell.rb +31 -0
  33. data/app/cells/decidim/participatory_processes/process_group_cell.rb +2 -2
  34. data/app/cells/decidim/participatory_processes/process_group_g_cell.rb +23 -0
  35. data/app/cells/decidim/participatory_processes/process_group_metadata_cell.rb +46 -0
  36. data/app/cells/decidim/participatory_processes/process_group_s_cell.rb +5 -13
  37. data/app/cells/decidim/participatory_processes/process_metadata_cell.rb +44 -0
  38. data/app/cells/decidim/participatory_processes/process_metadata_g_cell.rb +15 -0
  39. data/app/cells/decidim/participatory_processes/process_s_cell.rb +5 -25
  40. data/app/cells/decidim/participatory_processes/process_step/show.erb +48 -0
  41. data/app/cells/decidim/participatory_processes/process_step_cell.rb +30 -0
  42. data/app/cells/decidim/participatory_processes/processes/show.erb +16 -0
  43. data/app/cells/decidim/participatory_processes/processes_cell.rb +24 -0
  44. data/app/commands/decidim/participatory_processes/admin/activate_participatory_process_step.rb +1 -1
  45. data/app/commands/decidim/participatory_processes/admin/copy_participatory_process.rb +2 -2
  46. data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +3 -1
  47. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_group.rb +4 -2
  48. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_step.rb +1 -1
  49. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_type.rb +1 -1
  50. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb +1 -1
  51. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_step.rb +1 -1
  52. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_type.rb +1 -1
  53. data/app/commands/decidim/participatory_processes/admin/import_participatory_process.rb +1 -1
  54. data/app/commands/decidim/participatory_processes/admin/reorder_participatory_process_steps.rb +1 -1
  55. data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +1 -1
  56. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_group.rb +2 -2
  57. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb +1 -1
  58. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb +1 -1
  59. data/app/constraints/decidim/participatory_processes/current_participatory_process.rb +1 -1
  60. data/app/controllers/decidim/participatory_processes/admin/application_controller.rb +29 -0
  61. data/app/controllers/decidim/participatory_processes/admin/categories_controller.rb +2 -0
  62. data/app/controllers/decidim/participatory_processes/admin/concerns/participatory_process_admin.rb +3 -1
  63. data/app/controllers/decidim/participatory_processes/admin/moderations/reports_controller.rb +1 -1
  64. data/app/controllers/decidim/participatory_processes/admin/moderations_controller.rb +1 -1
  65. data/app/controllers/decidim/participatory_processes/admin/participatory_process_attachment_collections_controller.rb +5 -0
  66. data/app/controllers/decidim/participatory_processes/admin/participatory_process_attachments_controller.rb +5 -0
  67. data/app/controllers/decidim/participatory_processes/admin/participatory_process_group_landing_page_content_blocks_controller.rb +1 -5
  68. data/app/controllers/decidim/participatory_processes/admin/participatory_process_group_landing_page_controller.rb +24 -7
  69. data/app/controllers/decidim/participatory_processes/admin/participatory_process_groups_controller.rb +16 -0
  70. data/app/controllers/decidim/participatory_processes/admin/participatory_process_imports_controller.rb +14 -0
  71. data/app/controllers/decidim/participatory_processes/admin/participatory_process_landing_page_content_blocks_controller.rb +37 -0
  72. data/app/controllers/decidim/participatory_processes/admin/participatory_process_landing_page_controller.rb +37 -0
  73. data/app/controllers/decidim/participatory_processes/admin/participatory_process_publications_controller.rb +9 -29
  74. data/app/controllers/decidim/participatory_processes/admin/participatory_process_step_activations_controller.rb +1 -1
  75. data/app/controllers/decidim/participatory_processes/admin/participatory_process_steps_controller.rb +16 -4
  76. data/app/controllers/decidim/participatory_processes/admin/participatory_process_types_controller.rb +19 -0
  77. data/app/controllers/decidim/participatory_processes/admin/participatory_process_user_roles_controller.rb +8 -91
  78. data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb +3 -0
  79. data/app/controllers/decidim/participatory_processes/participatory_process_groups_controller.rb +14 -1
  80. data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +19 -4
  81. data/app/events/decidim/participatory_process_role_assigned_event.rb +6 -6
  82. data/app/events/decidim/participatory_process_step_activated_event.rb +5 -4
  83. data/app/events/decidim/participatory_process_step_changed_event.rb +5 -4
  84. data/app/forms/decidim/participatory_processes/admin/participatory_process_copy_form.rb +1 -1
  85. data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +1 -1
  86. data/app/forms/decidim/participatory_processes/admin/participatory_process_import_form.rb +1 -1
  87. data/app/forms/decidim/participatory_processes/admin/participatory_process_step_form.rb +2 -2
  88. data/app/forms/decidim/participatory_processes/admin/participatory_process_user_role_form.rb +2 -18
  89. data/app/helpers/decidim/participatory_processes/admin/participatory_process_helper.rb +1 -0
  90. data/app/helpers/decidim/participatory_processes/application_helper.rb +5 -0
  91. data/app/helpers/decidim/participatory_processes/participatory_process_helper.rb +37 -9
  92. data/app/helpers/decidim/participatory_processes/participatory_space_content_blocks_helper.rb +17 -0
  93. data/app/jobs/decidim/participatory_processes/change_active_step_job.rb +35 -0
  94. data/app/models/decidim/participatory_process.rb +5 -5
  95. data/app/models/decidim/participatory_process_group.rb +4 -0
  96. data/app/models/decidim/participatory_process_user_role.rb +5 -34
  97. data/app/packs/entrypoints/decidim_participatory_processes.js +0 -2
  98. data/app/packs/src/decidim/participatory_processes/admin/participatory_processes.js +2 -2
  99. data/app/permissions/decidim/participatory_processes/permissions.rb +11 -15
  100. data/app/presenters/decidim/participatory_processes/admin_log/participatory_process_group_presenter.rb +2 -2
  101. data/app/presenters/decidim/participatory_processes/admin_log/participatory_process_presenter.rb +2 -2
  102. data/app/presenters/decidim/participatory_processes/admin_log/participatory_process_type_presenter.rb +2 -2
  103. data/app/presenters/decidim/participatory_processes/admin_log/participatory_process_user_role_presenter.rb +2 -2
  104. data/app/presenters/decidim/participatory_processes/admin_log/step_presenter.rb +2 -2
  105. data/app/presenters/decidim/participatory_processes/participatory_process_group_stats_presenter.rb +4 -40
  106. data/app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb +0 -68
  107. data/app/presenters/decidim/participatory_processes/participatory_process_presenter.rb +6 -0
  108. data/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb +3 -42
  109. data/app/queries/decidim/participatory_processes/admin/admin_users.rb +1 -1
  110. data/app/queries/decidim/participatory_processes/admin/moderators.rb +1 -1
  111. data/app/serializers/decidim/participatory_processes/participatory_process_importer.rb +4 -4
  112. data/app/views/decidim/participatory_processes/admin/participatory_process_copies/_form.html.erb +24 -29
  113. data/app/views/decidim/participatory_processes/admin/participatory_process_copies/new.html.erb +16 -5
  114. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/_form.html.erb +72 -50
  115. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/edit.html.erb +15 -9
  116. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/index.html.erb +49 -54
  117. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/new.html.erb +28 -5
  118. data/app/views/decidim/participatory_processes/admin/participatory_process_imports/_form.html.erb +33 -39
  119. data/app/views/decidim/participatory_processes/admin/participatory_process_imports/new.html.erb +18 -5
  120. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/_form.html.erb +18 -25
  121. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/edit.html.erb +16 -5
  122. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/index.html.erb +54 -54
  123. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/new.html.erb +18 -5
  124. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/show.html.erb +2 -2
  125. data/app/views/decidim/participatory_processes/admin/participatory_process_types/_form.html.erb +6 -8
  126. data/app/views/decidim/participatory_processes/admin/participatory_process_types/edit.html.erb +14 -6
  127. data/app/views/decidim/participatory_processes/admin/participatory_process_types/index.html.erb +47 -50
  128. data/app/views/decidim/participatory_processes/admin/participatory_process_types/new.html.erb +14 -6
  129. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/_form.html.erb +14 -18
  130. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/edit.html.erb +17 -6
  131. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/index.html.erb +59 -60
  132. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/new.html.erb +16 -5
  133. data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +193 -146
  134. data/app/views/decidim/participatory_processes/admin/participatory_processes/edit.html.erb +25 -11
  135. data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +111 -128
  136. data/app/views/decidim/participatory_processes/admin/participatory_processes/new.html.erb +16 -9
  137. data/app/views/decidim/participatory_processes/participatory_process_groups/show.html.erb +6 -10
  138. data/app/views/decidim/participatory_processes/participatory_processes/_collection.html.erb +8 -0
  139. data/app/views/decidim/participatory_processes/participatory_processes/all_metrics.html.erb +21 -8
  140. data/app/views/decidim/participatory_processes/participatory_processes/index.html.erb +19 -17
  141. data/app/views/decidim/participatory_processes/participatory_processes/index.js.erb +1 -8
  142. data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +14 -128
  143. data/app/views/layouts/decidim/_process_header.html.erb +15 -26
  144. data/app/views/layouts/decidim/_process_nav_item.html.erb +6 -0
  145. data/app/views/layouts/decidim/admin/_manage_processes.html.erb +36 -0
  146. data/app/views/layouts/decidim/admin/participatory_process.html.erb +12 -14
  147. data/app/views/layouts/decidim/admin/participatory_process_group.html.erb +23 -13
  148. data/app/views/layouts/decidim/admin/participatory_process_groups.html.erb +13 -0
  149. data/app/views/layouts/decidim/admin/participatory_process_type.html.erb +13 -11
  150. data/app/views/layouts/decidim/admin/participatory_processes.html.erb +14 -8
  151. data/app/views/layouts/decidim/participatory_process.html.erb +7 -14
  152. data/config/locales/ar.yml +1 -55
  153. data/config/locales/bg.yml +0 -72
  154. data/config/locales/ca.yml +50 -70
  155. data/config/locales/cs.yml +51 -71
  156. data/config/locales/de.yml +51 -71
  157. data/config/locales/el.yml +8 -64
  158. data/config/locales/en.yml +52 -72
  159. data/config/locales/es-MX.yml +49 -69
  160. data/config/locales/es-PY.yml +49 -69
  161. data/config/locales/es.yml +49 -69
  162. data/config/locales/eu.yml +89 -112
  163. data/config/locales/fi-plain.yml +50 -70
  164. data/config/locales/fi.yml +51 -71
  165. data/config/locales/fr-CA.yml +51 -71
  166. data/config/locales/fr.yml +52 -72
  167. data/config/locales/ga-IE.yml +0 -16
  168. data/config/locales/gl.yml +0 -67
  169. data/config/locales/hu.yml +6 -66
  170. data/config/locales/id-ID.yml +1 -55
  171. data/config/locales/is-IS.yml +0 -24
  172. data/config/locales/it.yml +0 -67
  173. data/config/locales/ja.yml +51 -71
  174. data/config/locales/lb.yml +1 -153
  175. data/config/locales/lt.yml +39 -65
  176. data/config/locales/lv.yml +1 -59
  177. data/config/locales/nl.yml +0 -67
  178. data/config/locales/no.yml +0 -92
  179. data/config/locales/pl.yml +0 -100
  180. data/config/locales/pt-BR.yml +1 -113
  181. data/config/locales/pt.yml +0 -67
  182. data/config/locales/ro-RO.yml +4 -64
  183. data/config/locales/ru.yml +0 -49
  184. data/config/locales/sk.yml +1 -56
  185. data/config/locales/sl.yml +0 -7
  186. data/config/locales/sr-CS.yml +0 -4
  187. data/config/locales/sv.yml +15 -66
  188. data/config/locales/tr-TR.yml +7 -68
  189. data/config/locales/uk.yml +0 -49
  190. data/config/locales/zh-CN.yml +2 -63
  191. data/config/locales/zh-TW.yml +3 -63
  192. data/db/migrate/20220315100140_change_steps_dates_to_datetime.rb +8 -0
  193. data/lib/decidim/api/participatory_process_step_type.rb +2 -2
  194. data/lib/decidim/participatory_processes/admin_engine.rb +20 -139
  195. data/lib/decidim/participatory_processes/content_blocks/registry_manager.rb +278 -0
  196. data/lib/decidim/participatory_processes/engine.rb +13 -103
  197. data/lib/decidim/participatory_processes/menu.rb +190 -0
  198. data/lib/decidim/participatory_processes/participatory_space.rb +7 -204
  199. data/lib/decidim/participatory_processes/query_extensions.rb +2 -2
  200. data/lib/decidim/participatory_processes/seeds.rb +164 -0
  201. data/lib/decidim/participatory_processes/test/factories.rb +58 -65
  202. data/lib/decidim/participatory_processes/version.rb +1 -1
  203. data/lib/tasks/decidim_participatory_processes.rake +8 -0
  204. metadata +65 -70
  205. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/filters.erb +0 -21
  206. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/filters_small_view.erb +0 -18
  207. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/participatory_space_filters.erb +0 -6
  208. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/show.erb +0 -8
  209. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/title_filter_order.erb +0 -8
  210. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes_cell.rb +0 -60
  211. data/app/cells/decidim/participatory_process_groups/content_blocks/html/show.erb +0 -3
  212. data/app/cells/decidim/participatory_process_groups/content_blocks/html_cell.rb +0 -13
  213. data/app/cells/decidim/participatory_process_groups/content_blocks/metadata/show.erb +0 -28
  214. data/app/cells/decidim/participatory_process_groups/content_blocks/metadata_cell.rb +0 -15
  215. data/app/cells/decidim/participatory_process_groups/content_blocks/title/show.erb +0 -43
  216. data/app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb +0 -64
  217. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/_all_processes.erb +0 -9
  218. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/show.erb +0 -14
  219. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/single_process.erb +0 -48
  220. data/app/cells/decidim/participatory_processes/process_group_m/footer.erb +0 -8
  221. data/app/cells/decidim/participatory_processes/process_group_m_cell.rb +0 -60
  222. data/app/cells/decidim/participatory_processes/process_group_s/image.erb +0 -1
  223. data/app/cells/decidim/participatory_processes/process_group_s/show.erb +0 -8
  224. data/app/cells/decidim/participatory_processes/process_m/data.erb +0 -21
  225. data/app/cells/decidim/participatory_processes/process_m/footer.erb +0 -14
  226. data/app/cells/decidim/participatory_processes/process_m/tags.erb +0 -8
  227. data/app/cells/decidim/participatory_processes/process_m_cell.rb +0 -87
  228. data/app/cells/decidim/participatory_processes/process_s/image.erb +0 -1
  229. data/app/cells/decidim/participatory_processes/process_s/show.erb +0 -14
  230. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb +0 -58
  231. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_admin.rb +0 -58
  232. data/app/commands/decidim/participatory_processes/admin/notify_role_assigned_to_participatory_process.rb +0 -22
  233. data/app/commands/decidim/participatory_processes/admin/publish_participatory_process.rb +0 -40
  234. data/app/commands/decidim/participatory_processes/admin/unpublish_participatory_process.rb +0 -40
  235. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_admin.rb +0 -56
  236. data/app/controllers/decidim/participatory_processes/participatory_process_steps_controller.rb +0 -28
  237. data/app/controllers/decidim/participatory_processes/widgets_controller.rb +0 -37
  238. data/app/packs/src/decidim/participatory_processes/filters.js +0 -28
  239. data/app/views/decidim/participatory_process_steps/_participatory_process_step.html.erb +0 -16
  240. data/app/views/decidim/participatory_processes/participatory_process_steps/_timeline.html.erb +0 -7
  241. data/app/views/decidim/participatory_processes/participatory_process_steps/index.html.erb +0 -18
  242. data/app/views/decidim/participatory_processes/participatory_processes/_metrics.html.erb +0 -10
  243. data/app/views/decidim/participatory_processes/participatory_processes/_order_by_processes.html.erb +0 -1
  244. data/app/views/decidim/participatory_processes/participatory_processes/_participatory_process_group.html.erb +0 -4
  245. data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process.html.erb +0 -39
  246. data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process_group.html.erb +0 -31
  247. data/app/views/layouts/decidim/_process_header_steps.html.erb +0 -37
  248. data/app/views/layouts/decidim/_process_navigation.html.erb +0 -20
  249. data/config/locales/he-IL.yml +0 -1
  250. data/db/seeds/Exampledocument.pdf +0 -0
  251. data/db/seeds/city.jpeg +0 -0
  252. data/db/seeds/city2.jpeg +0 -0
  253. data/db/seeds/homepage_image.jpg +0 -0
  254. data/decidim-participatory_processes.gemspec +0 -31
@@ -0,0 +1,190 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ class Menu
6
+ def self.register_menu!
7
+ Decidim.menu :menu do |menu|
8
+ menu.add_item :participatory_processes,
9
+ I18n.t("menu.processes", scope: "decidim"),
10
+ decidim_participatory_processes.participatory_processes_path,
11
+ position: 2,
12
+ if: Decidim::ParticipatoryProcess.where(organization: current_organization).published.any?,
13
+ active: %r{^/process(es|_groups)}
14
+ end
15
+ end
16
+
17
+ def self.register_home_content_block_menu!
18
+ Decidim.menu :home_content_block_menu do |menu|
19
+ menu.add_item :participatory_processes,
20
+ I18n.t("menu.processes", scope: "decidim"),
21
+ decidim_participatory_processes.participatory_processes_path,
22
+ position: 10,
23
+ if: Decidim::ParticipatoryProcess.where(organization: current_organization).published.any?,
24
+ active: %r{^/process(es|_groups)}
25
+ end
26
+ end
27
+
28
+ def self.register_admin_menu_modules!
29
+ Decidim.menu :admin_menu_modules do |menu|
30
+ menu.add_item :participatory_processes,
31
+ I18n.t("menu.participatory_processes", scope: "decidim.admin"),
32
+ decidim_admin_participatory_processes.participatory_processes_path,
33
+ icon_name: "treasure-map-line",
34
+ position: 2,
35
+ active: is_active_link?(decidim_admin_participatory_processes.participatory_processes_path, :inclusive) ||
36
+ is_active_link?(decidim_admin_participatory_processes.participatory_process_groups_path, :inclusive) ||
37
+ is_active_link?(decidim_admin_participatory_processes.participatory_process_types_path),
38
+ if: allowed_to?(:enter, :space_area, space_name: :processes) || allowed_to?(:enter, :space_area, space_name: :process_groups)
39
+ end
40
+ end
41
+
42
+ def self.register_admin_participatory_processes_menu!
43
+ Decidim.menu :admin_participatory_processes_menu do |menu|
44
+ menu.add_item :participatory_processes,
45
+ I18n.t("menu.participatory_processes", scope: "decidim.admin"),
46
+ decidim_admin_participatory_processes.participatory_processes_path,
47
+ position: 1,
48
+ icon_name: "home-8-line",
49
+ if: allowed_to?(:enter, :space_area, space_name: :processes),
50
+ active: is_active_link?(decidim_admin_participatory_processes.participatory_processes_path)
51
+
52
+ menu.add_item :participatory_process_groups,
53
+ I18n.t("menu.participatory_process_groups", scope: "decidim.admin"),
54
+ decidim_admin_participatory_processes.participatory_process_groups_path,
55
+ position: 2,
56
+ icon_name: "home-8-line",
57
+ if: allowed_to?(:enter, :space_area, space_name: :process_groups),
58
+ active: is_active_link?(decidim_admin_participatory_processes.participatory_process_groups_path)
59
+ end
60
+ end
61
+
62
+ def self.register_participatory_process_admin_attachments_menu!
63
+ Decidim.menu :participatory_process_admin_attachments_menu do |menu|
64
+ menu.add_item :participatory_process_attachments,
65
+ I18n.t("attachment_files", scope: "decidim.admin.menu.participatory_processes_submenu"),
66
+ decidim_admin_participatory_processes.participatory_process_attachments_path(current_participatory_space),
67
+ active: is_active_link?(decidim_admin_participatory_processes.participatory_process_attachments_path(current_participatory_space)),
68
+ if: allowed_to?(:read, :attachment),
69
+ icon_name: "attachment-line"
70
+
71
+ menu.add_item :participatory_process_attachment_collections,
72
+ I18n.t("attachment_collections", scope: "decidim.admin.menu.participatory_processes_submenu"),
73
+ decidim_admin_participatory_processes.participatory_process_attachment_collections_path(current_participatory_space),
74
+ active: is_active_link?(decidim_admin_participatory_processes.participatory_process_attachment_collections_path(current_participatory_space)),
75
+ if: allowed_to?(:read, :attachment_collection),
76
+ icon_name: "folder-line"
77
+ end
78
+ end
79
+
80
+ def self.register_admin_participatory_process_components_menu!
81
+ Decidim.menu :admin_participatory_process_components_menu do |menu|
82
+ current_participatory_space.components.each do |component|
83
+ caption = translated_attribute(component.name)
84
+ if component.primary_stat.present?
85
+ caption += content_tag(:span, component.primary_stat, class: component.primary_stat.zero? ? "component-counter component-counter--off" : "component-counter")
86
+ end
87
+
88
+ menu.add_item [component.manifest_name, component.id].join("_"),
89
+ caption.html_safe,
90
+ manage_component_path(component),
91
+ active: is_active_link?(manage_component_path(component)) ||
92
+ is_active_link?(decidim_admin_participatory_processes.edit_component_path(current_participatory_space, component)) ||
93
+ is_active_link?(decidim_admin_participatory_processes.edit_component_permissions_path(current_participatory_space, component)) ||
94
+ participatory_space_active_link?(component),
95
+ if: component.manifest.admin_engine && user_role_config.component_is_accessible?(component.manifest_name)
96
+ end
97
+ end
98
+ end
99
+
100
+ def self.register_admin_participatory_process_menu!
101
+ Decidim.menu :admin_participatory_process_menu do |menu|
102
+ menu.add_item :edit_participatory_process,
103
+ I18n.t("info", scope: "decidim.admin.menu.participatory_processes_submenu"),
104
+ decidim_admin_participatory_processes.edit_participatory_process_path(current_participatory_space),
105
+ active: is_active_link?(decidim_admin_participatory_processes.edit_participatory_process_path(current_participatory_space)),
106
+ icon_name: "information-line",
107
+ if: allowed_to?(:update, :process, process: current_participatory_space)
108
+
109
+ menu.add_item :edit_participatory_process_landing_page,
110
+ I18n.t("landing_page", scope: "decidim.admin.menu.participatory_processes_submenu"),
111
+ decidim_admin_participatory_processes.edit_participatory_process_landing_page_path(current_participatory_space),
112
+ active: is_active_link?(decidim_admin_participatory_processes.participatory_process_landing_page_path(current_participatory_space)),
113
+ icon_name: "layout-masonry-line",
114
+ if: allowed_to?(:update, :process, process: current_participatory_space)
115
+
116
+ menu.add_item :participatory_process_steps,
117
+ I18n.t("steps", scope: "decidim.admin.menu.participatory_processes_submenu"),
118
+ decidim_admin_participatory_processes.participatory_process_steps_path(current_participatory_space),
119
+ active: is_active_link?(decidim_admin_participatory_processes.participatory_process_steps_path(current_participatory_space)),
120
+ icon_name: "direction-line",
121
+ if: allowed_to?(:read, :process_step)
122
+
123
+ menu.add_item :components,
124
+ I18n.t("components", scope: "decidim.admin.menu.participatory_processes_submenu"),
125
+ decidim_admin_participatory_processes.components_path(current_participatory_space),
126
+ active: is_active_link?(decidim_admin_participatory_processes.components_path(current_participatory_space),
127
+ ["decidim/participatory_processes/admin/components", %w(index new edit)]),
128
+ icon_name: "tools-line",
129
+ if: allowed_to?(:read, :component),
130
+ submenu: { target_menu: :admin_participatory_process_components_menu }
131
+
132
+ menu.add_item :categories,
133
+ I18n.t("categories", scope: "decidim.admin.menu.participatory_processes_submenu"),
134
+ decidim_admin_participatory_processes.categories_path(current_participatory_space),
135
+ active: is_active_link?(decidim_admin_participatory_processes.categories_path(current_participatory_space)),
136
+ icon_name: "price-tag-3-line",
137
+ if: allowed_to?(:read, :category)
138
+
139
+ menu.add_item :attachments,
140
+ I18n.t("attachments", scope: "decidim.admin.menu.participatory_processes_submenu"),
141
+ decidim_admin_participatory_processes.participatory_process_attachments_path(current_participatory_space),
142
+ active: is_active_link?(decidim_admin_participatory_processes.participatory_process_attachment_collections_path(current_participatory_space)) ||
143
+ is_active_link?(decidim_admin_participatory_processes.participatory_process_attachments_path(current_participatory_space)),
144
+ icon_name: "attachment-2",
145
+ if: allowed_to?(:read, :attachment_collection) || allowed_to?(:read, :attachment)
146
+
147
+ menu.add_item :participatory_process_user_roles,
148
+ I18n.t("process_admins", scope: "decidim.admin.menu.participatory_processes_submenu"),
149
+ decidim_admin_participatory_processes.participatory_process_user_roles_path(current_participatory_space),
150
+ active: is_active_link?(decidim_admin_participatory_processes.participatory_process_user_roles_path(current_participatory_space)),
151
+ icon_name: "user-settings-line",
152
+ if: allowed_to?(:read, :process_user_role)
153
+
154
+ menu.add_item :participatory_space_private_users,
155
+ I18n.t("private_users", scope: "decidim.admin.menu.participatory_processes_submenu"),
156
+ decidim_admin_participatory_processes.participatory_space_private_users_path(current_participatory_space),
157
+ active: is_active_link?(decidim_admin_participatory_processes.participatory_space_private_users_path(current_participatory_space)),
158
+ icon_name: "spy-line",
159
+ if: allowed_to?(:read, :space_private_user, current_participatory_space:)
160
+
161
+ menu.add_item :moderations,
162
+ I18n.t("moderations", scope: "decidim.admin.menu.participatory_processes_submenu"),
163
+ decidim_admin_participatory_processes.moderations_path(current_participatory_space),
164
+ active: is_active_link?(decidim_admin_participatory_processes.moderations_path(current_participatory_space)),
165
+ icon_name: "flag-line",
166
+ if: allowed_to?(:read, :moderation, current_participatory_space:)
167
+ end
168
+ end
169
+
170
+ def self.register_admin_participatory_process_group_menu!
171
+ Decidim.menu :admin_participatory_process_group_menu do |menu|
172
+ menu.add_item :edit_participatory_process_group,
173
+ I18n.t("info", scope: "decidim.admin.menu.participatory_process_groups_submenu"),
174
+ decidim_admin_participatory_processes.edit_participatory_process_group_path(participatory_process_group),
175
+ position: 1,
176
+ icon_name: "information-line",
177
+ if: allowed_to?(:update, :process_group, process_group: participatory_process_group),
178
+ active: is_active_link?(decidim_admin_participatory_processes.edit_participatory_process_group_path(participatory_process_group))
179
+ menu.add_item :edit_participatory_process_group_landing_page,
180
+ I18n.t("landing_page", scope: "decidim.admin.menu.participatory_process_groups_submenu"),
181
+ decidim_admin_participatory_processes.edit_participatory_process_group_landing_page_path(participatory_process_group),
182
+ position: 2,
183
+ icon_name: "layout-masonry-line",
184
+ if: allowed_to?(:update, :process_group, process_group: participatory_process_group),
185
+ active: is_active_link?(decidim_admin_participatory_processes.participatory_process_group_landing_page_path(participatory_process_group))
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
@@ -3,6 +3,7 @@
3
3
  Decidim.register_participatory_space(:participatory_processes) do |participatory_space|
4
4
  participatory_space.icon = "media/images/decidim_participatory_processes.svg"
5
5
  participatory_space.model_class_name = "Decidim::ParticipatoryProcess"
6
+ participatory_space.content_blocks_scope_name = "participatory_process_homepage"
6
7
 
7
8
  participatory_space.participatory_spaces do |organization|
8
9
  Decidim::ParticipatoryProcesses::OrganizationParticipatoryProcesses.new(organization).query
@@ -14,6 +15,8 @@ Decidim.register_participatory_space(:participatory_processes) do |participatory
14
15
 
15
16
  participatory_space.permissions_class_name = "Decidim::ParticipatoryProcesses::Permissions"
16
17
 
18
+ participatory_space.breadcrumb_cell = "decidim/participatory_processes/process_dropdown_metadata"
19
+
17
20
  participatory_space.register_resource(:participatory_process) do |resource|
18
21
  resource.model_class_name = "Decidim::ParticipatoryProcess"
19
22
  resource.card = "decidim/participatory_processes/process"
@@ -23,6 +26,7 @@ Decidim.register_participatory_space(:participatory_processes) do |participatory
23
26
  participatory_space.register_resource(:participatory_process_group) do |resource|
24
27
  resource.model_class_name = "Decidim::ParticipatoryProcessGroup"
25
28
  resource.card = "decidim/participatory_processes/process_group"
29
+ resource.content_blocks_scope_name = "participatory_process_group_homepage"
26
30
  end
27
31
 
28
32
  participatory_space.register_stat :followers_count, tag: :followers, priority: Decidim::StatsRegistry::LOW_PRIORITY do |spaces, _start_at, _end_at|
@@ -49,213 +53,12 @@ Decidim.register_participatory_space(:participatory_processes) do |participatory
49
53
  end
50
54
 
51
55
  participatory_space.register_on_destroy_account do |user|
52
- Decidim::ParticipatoryProcessUserRole.where(user: user).destroy_all
56
+ Decidim::ParticipatoryProcessUserRole.where(user:).destroy_all
53
57
  end
54
58
 
55
59
  participatory_space.seeds do
56
- organization = Decidim::Organization.first
57
- seeds_root = File.join(__dir__, "..", "..", "..", "db", "seeds")
58
-
59
- Decidim::ContentBlock.create(
60
- organization: organization,
61
- weight: 31,
62
- scope_name: :homepage,
63
- manifest_name: :highlighted_processes,
64
- published_at: Time.current
65
- )
66
-
67
- process_groups = []
68
- 2.times do
69
- process_groups << Decidim::ParticipatoryProcessGroup.create!(
70
- title: Decidim::Faker::Localized.sentence(word_count: 3),
71
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
72
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
73
- end,
74
- hashtag: Faker::Internet.slug,
75
- group_url: Faker::Internet.url,
76
- organization: organization,
77
- hero_image: ActiveStorage::Blob.create_and_upload!(
78
- io: File.open(File.join(seeds_root, "city.jpeg")),
79
- filename: "hero_image.jpeg",
80
- content_type: "image/jpeg",
81
- metadata: nil
82
- ), # Keep after organization
83
- developer_group: Decidim::Faker::Localized.sentence(word_count: 1),
84
- local_area: Decidim::Faker::Localized.sentence(word_count: 2),
85
- meta_scope: Decidim::Faker::Localized.word,
86
- target: Decidim::Faker::Localized.sentence(word_count: 3),
87
- participatory_scope: Decidim::Faker::Localized.sentence(word_count: 1),
88
- participatory_structure: Decidim::Faker::Localized.sentence(word_count: 2)
89
- )
90
- end
91
-
92
- landing_page_content_blocks = [:title, :metadata, :cta, :highlighted_proposals, :highlighted_results, :highlighted_meetings, :stats, :participatory_processes]
93
-
94
- process_groups.each do |process_group|
95
- landing_page_content_blocks.each.with_index(1) do |manifest_name, index|
96
- Decidim::ContentBlock.create(
97
- organization: organization,
98
- scope_name: :participatory_process_group_homepage,
99
- manifest_name: manifest_name,
100
- weight: index,
101
- scoped_resource_id: process_group.id,
102
- published_at: Time.current
103
- )
104
- end
105
- end
106
-
107
- process_types = []
108
- 2.times do
109
- process_types << Decidim::ParticipatoryProcessType.create!(
110
- title: Decidim::Faker::Localized.word,
111
- organization: organization
112
- )
113
- end
114
-
115
- 2.times do |n|
116
- params = {
117
- title: Decidim::Faker::Localized.sentence(word_count: 5),
118
- slug: Decidim::Faker::Internet.unique.slug(words: nil, glue: "-"),
119
- subtitle: Decidim::Faker::Localized.sentence(word_count: 2),
120
- hashtag: "##{Faker::Lorem.word}",
121
- short_description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
122
- Decidim::Faker::Localized.sentence(word_count: 3)
123
- end,
124
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
125
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
126
- end,
127
- organization: organization,
128
- hero_image: ActiveStorage::Blob.create_and_upload!(
129
- io: File.open(File.join(seeds_root, "city.jpeg")),
130
- filename: "hero_image.jpeg",
131
- content_type: "image/jpeg",
132
- metadata: nil
133
- ), # Keep after organization
134
- banner_image: ActiveStorage::Blob.create_and_upload!(
135
- io: File.open(File.join(seeds_root, "city2.jpeg")),
136
- filename: "banner_image.jpeg",
137
- content_type: "image/jpeg",
138
- metadata: nil
139
- ), # Keep after organization
140
- promoted: true,
141
- published_at: 2.weeks.ago,
142
- meta_scope: Decidim::Faker::Localized.word,
143
- developer_group: Decidim::Faker::Localized.sentence(word_count: 1),
144
- local_area: Decidim::Faker::Localized.sentence(word_count: 2),
145
- target: Decidim::Faker::Localized.sentence(word_count: 3),
146
- participatory_scope: Decidim::Faker::Localized.sentence(word_count: 1),
147
- participatory_structure: Decidim::Faker::Localized.sentence(word_count: 2),
148
- start_date: Date.current,
149
- end_date: 2.months.from_now,
150
- participatory_process_group: process_groups.sample,
151
- participatory_process_type: process_types.sample,
152
- scope: n.positive? ? nil : Decidim::Scope.reorder(Arel.sql("RANDOM()")).first
153
- }
154
-
155
- process = Decidim.traceability.perform_action!(
156
- "publish",
157
- Decidim::ParticipatoryProcess,
158
- organization.users.first,
159
- visibility: "all"
160
- ) do
161
- Decidim::ParticipatoryProcess.create!(params)
162
- end
163
- process.add_to_index_as_search_resource
60
+ require "decidim/participatory_processes/seeds"
164
61
 
165
- Decidim::ParticipatoryProcessStep.find_or_initialize_by(
166
- participatory_process: process,
167
- active: true
168
- ).update!(
169
- title: Decidim::Faker::Localized.sentence(word_count: 1, supplemental: false, random_words_to_add: 2),
170
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
171
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
172
- end,
173
- start_date: 1.month.ago,
174
- end_date: 2.months.from_now
175
- )
176
-
177
- # Create users with specific roles
178
- Decidim::ParticipatoryProcessUserRole::ROLES.each do |role|
179
- email = "participatory_process_#{process.id}_#{role}@example.org"
180
-
181
- user = Decidim::User.find_or_initialize_by(email: email)
182
- user.update!(
183
- name: Faker::Name.name,
184
- nickname: Faker::Twitter.unique.screen_name,
185
- password: "decidim123456789",
186
- password_confirmation: "decidim123456789",
187
- organization: organization,
188
- confirmed_at: Time.current,
189
- locale: I18n.default_locale,
190
- tos_agreement: true
191
- )
192
-
193
- Decidim::ParticipatoryProcessUserRole.find_or_create_by!(
194
- user: user,
195
- participatory_process: process,
196
- role: role
197
- )
198
- end
199
-
200
- attachment_collection = Decidim::AttachmentCollection.create!(
201
- name: Decidim::Faker::Localized.word,
202
- description: Decidim::Faker::Localized.sentence(word_count: 5),
203
- collection_for: process
204
- )
205
-
206
- Decidim::Attachment.create!(
207
- title: Decidim::Faker::Localized.sentence(word_count: 2),
208
- description: Decidim::Faker::Localized.sentence(word_count: 5),
209
- attachment_collection: attachment_collection,
210
- content_type: "application/pdf",
211
- attached_to: process,
212
- file: ActiveStorage::Blob.create_and_upload!(
213
- io: File.open(File.join(seeds_root, "Exampledocument.pdf")),
214
- filename: "Exampledocument.pdf",
215
- content_type: "application/pdf",
216
- metadata: nil
217
- ) # Keep after attached_to
218
- )
219
-
220
- Decidim::Attachment.create!(
221
- title: Decidim::Faker::Localized.sentence(word_count: 2),
222
- description: Decidim::Faker::Localized.sentence(word_count: 5),
223
- attached_to: process,
224
- content_type: "image/jpeg",
225
- file: ActiveStorage::Blob.create_and_upload!(
226
- io: File.open(File.join(seeds_root, "city.jpeg")),
227
- filename: "city.jpeg",
228
- content_type: "image/jpeg",
229
- metadata: nil
230
- ) # Keep after attached_to
231
- )
232
-
233
- Decidim::Attachment.create!(
234
- title: Decidim::Faker::Localized.sentence(word_count: 2),
235
- description: Decidim::Faker::Localized.sentence(word_count: 5),
236
- attached_to: process,
237
- content_type: "application/pdf",
238
- file: ActiveStorage::Blob.create_and_upload!(
239
- io: File.open(File.join(seeds_root, "Exampledocument.pdf")),
240
- filename: "Exampledocument.pdf",
241
- content_type: "application/pdf",
242
- metadata: nil
243
- ) # Keep after attached_to
244
- )
245
-
246
- 2.times do
247
- Decidim::Category.create!(
248
- name: Decidim::Faker::Localized.sentence(word_count: 5),
249
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
250
- Decidim::Faker::Localized.paragraph(sentence_count: 3)
251
- end,
252
- participatory_space: process
253
- )
254
- end
255
-
256
- Decidim.component_manifests.each do |manifest|
257
- manifest.seed!(process.reload)
258
- end
259
- end
62
+ Decidim::ParticipatoryProcesses::Seeds.new.call
260
63
  end
261
64
  end
@@ -39,7 +39,7 @@ module Decidim
39
39
  def participatory_process_group(id:)
40
40
  Decidim::ParticipatoryProcessGroup.find_by(
41
41
  organization: context[:current_organization],
42
- id: id
42
+ id:
43
43
  )
44
44
  end
45
45
 
@@ -52,7 +52,7 @@ module Decidim
52
52
  def participatory_process_type(id:)
53
53
  Decidim::ParticipatoryProcessType.find_by(
54
54
  organization: context[:current_organization],
55
- id: id
55
+ id:
56
56
  )
57
57
  end
58
58
  end
@@ -0,0 +1,164 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faker"
4
+ require "decidim/seeds"
5
+
6
+ module Decidim
7
+ module ParticipatoryProcesses
8
+ class Seeds < Decidim::Seeds
9
+ def call
10
+ create_content_block!
11
+
12
+ process_groups = []
13
+ 2.times do
14
+ process_groups << create_process_group!
15
+ end
16
+
17
+ process_groups.each do |process_group|
18
+ Decidim::ContentBlocksCreator.new(process_group).create_default!
19
+ end
20
+
21
+ process_types = []
22
+ 2.times do
23
+ process_types << create_process_type!
24
+ end
25
+
26
+ 2.times do |_n|
27
+ process = create_process!(process_group: process_groups.sample, process_type: process_types.sample)
28
+
29
+ create_process_step!(process:)
30
+
31
+ create_process_user_roles!(process:)
32
+
33
+ Decidim::ContentBlocksCreator.new(process).create_default!
34
+
35
+ create_attachments!(attached_to: process)
36
+
37
+ 2.times do
38
+ create_category!(participatory_space: process)
39
+ end
40
+
41
+ seed_components_manifests!(participatory_space: process)
42
+ end
43
+ end
44
+
45
+ def create_content_block!
46
+ Decidim::ContentBlock.create(
47
+ organization:,
48
+ weight: 31,
49
+ scope_name: :homepage,
50
+ manifest_name: :highlighted_processes,
51
+ published_at: Time.current
52
+ )
53
+ end
54
+
55
+ def create_process_group!
56
+ Decidim::ParticipatoryProcessGroup.create!(
57
+ title: Decidim::Faker::Localized.sentence(word_count: 3),
58
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
59
+ Decidim::Faker::Localized.paragraph(sentence_count: 3)
60
+ end,
61
+ hashtag: ::Faker::Internet.slug,
62
+ group_url: ::Faker::Internet.url,
63
+ organization:,
64
+ hero_image: ::Faker::Boolean.boolean(true_ratio: 0.5) ? hero_image : nil, # Keep after organization
65
+ developer_group: Decidim::Faker::Localized.sentence(word_count: 1),
66
+ local_area: Decidim::Faker::Localized.sentence(word_count: 2),
67
+ meta_scope: Decidim::Faker::Localized.word,
68
+ target: Decidim::Faker::Localized.sentence(word_count: 3),
69
+ participatory_scope: Decidim::Faker::Localized.sentence(word_count: 1),
70
+ participatory_structure: Decidim::Faker::Localized.sentence(word_count: 2)
71
+ )
72
+ end
73
+
74
+ def create_process_type!
75
+ Decidim::ParticipatoryProcessType.create!(
76
+ title: Decidim::Faker::Localized.word,
77
+ organization:
78
+ )
79
+ end
80
+
81
+ def create_process!(process_group: nil, process_type: nil)
82
+ n = rand(2)
83
+ params = {
84
+ title: Decidim::Faker::Localized.sentence(word_count: 5),
85
+ slug: Decidim::Faker::Internet.unique.slug(words: nil, glue: "-"),
86
+ subtitle: Decidim::Faker::Localized.sentence(word_count: 2),
87
+ hashtag: "##{::Faker::Lorem.word}",
88
+ short_description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
89
+ Decidim::Faker::Localized.sentence(word_count: 3)
90
+ end,
91
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
92
+ Decidim::Faker::Localized.paragraph(sentence_count: 3)
93
+ end,
94
+ organization:,
95
+ hero_image: ::Faker::Boolean.boolean(true_ratio: 0.5) ? hero_image : nil, # Keep after organization
96
+ banner_image: ::Faker::Boolean.boolean(true_ratio: 0.5) ? banner_image : nil, # Keep after organization
97
+ promoted: true,
98
+ published_at: 2.weeks.ago,
99
+ meta_scope: Decidim::Faker::Localized.word,
100
+ developer_group: Decidim::Faker::Localized.sentence(word_count: 1),
101
+ local_area: Decidim::Faker::Localized.sentence(word_count: 2),
102
+ target: Decidim::Faker::Localized.sentence(word_count: 3),
103
+ participatory_scope: Decidim::Faker::Localized.sentence(word_count: 1),
104
+ participatory_structure: Decidim::Faker::Localized.sentence(word_count: 2),
105
+ start_date: Date.current,
106
+ end_date: 2.months.from_now,
107
+ participatory_process_group: process_group,
108
+ participatory_process_type: process_type,
109
+ scope: n.positive? ? nil : Decidim::Scope.all.sample
110
+ }
111
+
112
+ process = Decidim.traceability.perform_action!(
113
+ "publish",
114
+ Decidim::ParticipatoryProcess,
115
+ organization.users.first,
116
+ visibility: "all"
117
+ ) do
118
+ Decidim::ParticipatoryProcess.create!(params)
119
+ end
120
+ process.add_to_index_as_search_resource
121
+
122
+ process
123
+ end
124
+
125
+ def create_process_step!(process:)
126
+ Decidim::ParticipatoryProcessStep.find_or_initialize_by(
127
+ participatory_process: process,
128
+ active: true
129
+ ).update!(
130
+ title: Decidim::Faker::Localized.sentence(word_count: 1, supplemental: false, random_words_to_add: 2),
131
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
132
+ Decidim::Faker::Localized.paragraph(sentence_count: 3)
133
+ end,
134
+ start_date: 1.month.ago,
135
+ end_date: 2.months.from_now
136
+ )
137
+ end
138
+
139
+ def create_process_user_roles!(process:)
140
+ # Create users with specific roles
141
+ Decidim::ParticipatoryProcessUserRole::ROLES.each do |role|
142
+ email = "participatory_process_#{process.id}_#{role}@example.org"
143
+
144
+ user = Decidim::User.find_or_initialize_by(email:)
145
+ user.update!(
146
+ name: ::Faker::Name.name,
147
+ nickname: ::Faker::Twitter.unique.screen_name,
148
+ password: "decidim123456789",
149
+ organization:,
150
+ confirmed_at: Time.current,
151
+ locale: I18n.default_locale,
152
+ tos_agreement: true
153
+ )
154
+
155
+ Decidim::ParticipatoryProcessUserRole.find_or_create_by!(
156
+ user:,
157
+ participatory_process: process,
158
+ role:
159
+ )
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end