decidim-initiatives 0.27.10 → 0.28.0.rc4

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 (240) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -3
  3. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives_cell.rb +17 -18
  4. data/app/cells/decidim/initiatives/initiative_cell.rb +6 -1
  5. data/app/cells/decidim/initiatives/initiative_dropdown_metadata_cell.rb +19 -0
  6. data/app/cells/decidim/initiatives/initiative_g_cell.rb +31 -0
  7. data/app/cells/decidim/initiatives/initiative_metadata_g_cell.rb +62 -0
  8. data/app/cells/decidim/initiatives/initiative_s_cell.rb +15 -0
  9. data/app/cells/decidim/initiatives_votes/vote/show.erb +25 -19
  10. data/app/cells/decidim/initiatives_votes/vote_cell.rb +3 -1
  11. data/app/commands/decidim/initiatives/admin/accept_initiative.rb +40 -0
  12. data/app/commands/decidim/initiatives/admin/create_initiative_type.rb +1 -1
  13. data/app/commands/decidim/initiatives/admin/create_initiative_type_scope.rb +1 -1
  14. data/app/commands/decidim/initiatives/admin/discard_initiative.rb +40 -0
  15. data/app/commands/decidim/initiatives/admin/publish_initiative.rb +1 -1
  16. data/app/commands/decidim/initiatives/admin/reject_initiative.rb +40 -0
  17. data/app/commands/decidim/initiatives/admin/send_initiative_to_technical_validation.rb +2 -2
  18. data/app/commands/decidim/initiatives/admin/unpublish_initiative.rb +1 -1
  19. data/app/commands/decidim/initiatives/admin/update_initiative.rb +1 -1
  20. data/app/commands/decidim/initiatives/admin/update_initiative_answer.rb +1 -1
  21. data/app/commands/decidim/initiatives/admin/update_initiative_type.rb +1 -1
  22. data/app/commands/decidim/initiatives/admin/update_initiative_type_scope.rb +1 -1
  23. data/app/commands/decidim/initiatives/admin/update_initiatives_settings.rb +1 -1
  24. data/app/commands/decidim/initiatives/attachment_methods.rb +2 -24
  25. data/app/commands/decidim/initiatives/create_initiative.rb +19 -14
  26. data/app/commands/decidim/initiatives/send_initiative_to_technical_validation.rb +2 -2
  27. data/app/commands/decidim/initiatives/spawn_committee_request.rb +1 -1
  28. data/app/commands/decidim/initiatives/unvote_initiative.rb +1 -1
  29. data/app/commands/decidim/initiatives/update_initiative.rb +9 -2
  30. data/app/commands/decidim/initiatives/validate_mobile_phone.rb +2 -2
  31. data/app/commands/decidim/initiatives/vote_initiative.rb +5 -5
  32. data/app/constraints/decidim/initiatives/current_initiative.rb +1 -1
  33. data/app/controllers/concerns/decidim/initiatives/admin/filterable.rb +2 -2
  34. data/app/controllers/concerns/decidim/initiatives/needs_initiative.rb +1 -1
  35. data/app/controllers/decidim/initiatives/admin/answers_controller.rb +3 -0
  36. data/app/controllers/decidim/initiatives/admin/committee_requests_controller.rb +2 -0
  37. data/app/controllers/decidim/initiatives/admin/components_controller.rb +3 -0
  38. data/app/controllers/decidim/initiatives/admin/initiative_attachments_controller.rb +2 -0
  39. data/app/controllers/decidim/initiatives/admin/initiatives_controller.rb +17 -6
  40. data/app/controllers/decidim/initiatives/admin/initiatives_permissions_controller.rb +3 -0
  41. data/app/controllers/decidim/initiatives/admin/initiatives_settings_controller.rb +2 -0
  42. data/app/controllers/decidim/initiatives/admin/initiatives_type_scopes_controller.rb +30 -0
  43. data/app/controllers/decidim/initiatives/admin/initiatives_types_controller.rb +14 -0
  44. data/app/controllers/decidim/initiatives/admin/initiatives_types_permissions_controller.rb +21 -0
  45. data/app/controllers/decidim/initiatives/admin/moderations/reports_controller.rb +2 -2
  46. data/app/controllers/decidim/initiatives/admin/moderations_controller.rb +4 -2
  47. data/app/controllers/decidim/initiatives/application_controller.rb +0 -1
  48. data/app/controllers/decidim/initiatives/authorization_create_modals_controller.rb +25 -0
  49. data/app/controllers/decidim/initiatives/authorization_sign_modals_controller.rb +2 -2
  50. data/app/controllers/decidim/initiatives/committee_requests_controller.rb +0 -2
  51. data/app/controllers/decidim/initiatives/create_initiative_controller.rb +62 -115
  52. data/app/controllers/decidim/initiatives/initiative_signatures_controller.rb +113 -81
  53. data/app/controllers/decidim/initiatives/initiative_types_controller.rb +7 -0
  54. data/app/controllers/decidim/initiatives/initiatives_controller.rb +37 -17
  55. data/app/controllers/decidim/initiatives/versions_controller.rb +0 -1
  56. data/app/events/decidim/initiatives/admin/initiative_sent_to_technical_validation_event.rb +2 -2
  57. data/app/events/decidim/initiatives/admin/support_threshold_reached_event.rb +1 -1
  58. data/app/events/decidim/initiatives/approve_membership_request_event.rb +16 -13
  59. data/app/events/decidim/initiatives/create_initiative_event.rb +10 -7
  60. data/app/events/decidim/initiatives/endorse_initiative_event.rb +1 -1
  61. data/app/events/decidim/initiatives/extend_initiative_event.rb +1 -1
  62. data/app/events/decidim/initiatives/initiative_sent_to_technical_validation_event.rb +2 -2
  63. data/app/events/decidim/initiatives/milestone_completed_event.rb +1 -1
  64. data/app/events/decidim/initiatives/revoke_membership_request_event.rb +16 -13
  65. data/app/events/decidim/initiatives/spawn_committee_request_event.rb +16 -13
  66. data/app/forms/decidim/initiatives/admin/initiative_form.rb +1 -1
  67. data/app/forms/decidim/initiatives/initiative_form.rb +22 -31
  68. data/app/forms/decidim/initiatives/previous_form.rb +4 -0
  69. data/app/forms/decidim/initiatives/vote_form.rb +11 -11
  70. data/app/helpers/decidim/initiatives/admin/initiatives_helper.rb +1 -1
  71. data/app/helpers/decidim/initiatives/application_helper.rb +5 -62
  72. data/app/helpers/decidim/initiatives/initiative_helper.rb +48 -5
  73. data/app/helpers/decidim/initiatives/initiatives_helper.rb +33 -12
  74. data/app/jobs/decidim/initiatives/export_initiatives_job.rb +1 -1
  75. data/app/models/decidim/initiative.rb +16 -14
  76. data/app/models/decidim/initiatives_vote.rb +1 -1
  77. data/app/packs/entrypoints/decidim_initiatives.js +3 -0
  78. data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_initiatives.svg +42 -1
  79. data/app/packs/src/decidim/initiatives/application.js +0 -1
  80. data/app/packs/src/decidim/initiatives/scoped_type.js +1 -1
  81. data/app/packs/stylesheets/decidim/initiatives/initiatives-votes.scss +21 -21
  82. data/app/packs/stylesheets/decidim/initiatives/print-initiative.scss +47 -35
  83. data/app/packs/stylesheets/initiatives.scss +171 -0
  84. data/app/permissions/decidim/initiatives/permissions.rb +3 -13
  85. data/app/presenters/decidim/initiatives/admin_log/initiative_presenter.rb +2 -2
  86. data/app/presenters/decidim/initiatives/admin_log/initiatives_settings_presenter.rb +2 -2
  87. data/app/presenters/decidim/initiatives/admin_log/initiatives_type_presenter.rb +2 -2
  88. data/app/queries/decidim/initiatives/organization_prioritized_initiatives.rb +1 -1
  89. data/app/queries/decidim/initiatives/similar_initiatives.rb +2 -2
  90. data/app/queries/decidim/initiatives/support_period_finished_initiatives.rb +1 -1
  91. data/app/queries/decidim/initiatives/user_authorizations.rb +1 -1
  92. data/app/services/decidim/initiatives/pdf_signature_example.rb +44 -52
  93. data/app/views/decidim/initiatives/_modal.html.erb +15 -0
  94. data/app/views/decidim/initiatives/admin/answers/_info_initiative.html.erb +21 -19
  95. data/app/views/decidim/initiatives/admin/answers/edit.html.erb +41 -27
  96. data/app/views/decidim/initiatives/admin/committee_requests/index.html.erb +41 -48
  97. data/app/views/decidim/initiatives/admin/exports/_dropdown.html.erb +8 -7
  98. data/app/views/decidim/initiatives/admin/initiatives/_form.html.erb +111 -95
  99. data/app/views/decidim/initiatives/admin/initiatives/_initiative_attachments.erb +7 -7
  100. data/app/views/decidim/initiatives/admin/initiatives/_signatures.html.erb +87 -0
  101. data/app/views/decidim/initiatives/admin/initiatives/edit.html.erb +72 -60
  102. data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.html.erb +8 -0
  103. data/app/views/decidim/initiatives/admin/initiatives/export_pdf_signatures.pdf.erb +5 -78
  104. data/app/views/decidim/initiatives/admin/initiatives/index.html.erb +76 -75
  105. data/app/views/decidim/initiatives/admin/initiatives_settings/_form.html.erb +7 -8
  106. data/app/views/decidim/initiatives/admin/initiatives_settings/edit.html.erb +17 -5
  107. data/app/views/decidim/initiatives/admin/initiatives_type_scopes/_form.html.erb +11 -6
  108. data/app/views/decidim/initiatives/admin/initiatives_type_scopes/edit.html.erb +16 -22
  109. data/app/views/decidim/initiatives/admin/initiatives_type_scopes/new.html.erb +17 -15
  110. data/app/views/decidim/initiatives/admin/initiatives_types/_form.html.erb +93 -76
  111. data/app/views/decidim/initiatives/admin/initiatives_types/_initiative_type_scopes.html.erb +35 -33
  112. data/app/views/decidim/initiatives/admin/initiatives_types/edit.html.erb +16 -12
  113. data/app/views/decidim/initiatives/admin/initiatives_types/index.html.erb +39 -48
  114. data/app/views/decidim/initiatives/admin/initiatives_types/new.html.erb +16 -9
  115. data/app/views/decidim/initiatives/committee_requests/new.html.erb +21 -19
  116. data/app/views/decidim/initiatives/create_initiative/_share_committee_link.html.erb +15 -20
  117. data/app/views/decidim/initiatives/create_initiative/fill_data.html.erb +62 -100
  118. data/app/views/decidim/initiatives/create_initiative/finish.html.erb +24 -28
  119. data/app/views/decidim/initiatives/create_initiative/promotal_committee.html.erb +15 -17
  120. data/app/views/decidim/initiatives/create_initiative/select_initiative_type.html.erb +32 -46
  121. data/app/views/decidim/initiatives/initiative_signatures/_wizard_steps.html.erb +15 -19
  122. data/app/views/decidim/initiatives/initiative_signatures/fill_personal_data.html.erb +25 -36
  123. data/app/views/decidim/initiatives/initiative_signatures/finish.html.erb +5 -16
  124. data/app/views/decidim/initiatives/initiative_signatures/sms_code.html.erb +8 -19
  125. data/app/views/decidim/initiatives/initiative_signatures/sms_phone_number.html.erb +8 -20
  126. data/app/views/decidim/initiatives/initiatives/_committee_members.html.erb +48 -66
  127. data/app/views/decidim/initiatives/initiatives/_form.html.erb +49 -95
  128. data/app/views/decidim/initiatives/initiatives/_initiative_badge.html.erb +3 -5
  129. data/app/views/decidim/initiatives/initiatives/_initiative_hero.html.erb +13 -0
  130. data/app/views/decidim/initiatives/initiatives/_initiatives.html.erb +6 -15
  131. data/app/views/decidim/initiatives/initiatives/_interactions.html.erb +1 -1
  132. data/app/views/decidim/initiatives/initiatives/_new_initiative_button.html.erb +28 -0
  133. data/app/views/decidim/initiatives/initiatives/_progress_bar.html.erb +2 -6
  134. data/app/views/decidim/initiatives/initiatives/_result.html.erb +15 -21
  135. data/app/views/decidim/initiatives/initiatives/_send_to_technical_validation.html.erb +3 -3
  136. data/app/views/decidim/initiatives/initiatives/_tags_type.html.erb +1 -0
  137. data/app/views/decidim/initiatives/initiatives/_vote_button.html.erb +9 -9
  138. data/app/views/decidim/initiatives/initiatives/_vote_cabin.html.erb +7 -7
  139. data/app/views/decidim/initiatives/initiatives/edit.html.erb +63 -68
  140. data/app/views/decidim/initiatives/initiatives/index.html.erb +17 -18
  141. data/app/views/decidim/initiatives/initiatives/index.js.erb +0 -5
  142. data/app/views/decidim/initiatives/initiatives/print.html.erb +123 -120
  143. data/app/views/decidim/initiatives/initiatives/show.html.erb +188 -72
  144. data/app/views/decidim/initiatives/initiatives_mailer/notify_creation.html.erb +2 -2
  145. data/app/views/decidim/initiatives/initiatives_type_scopes/search.html.erb +2 -1
  146. data/app/views/decidim/initiatives/versions/show.html.erb +15 -6
  147. data/app/views/layouts/decidim/_initiative_creation_header.html.erb +17 -28
  148. data/app/views/layouts/decidim/_initiative_header.html.erb +3 -23
  149. data/app/views/layouts/decidim/_initiative_header_steps.html.erb +4 -12
  150. data/app/views/layouts/decidim/_initiative_signature_creation_header.html.erb +5 -26
  151. data/app/views/layouts/decidim/admin/initiative.html.erb +12 -13
  152. data/app/views/layouts/decidim/admin/initiatives.html.erb +40 -11
  153. data/app/views/layouts/decidim/initiative.html.erb +16 -11
  154. data/app/views/layouts/decidim/initiative_creation.html.erb +7 -18
  155. data/app/views/layouts/decidim/initiative_head.html.erb +15 -0
  156. data/app/views/layouts/decidim/initiative_signature_creation.html.erb +3 -11
  157. data/config/assets.rb +0 -1
  158. data/config/initializers/wicked_pdf.rb +1 -1
  159. data/config/locales/ar.yml +1 -96
  160. data/config/locales/bg.yml +0 -642
  161. data/config/locales/ca.yml +76 -115
  162. data/config/locales/cs.yml +70 -109
  163. data/config/locales/de.yml +78 -117
  164. data/config/locales/el.yml +1 -98
  165. data/config/locales/en.yml +69 -108
  166. data/config/locales/es-MX.yml +65 -104
  167. data/config/locales/es-PY.yml +65 -104
  168. data/config/locales/es.yml +73 -112
  169. data/config/locales/eu.yml +66 -105
  170. data/config/locales/fi-plain.yml +67 -106
  171. data/config/locales/fi.yml +68 -107
  172. data/config/locales/fr-CA.yml +69 -108
  173. data/config/locales/fr.yml +67 -106
  174. data/config/locales/ga-IE.yml +0 -35
  175. data/config/locales/gl.yml +1 -89
  176. data/config/locales/hu.yml +25 -114
  177. data/config/locales/id-ID.yml +1 -89
  178. data/config/locales/is-IS.yml +1 -60
  179. data/config/locales/it.yml +6 -111
  180. data/config/locales/ja.yml +65 -111
  181. data/config/locales/lb.yml +6 -88
  182. data/config/locales/lt.yml +52 -103
  183. data/config/locales/lv.yml +1 -99
  184. data/config/locales/nl.yml +6 -104
  185. data/config/locales/no.yml +6 -114
  186. data/config/locales/pl.yml +6 -158
  187. data/config/locales/pt-BR.yml +23 -146
  188. data/config/locales/pt.yml +6 -111
  189. data/config/locales/ro-RO.yml +13 -108
  190. data/config/locales/ru.yml +1 -68
  191. data/config/locales/sk.yml +1 -85
  192. data/config/locales/sl.yml +3 -5
  193. data/config/locales/sv.yml +25 -120
  194. data/config/locales/tr-TR.yml +9 -110
  195. data/config/locales/uk.yml +1 -68
  196. data/config/locales/zh-CN.yml +6 -102
  197. data/config/locales/zh-TW.yml +31 -95
  198. data/db/migrate/20171017091734_add_scopes_for_all_initiative_types.rb +1 -1
  199. data/db/migrate/20171017095143_update_initiative_scoped_type.rb +1 -1
  200. data/db/migrate/20191002082220_move_signature_type_to_initative_type.rb +1 -1
  201. data/lib/decidim/api/initiative_committee_member_type.rb +2 -2
  202. data/lib/decidim/initiatives/admin_engine.rb +13 -93
  203. data/lib/decidim/initiatives/content_blocks/registry_manager.rb +22 -0
  204. data/lib/decidim/initiatives/engine.rb +45 -23
  205. data/lib/decidim/initiatives/menu.rb +150 -0
  206. data/lib/decidim/initiatives/participatory_space.rb +6 -91
  207. data/lib/decidim/initiatives/query_extensions.rb +5 -5
  208. data/lib/decidim/initiatives/seeds.rb +95 -0
  209. data/lib/decidim/initiatives/test/factories.rb +43 -48
  210. data/lib/decidim/initiatives/version.rb +1 -1
  211. data/lib/decidim/initiatives.rb +1 -1
  212. data/lib/tasks/decidim_initiatives.rake +2 -2
  213. data/lib/tasks/initiatives/upgrade/decidim_initiatives_upgrade_tasks.rake +1 -1
  214. metadata +51 -81
  215. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +0 -28
  216. data/app/cells/decidim/initiatives/initiative_m/author.erb +0 -10
  217. data/app/cells/decidim/initiatives/initiative_m/footer.erb +0 -28
  218. data/app/cells/decidim/initiatives/initiative_m/tags.erb +0 -9
  219. data/app/cells/decidim/initiatives/initiative_m_cell.rb +0 -77
  220. data/app/controllers/decidim/initiatives/widgets_controller.rb +0 -44
  221. data/app/packs/stylesheets/decidim/initiatives/admin.scss +0 -33
  222. data/app/packs/stylesheets/decidim/initiatives/initiatives.scss +0 -64
  223. data/app/packs/stylesheets/decidim/initiatives/popularity_item.scss +0 -76
  224. data/app/packs/stylesheets/decidim/initiatives/statistics.scss +0 -15
  225. data/app/views/decidim/initiatives/create_initiative/_finish_help.html.erb +0 -2
  226. data/app/views/decidim/initiatives/create_initiative/previous_form.html.erb +0 -40
  227. data/app/views/decidim/initiatives/create_initiative/show_similar_initiatives.html.erb +0 -23
  228. data/app/views/decidim/initiatives/initiatives/_author.html.erb +0 -35
  229. data/app/views/decidim/initiatives/initiatives/_count.html.erb +0 -1
  230. data/app/views/decidim/initiatives/initiatives/_filters.html.erb +0 -33
  231. data/app/views/decidim/initiatives/initiatives/_filters_small_view.html.erb +0 -18
  232. data/app/views/decidim/initiatives/initiatives/_index_header.html.erb +0 -44
  233. data/app/views/decidim/initiatives/initiatives/_tags.html.erb +0 -7
  234. data/app/views/decidim/initiatives/versions/index.html.erb +0 -8
  235. data/config/locales/he-IL.yml +0 -1
  236. data/db/seeds/city.jpeg +0 -0
  237. data/db/seeds/city2.jpeg +0 -0
  238. data/decidim-initiatives.gemspec +0 -38
  239. data/lib/decidim/initiatives/initiatives_filter_form_builder.rb +0 -56
  240. data/lib/gem_overrides/origami/date.rb +0 -47
@@ -0,0 +1,150 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ class Menu
6
+ def self.register_menu!
7
+ Decidim.menu :menu do |menu|
8
+ menu.add_item :initiatives,
9
+ I18n.t("menu.initiatives", scope: "decidim"),
10
+ decidim_initiatives.initiatives_path,
11
+ position: 2.4,
12
+ active: %r{^/(initiatives|create_initiative)},
13
+ if: !Decidim::InitiativesType.joins(:scopes).where(organization: current_organization).all.empty?
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 :initiatives,
20
+ I18n.t("menu.initiatives", scope: "decidim"),
21
+ decidim_initiatives.initiatives_path,
22
+ position: 30,
23
+ active: :inclusive,
24
+ if: !Decidim::InitiativesType.joins(:scopes).where(organization: current_organization).all.empty?
25
+ end
26
+ end
27
+
28
+ def self.register_admin_menu_modules!
29
+ Decidim.menu :admin_menu_modules do |menu|
30
+ menu.add_item :initiatives,
31
+ I18n.t("menu.initiatives", scope: "decidim.admin"),
32
+ decidim_admin_initiatives.initiatives_path,
33
+ icon_name: "lightbulb-flash-line",
34
+ position: 2.4,
35
+ active: is_active_link?(decidim_admin_initiatives.initiatives_path) ||
36
+ is_active_link?(decidim_admin_initiatives.initiatives_types_path) ||
37
+ is_active_link?(
38
+ decidim_admin_initiatives.edit_initiatives_setting_path(
39
+ Decidim::InitiativesSettings.find_or_create_by!(organization: current_organization)
40
+ )
41
+ ),
42
+ if: allowed_to?(:enter, :space_area, space_name: :initiatives)
43
+ end
44
+ end
45
+
46
+ def self.register_admin_initiatives_components_menu!
47
+ Decidim.menu :admin_initiatives_components_menu do |menu|
48
+ current_participatory_space.components.each do |component|
49
+ caption = translated_attribute(component.name)
50
+ if component.primary_stat.present?
51
+ caption += content_tag(:span, component.primary_stat,
52
+ class: component.primary_stat.zero? ? "component-counter component-counter--off" : "component-counter")
53
+ end
54
+
55
+ menu.add_item [component.manifest_name, component.id].join("_"),
56
+ caption.html_safe,
57
+ manage_component_path(component),
58
+ active: is_active_link?(manage_component_path(component)) ||
59
+ is_active_link?(decidim_admin_initiatives.edit_component_path(current_participatory_space, component)) ||
60
+ is_active_link?(decidim_admin_initiatives.edit_component_permissions_path(current_participatory_space, component)) ||
61
+ participatory_space_active_link?(component),
62
+ if: component.manifest.admin_engine # && user_role_config.component_is_accessible?(component.manifest_name)
63
+ end
64
+ end
65
+ end
66
+
67
+ def self.register_admin_initiative_menu!
68
+ Decidim.menu :admin_initiative_menu do |menu|
69
+ menu.add_item :edit_initiative,
70
+ I18n.t("menu.information", scope: "decidim.admin"),
71
+ decidim_admin_initiatives.edit_initiative_path(current_participatory_space),
72
+ icon_name: "information-line",
73
+ if: allowed_to?(:edit, :initiative, initiative: current_participatory_space)
74
+
75
+ menu.add_item :initiative_committee_requests,
76
+ I18n.t("menu.committee_members", scope: "decidim.admin"),
77
+ decidim_admin_initiatives.initiative_committee_requests_path(current_participatory_space),
78
+ icon_name: "group-line",
79
+ if: current_participatory_space.promoting_committee_enabled? && allowed_to?(:manage_membership, :initiative,
80
+ initiative: current_participatory_space)
81
+
82
+ menu.add_item :components,
83
+ I18n.t("menu.components", scope: "decidim.admin"),
84
+ decidim_admin_initiatives.components_path(current_participatory_space),
85
+ icon_name: "tools-line",
86
+ active: is_active_link?(decidim_admin_initiatives.components_path(current_participatory_space),
87
+ ["decidim/initiatives/admin/components", %w(index new edit)]),
88
+ if: allowed_to?(:read, :component, initiative: current_participatory_space),
89
+ submenu: { target_menu: :admin_initiatives_components_menu }
90
+ menu.add_item :initiative_attachments,
91
+ I18n.t("menu.attachments", scope: "decidim.admin"),
92
+ decidim_admin_initiatives.initiative_attachments_path(current_participatory_space),
93
+ icon_name: "attachment-2",
94
+ if: allowed_to?(:read, :attachment, initiative: current_participatory_space)
95
+
96
+ menu.add_item :moderations,
97
+ I18n.t("menu.moderations", scope: "decidim.admin"),
98
+ decidim_admin_initiatives.moderations_path(current_participatory_space),
99
+ icon_name: "flag-line",
100
+ if: allowed_to?(:read, :moderation)
101
+ end
102
+ end
103
+
104
+ def self.register_admin_initiative_actions_menu!
105
+ Decidim.menu :admin_initiative_actions_menu do |menu|
106
+ menu.add_item :answer_initiative,
107
+ I18n.t("actions.answer", scope: "decidim.initiatives"),
108
+ decidim_admin_initiatives.edit_initiative_answer_path(current_participatory_space),
109
+ if: allowed_to?(:answer, :initiative, initiative: current_participatory_space)
110
+
111
+ menu.add_item :initiative_permissions,
112
+ I18n.t("actions.permissions", scope: "decidim.admin"),
113
+ decidim_admin_initiatives.edit_initiative_permissions_path(current_participatory_space, resource_name: :initiative),
114
+ if: current_participatory_space.allow_resource_permissions? && allowed_to?(:update, :initiative, initiative: current_participatory_space)
115
+ end
116
+ end
117
+
118
+ def self.register_admin_initiatives_menu!
119
+ Decidim.menu :admin_initiatives_menu do |menu|
120
+ menu.add_item :initiatives,
121
+ I18n.t("menu.initiatives", scope: "decidim.admin"),
122
+ decidim_admin_initiatives.initiatives_path,
123
+ position: 1.0,
124
+ active: is_active_link?(decidim_admin_initiatives.initiatives_path),
125
+ if: allowed_to?(:index, :initiative)
126
+
127
+ menu.add_item :initiatives_types,
128
+ I18n.t("menu.initiatives_types", scope: "decidim.admin"),
129
+ decidim_admin_initiatives.initiatives_types_path,
130
+ active: is_active_link?(decidim_admin_initiatives.initiatives_types_path),
131
+ if: allowed_to?(:manage, :initiative_type)
132
+
133
+ menu.add_item :initiatives_settings,
134
+ I18n.t("menu.initiatives_settings", scope: "decidim.admin"),
135
+ decidim_admin_initiatives.edit_initiatives_setting_path(
136
+ Decidim::InitiativesSettings.find_or_create_by!(
137
+ organization: current_organization
138
+ )
139
+ ),
140
+ active: is_active_link?(
141
+ decidim_admin_initiatives.edit_initiatives_setting_path(
142
+ Decidim::InitiativesSettings.find_or_create_by!(organization: current_organization)
143
+ )
144
+ ),
145
+ if: allowed_to?(:update, :initiatives_settings)
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end
@@ -15,11 +15,13 @@ Decidim.register_participatory_space(:initiatives) do |participatory_space|
15
15
  end
16
16
 
17
17
  participatory_space.participatory_spaces do |organization|
18
- Decidim::Initiative.where(organization: organization)
18
+ Decidim::Initiative.where(organization:)
19
19
  end
20
20
 
21
21
  participatory_space.query_type = "Decidim::Initiatives::InitiativeType"
22
22
 
23
+ participatory_space.breadcrumb_cell = "decidim/initiatives/initiative_dropdown_metadata"
24
+
23
25
  participatory_space.register_resource(:initiative) do |resource|
24
26
  resource.actions = %w(comment)
25
27
  resource.permissions_class_name = "Decidim::Initiatives::Permissions"
@@ -30,7 +32,7 @@ Decidim.register_participatory_space(:initiatives) do |participatory_space|
30
32
 
31
33
  participatory_space.register_resource(:initiatives_type) do |resource|
32
34
  resource.model_class_name = "Decidim::InitiativesType"
33
- resource.actions = %w(vote)
35
+ resource.actions = %w(vote create)
34
36
  end
35
37
 
36
38
  participatory_space.model_class_name = "Decidim::Initiative"
@@ -45,95 +47,8 @@ Decidim.register_participatory_space(:initiatives) do |participatory_space|
45
47
  end
46
48
 
47
49
  participatory_space.seeds do
48
- seeds_root = File.join(__dir__, "..", "..", "..", "db", "seeds")
49
- organization = Decidim::Organization.first
50
-
51
- Decidim::ContentBlock.create(
52
- organization: organization,
53
- weight: 33,
54
- scope_name: :homepage,
55
- manifest_name: :highlighted_initiatives,
56
- published_at: Time.current
57
- )
58
-
59
- 3.times do |n|
60
- type = Decidim::InitiativesType.create!(
61
- title: Decidim::Faker::Localized.sentence(word_count: 5),
62
- description: Decidim::Faker::Localized.sentence(word_count: 25),
63
- organization: organization,
64
- banner_image: ActiveStorage::Blob.create_and_upload!(
65
- io: File.open(File.join(seeds_root, "city2.jpeg")),
66
- filename: "banner_image.jpeg",
67
- content_type: "image/jpeg",
68
- metadata: nil
69
- )
70
- )
71
-
72
- organization.top_scopes.each do |scope|
73
- Decidim::InitiativesTypeScope.create(
74
- type: type,
75
- scope: scope,
76
- supports_required: (n + 1) * 1000
77
- )
78
- end
79
- end
80
-
81
- Decidim::Initiative.states.keys.each do |state|
82
- Decidim::Initiative.skip_callback(:save, :after, :notify_state_change, raise: false)
83
- Decidim::Initiative.skip_callback(:create, :after, :notify_creation, raise: false)
84
-
85
- params = {
86
- title: Decidim::Faker::Localized.sentence(word_count: 3),
87
- description: Decidim::Faker::Localized.sentence(word_count: 25),
88
- scoped_type: Decidim::InitiativesTypeScope.reorder(Arel.sql("RANDOM()")).first,
89
- state: state,
90
- signature_type: "online",
91
- signature_start_date: Date.current - 7.days,
92
- signature_end_date: Date.current + 7.days,
93
- published_at: 7.days.ago,
94
- author: Decidim::User.reorder(Arel.sql("RANDOM()")).first,
95
- organization: organization
96
- }
50
+ require "decidim/initiatives/seeds"
97
51
 
98
- initiative = Decidim.traceability.perform_action!(
99
- "publish",
100
- Decidim::Initiative,
101
- organization.users.first,
102
- visibility: "all"
103
- ) do
104
- Decidim::Initiative.create!(params)
105
- end
106
- initiative.add_to_index_as_search_resource
107
-
108
- Decidim::Comments::Seed.comments_for(initiative)
109
-
110
- Decidim::Attachment.create!(
111
- title: Decidim::Faker::Localized.sentence(word_count: 2),
112
- description: Decidim::Faker::Localized.sentence(word_count: 5),
113
- attached_to: initiative,
114
- content_type: "image/jpeg",
115
- file: ActiveStorage::Blob.create_and_upload!(
116
- io: File.open(File.join(seeds_root, "city.jpeg")),
117
- filename: "city.jpeg",
118
- content_type: "image/jpeg",
119
- metadata: nil
120
- )
121
- )
122
-
123
- Decidim::Initiatives.default_components.each do |component_name|
124
- component = Decidim::Component.create!(
125
- name: Decidim::Components::Namer.new(initiative.organization.available_locales, component_name).i18n_name,
126
- manifest_name: component_name,
127
- published_at: Time.current,
128
- participatory_space: initiative
129
- )
130
-
131
- next unless component_name.in? ["pages", :pages]
132
-
133
- Decidim::Pages::CreatePage.call(component) do
134
- on(:invalid) { raise "Can't create page" }
135
- end
136
- end
137
- end
52
+ Decidim::Initiatives::Seeds.new.call
138
53
  end
139
54
  end
@@ -15,7 +15,7 @@ module Decidim
15
15
  description "Lists all initiative types"
16
16
  end
17
17
 
18
- type.field :initiatives_type, InitiativeApiType, null: true, description: "Finds a initiative type" do
18
+ type.field :initiatives_type, InitiativeApiType, null: true, description: "Finds an initiative type" do
19
19
  argument :id, GraphQL::Types::ID, "The ID of the initiative type", required: true
20
20
  end
21
21
 
@@ -30,7 +30,7 @@ module Decidim
30
30
  type.field :initiative,
31
31
  Decidim::Initiatives::InitiativeType,
32
32
  null: true,
33
- description: "Finds a initiative" do
33
+ description: "Finds an initiative" do
34
34
  argument :id, GraphQL::Types::ID, "The ID of the participatory space", required: false
35
35
  end
36
36
  end
@@ -44,19 +44,19 @@ module Decidim
44
44
  def initiatives_type(id:)
45
45
  Decidim::InitiativesType.find_by(
46
46
  organization: context[:current_organization],
47
- id: id
47
+ id:
48
48
  )
49
49
  end
50
50
 
51
51
  def initiatives(filter: {}, order: {})
52
52
  manifest = Decidim.participatory_space_manifests.select { |m| m.name == :initiatives }.first
53
- Decidim::Core::ParticipatorySpaceListBase.new(manifest: manifest).call(object, { filter: filter, order: order }, context)
53
+ Decidim::Core::ParticipatorySpaceListBase.new(manifest:).call(object, { filter:, order: }, context)
54
54
  end
55
55
 
56
56
  def initiative(id: nil)
57
57
  manifest = Decidim.participatory_space_manifests.select { |m| m.name == :initiatives }.first
58
58
 
59
- Decidim::Core::ParticipatorySpaceFinderBase.new(manifest: manifest).call(object, { id: id }, context)
59
+ Decidim::Core::ParticipatorySpaceFinderBase.new(manifest:).call(object, { id: }, context)
60
60
  end
61
61
  end
62
62
  end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/components/namer"
4
+ require "decidim/seeds"
5
+
6
+ module Decidim
7
+ module Initiatives
8
+ class Seeds < Decidim::Seeds
9
+ def call
10
+ organization = Decidim::Organization.first
11
+
12
+ Decidim::ContentBlock.create(
13
+ organization:,
14
+ weight: 33,
15
+ scope_name: :homepage,
16
+ manifest_name: :highlighted_initiatives,
17
+ published_at: Time.current
18
+ )
19
+
20
+ 3.times do |n|
21
+ type = Decidim::InitiativesType.create!(
22
+ title: Decidim::Faker::Localized.sentence(word_count: 5),
23
+ description: Decidim::Faker::Localized.sentence(word_count: 25),
24
+ organization:,
25
+ banner_image: ::Faker::Boolean.boolean(true_ratio: 0.5) ? banner_image : nil # Keep after organization
26
+ )
27
+
28
+ organization.top_scopes.each do |scope|
29
+ Decidim::InitiativesTypeScope.create(
30
+ type:,
31
+ scope:,
32
+ supports_required: (n + 1) * 1000
33
+ )
34
+ end
35
+ end
36
+
37
+ Decidim::Initiative.states.keys.each do |state|
38
+ Decidim::Initiative.skip_callback(:save, :after, :notify_state_change, raise: false)
39
+ Decidim::Initiative.skip_callback(:create, :after, :notify_creation, raise: false)
40
+
41
+ params = {
42
+ title: Decidim::Faker::Localized.sentence(word_count: 3),
43
+ description: Decidim::Faker::Localized.sentence(word_count: 25),
44
+ scoped_type: Decidim::InitiativesTypeScope.all.sample,
45
+ state:,
46
+ signature_type: "online",
47
+ signature_start_date: Date.current - 7.days,
48
+ signature_end_date: Date.current + 7.days,
49
+ published_at: 7.days.ago,
50
+ author: Decidim::User.all.sample,
51
+ organization:
52
+ }
53
+
54
+ initiative = Decidim.traceability.perform_action!(
55
+ "publish",
56
+ Decidim::Initiative,
57
+ organization.users.first,
58
+ visibility: "all"
59
+ ) do
60
+ Decidim::Initiative.create!(params)
61
+ end
62
+ initiative.add_to_index_as_search_resource
63
+
64
+ if %w(published rejected accepted).include? state
65
+ users = []
66
+ rand(50).times do
67
+ author = (Decidim::User.all - users).sample
68
+ initiative.votes.create!(author:, scope: initiative.scope, hash_id: SecureRandom.hex)
69
+ users << author
70
+ end
71
+ end
72
+
73
+ Decidim::Comments::Seed.comments_for(initiative)
74
+
75
+ create_attachment(attached_to: initiative, filename: "city.jpeg")
76
+
77
+ Decidim::Initiatives.default_components.each do |component_name|
78
+ component = Decidim::Component.create!(
79
+ name: Decidim::Components::Namer.new(initiative.organization.available_locales, component_name).i18n_name,
80
+ manifest_name: component_name,
81
+ published_at: Time.current,
82
+ participatory_space: initiative
83
+ )
84
+
85
+ next unless component_name.in? ["pages", :pages]
86
+
87
+ Decidim::Pages::CreatePage.call(component) do
88
+ on(:invalid) { raise "Cannot create page" }
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -5,11 +5,8 @@ require "decidim/dev"
5
5
 
6
6
  FactoryBot.define do
7
7
  factory :initiatives_type, class: "Decidim::InitiativesType" do
8
- transient do
9
- skip_injection { false }
10
- end
11
- title { generate_localized_title(:initiatives_type_title, skip_injection: skip_injection) }
12
- description { generate_localized_description(:initiatives_type_description, skip_injection: skip_injection) }
8
+ title { generate_localized_title }
9
+ description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
13
10
  organization
14
11
  # Keep banner_image after organization
15
12
  banner_image do
@@ -85,7 +82,7 @@ FactoryBot.define do
85
82
 
86
83
  trait :with_user_extra_fields_collection do
87
84
  collect_user_extra_fields { true }
88
- extra_fields_legal_information { generate_localized_description(:initiatives_type_extra_fields_legal_information, skip_injection: skip_injection) }
85
+ extra_fields_legal_information { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
89
86
  document_number_authorization_handler { "dummy_authorization_handler" }
90
87
  end
91
88
 
@@ -103,15 +100,12 @@ FactoryBot.define do
103
100
  end
104
101
 
105
102
  factory :initiatives_type_scope, class: "Decidim::InitiativesTypeScope" do
106
- transient do
107
- skip_injection { false }
108
- end
109
- type { create(:initiatives_type, skip_injection: skip_injection) }
110
- scope { create(:scope, organization: type.organization, skip_injection: skip_injection) }
103
+ type { create(:initiatives_type) }
104
+ scope { create(:scope, organization: type.organization) }
111
105
  supports_required { 1000 }
112
106
 
113
107
  trait :with_user_extra_fields_collection do
114
- type { create(:initiatives_type, :with_user_extra_fields_collection, skip_injection: skip_injection) }
108
+ type { create(:initiatives_type, :with_user_extra_fields_collection) }
115
109
  end
116
110
  end
117
111
 
@@ -119,10 +113,25 @@ FactoryBot.define do
119
113
  transient do
120
114
  skip_injection { false }
121
115
  end
122
- title { generate_localized_title(:initiative_title, skip_injection: skip_injection) }
123
- description { generate_localized_description(:initiative_description, skip_injection: skip_injection) }
116
+
117
+ title do
118
+ if skip_injection
119
+ Decidim::Faker::Localized.localized { generate(:title) }
120
+ else
121
+ Decidim::Faker::Localized.localized { "<script>alert(\"Initiative TITLE\")</script> #{generate(:title)}" }
122
+ end
123
+ end
124
+ description do
125
+ Decidim::Faker::Localized.wrapped("<p>", "</p>") do
126
+ if skip_injection
127
+ Decidim::Faker::Localized.localized { generate(:title) }
128
+ else
129
+ Decidim::Faker::Localized.localized { "<script>alert(\"Meetings description\");</script> #{generate(:title)}" }
130
+ end
131
+ end
132
+ end
124
133
  organization
125
- author { create(:user, :confirmed, organization: organization, skip_injection: skip_injection) }
134
+ author { create(:user, :confirmed, organization:) }
126
135
  published_at { Time.current }
127
136
  state { "published" }
128
137
  signature_type { "online" }
@@ -130,15 +139,15 @@ FactoryBot.define do
130
139
  signature_end_date { Date.current + 120.days }
131
140
 
132
141
  scoped_type do
133
- create(:initiatives_type_scope, skip_injection: skip_injection,
134
- type: create(:initiatives_type, organization: organization, signature_type: signature_type, skip_injection: skip_injection))
142
+ create(:initiatives_type_scope,
143
+ type: create(:initiatives_type, organization:, signature_type:))
135
144
  end
136
145
 
137
- after(:create) do |initiative, evaluator|
146
+ after(:create) do |initiative|
138
147
  if initiative.author.is_a?(Decidim::User) && Decidim::Authorization.where(user: initiative.author).where.not(granted_at: nil).none?
139
- create(:authorization, user: initiative.author, granted_at: Time.now.utc, skip_injection: evaluator.skip_injection)
148
+ create(:authorization, user: initiative.author, granted_at: Time.now.utc)
140
149
  end
141
- create_list(:initiatives_committee_member, 3, initiative: initiative, skip_injection: evaluator.skip_injection)
150
+ create_list(:initiatives_committee_member, 3, initiative:)
142
151
  end
143
152
 
144
153
  trait :created do
@@ -207,13 +216,13 @@ FactoryBot.define do
207
216
 
208
217
  trait :with_user_extra_fields_collection do
209
218
  scoped_type do
210
- create(:initiatives_type_scope, skip_injection: skip_injection,
211
- type: create(:initiatives_type, :with_user_extra_fields_collection, organization: organization, skip_injection: skip_injection))
219
+ create(:initiatives_type_scope,
220
+ type: create(:initiatives_type, :with_user_extra_fields_collection, organization:))
212
221
  end
213
222
  end
214
223
 
215
224
  trait :with_area do
216
- area { create(:area, organization: organization, skip_injection: skip_injection) }
225
+ area { create(:area, organization:) }
217
226
  end
218
227
 
219
228
  trait :with_documents do
@@ -226,8 +235,7 @@ FactoryBot.define do
226
235
  initiative.attachments << create(
227
236
  :attachment,
228
237
  :with_pdf,
229
- attached_to: initiative,
230
- skip_injection: evaluator.skip_injection
238
+ attached_to: initiative
231
239
  )
232
240
  end
233
241
  end
@@ -243,8 +251,7 @@ FactoryBot.define do
243
251
  initiative.attachments << create(
244
252
  :attachment,
245
253
  :with_image,
246
- attached_to: initiative,
247
- skip_injection: evaluator.skip_injection
254
+ attached_to: initiative
248
255
  )
249
256
  end
250
257
  end
@@ -252,11 +259,8 @@ FactoryBot.define do
252
259
  end
253
260
 
254
261
  factory :initiative_user_vote, class: "Decidim::InitiativesVote" do
255
- transient do
256
- skip_injection { false }
257
- end
258
- initiative { create(:initiative, skip_injection: skip_injection) }
259
- author { create(:user, :confirmed, organization: initiative.organization, skip_injection: skip_injection) }
262
+ initiative { create(:initiative) }
263
+ author { create(:user, :confirmed, organization: initiative.organization) }
260
264
  hash_id { SecureRandom.uuid }
261
265
  scope { initiative.scope }
262
266
  after(:create) do |vote|
@@ -265,23 +269,17 @@ FactoryBot.define do
265
269
  end
266
270
 
267
271
  factory :organization_user_vote, class: "Decidim::InitiativesVote" do
268
- transient do
269
- skip_injection { false }
270
- end
271
- initiative { create(:initiative, skip_injection: skip_injection) }
272
- author { create(:user, :confirmed, organization: initiative.organization, skip_injection: skip_injection) }
273
- decidim_user_group_id { create(:user_group, skip_injection: skip_injection).id }
274
- after(:create) do |support, evaluator|
275
- create(:user_group_membership, user: support.author, user_group: Decidim::UserGroup.find(support.decidim_user_group_id), skip_injection: evaluator.skip_injection)
272
+ initiative { create(:initiative) }
273
+ author { create(:user, :confirmed, organization: initiative.organization) }
274
+ decidim_user_group_id { create(:user_group).id }
275
+ after(:create) do |support|
276
+ create(:user_group_membership, user: support.author, user_group: Decidim::UserGroup.find(support.decidim_user_group_id))
276
277
  end
277
278
  end
278
279
 
279
280
  factory :initiatives_committee_member, class: "Decidim::InitiativesCommitteeMember" do
280
- transient do
281
- skip_injection { false }
282
- end
283
- initiative { create(:initiative, skip_injection: skip_injection) }
284
- user { create(:user, :confirmed, organization: initiative.organization, skip_injection: skip_injection) }
281
+ initiative { create(:initiative) }
282
+ user { create(:user, :confirmed, organization: initiative.organization) }
285
283
  state { "accepted" }
286
284
 
287
285
  trait :accepted do
@@ -298,9 +296,6 @@ FactoryBot.define do
298
296
  end
299
297
 
300
298
  factory :initiatives_settings, class: "Decidim::InitiativesSettings" do
301
- transient do
302
- skip_injection { false }
303
- end
304
299
  initiatives_order { "random" }
305
300
  organization
306
301
 
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-initiatives version.
5
5
  module Initiatives
6
6
  def self.version
7
- "0.27.10"
7
+ "0.28.0.rc4"
8
8
  end
9
9
  end
10
10
  end
@@ -75,7 +75,7 @@ module Decidim
75
75
  # a printed version of the initiative from the administration
76
76
  # panel.
77
77
  config_accessor :print_enabled do
78
- true
78
+ false
79
79
  end
80
80
 
81
81
  # Set a service to generate a timestamp on each vote. The
@@ -26,7 +26,7 @@ namespace :decidim_initiatives do
26
26
  .where.not(first_progress_notification_at: nil)
27
27
  .where(second_progress_notification_at: nil).find_each do |initiative|
28
28
  if initiative.percentage >= Decidim::Initiatives.second_notification_percentage
29
- notifier = Decidim::Initiatives::ProgressNotifier.new(initiative: initiative)
29
+ notifier = Decidim::Initiatives::ProgressNotifier.new(initiative:)
30
30
  notifier.notify
31
31
 
32
32
  initiative.second_progress_notification_at = Time.now.utc
@@ -38,7 +38,7 @@ namespace :decidim_initiatives do
38
38
  .published
39
39
  .where(first_progress_notification_at: nil).find_each do |initiative|
40
40
  if initiative.percentage >= Decidim::Initiatives.first_notification_percentage
41
- notifier = Decidim::Initiatives::ProgressNotifier.new(initiative: initiative)
41
+ notifier = Decidim::Initiatives::ProgressNotifier.new(initiative:)
42
42
  notifier.notify
43
43
 
44
44
  initiative.first_progress_notification_at = Time.now.utc
@@ -7,7 +7,7 @@ namespace :decidim do
7
7
  task fix_broken_pages: :environment do
8
8
  Decidim::Initiative.find_each do |initiative|
9
9
  initiative.components.where(manifest_name: "pages").each do |component|
10
- next unless Decidim::Pages::Page.where(component: component).empty?
10
+ next unless Decidim::Pages::Page.where(component:).empty?
11
11
 
12
12
  Decidim::Pages::CreatePage.call(component) do
13
13
  on(:invalid) { raise "Cannot create page" }