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
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
@@ -1,40 +1,43 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
5
- class ApproveMembershipRequestEvent < Decidim::Events::SimpleEvent
5
+ class ApproveMembershipRequestEvent < Decidim::Events::BaseEvent
6
+ include Decidim::Events::EmailEvent
7
+ include Decidim::Events::NotificationEvent
8
+
6
9
  def email_subject
7
10
  I18n.t(
8
11
  "decidim.initiatives.events.approve_membership_request.email_subject",
9
- author_nickname: author_nickname
12
+ author_nickname:
10
13
  )
11
14
  end
12
15
 
13
16
  def email_intro
14
17
  I18n.t(
15
18
  "decidim.initiatives.events.approve_membership_request.email_intro",
16
- resource_title: resource_title,
17
- resource_url: resource_url,
18
- author_profile_url: author_profile_url,
19
- author_nickname: author_nickname
19
+ resource_title:,
20
+ resource_url:,
21
+ author_profile_url:,
22
+ author_nickname:
20
23
  )
21
24
  end
22
25
 
23
26
  def email_outro
24
27
  I18n.t(
25
28
  "decidim.initiatives.events.approve_membership_request.email_outro",
26
- resource_title: resource_title,
27
- resource_url: resource_url
29
+ resource_title:,
30
+ resource_url:
28
31
  )
29
32
  end
30
33
 
31
34
  def notification_title
32
35
  I18n.t(
33
36
  "decidim.initiatives.events.approve_membership_request.notification_title",
34
- resource_title: resource_title,
35
- resource_url: resource_url,
36
- author_profile_url: author_profile_url,
37
- author_nickname: author_nickname
37
+ resource_title:,
38
+ resource_url:,
39
+ author_profile_url:,
40
+ author_nickname:
38
41
  ).html_safe
39
42
  end
40
43
 
@@ -1,12 +1,15 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
5
- class CreateInitiativeEvent < Decidim::Events::SimpleEvent
5
+ class CreateInitiativeEvent < Decidim::Events::BaseEvent
6
+ include Decidim::Events::EmailEvent
7
+ include Decidim::Events::NotificationEvent
8
+
6
9
  def email_subject
7
10
  I18n.t(
8
11
  "decidim.initiatives.events.create_initiative_event.email_subject",
9
- resource_title: resource_title,
12
+ resource_title:,
10
13
  author_nickname: author.nickname,
11
14
  author_name: author.name
12
15
  )
@@ -15,7 +18,7 @@ module Decidim
15
18
  def email_intro
16
19
  I18n.t(
17
20
  "decidim.initiatives.events.create_initiative_event.email_intro",
18
- resource_title: resource_title,
21
+ resource_title:,
19
22
  author_nickname: author.nickname,
20
23
  author_name: author.name
21
24
  )
@@ -24,7 +27,7 @@ module Decidim
24
27
  def email_outro
25
28
  I18n.t(
26
29
  "decidim.initiatives.events.create_initiative_event.email_outro",
27
- resource_title: resource_title,
30
+ resource_title:,
28
31
  author_nickname: author.nickname,
29
32
  author_name: author.name
30
33
  )
@@ -33,8 +36,8 @@ module Decidim
33
36
  def notification_title
34
37
  I18n.t(
35
38
  "decidim.initiatives.events.create_initiative_event.notification_title",
36
- resource_title: resource_title,
37
- resource_path: resource_path,
39
+ resource_title:,
40
+ resource_path:,
38
41
  author_nickname: author.nickname,
39
42
  author_name: author.name,
40
43
  author_path: author.profile_path
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
@@ -12,7 +12,7 @@ module Decidim
12
12
  end
13
13
 
14
14
  def admin_initiative_url
15
- EngineRouter.admin_proxy(resource).edit_initiative_url(resource)
15
+ decidim_admin_initiatives.edit_initiative_url(resource, resource.mounted_params)
16
16
  end
17
17
  end
18
18
  end
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
@@ -1,40 +1,43 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
5
- class RevokeMembershipRequestEvent < Decidim::Events::SimpleEvent
5
+ class RevokeMembershipRequestEvent < Decidim::Events::BaseEvent
6
+ include Decidim::Events::EmailEvent
7
+ include Decidim::Events::NotificationEvent
8
+
6
9
  def email_subject
7
10
  I18n.t(
8
11
  "decidim.initiatives.events.revoke_membership_request.email_subject",
9
- author_nickname: author_nickname
12
+ author_nickname:
10
13
  )
11
14
  end
12
15
 
13
16
  def email_intro
14
17
  I18n.t(
15
18
  "decidim.initiatives.events.revoke_membership_request.email_intro",
16
- resource_title: resource_title,
17
- resource_url: resource_url,
18
- author_profile_url: author_profile_url,
19
- author_nickname: author_nickname
19
+ resource_title:,
20
+ resource_url:,
21
+ author_profile_url:,
22
+ author_nickname:
20
23
  )
21
24
  end
22
25
 
23
26
  def email_outro
24
27
  I18n.t(
25
28
  "decidim.initiatives.events.revoke_membership_request.email_outro",
26
- resource_title: resource_title,
27
- resource_url: resource_url
29
+ resource_title:,
30
+ resource_url:
28
31
  )
29
32
  end
30
33
 
31
34
  def notification_title
32
35
  I18n.t(
33
36
  "decidim.initiatives.events.revoke_membership_request.notification_title",
34
- resource_title: resource_title,
35
- resource_url: resource_url,
36
- author_profile_url: author_profile_url,
37
- author_nickname: author_nickname
37
+ resource_title:,
38
+ resource_url:,
39
+ author_profile_url:,
40
+ author_nickname:
38
41
  ).html_safe
39
42
  end
40
43
 
@@ -1,40 +1,43 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
5
- class SpawnCommitteeRequestEvent < Decidim::Events::SimpleEvent
5
+ class SpawnCommitteeRequestEvent < Decidim::Events::BaseEvent
6
+ include Decidim::Events::EmailEvent
7
+ include Decidim::Events::NotificationEvent
8
+
6
9
  def email_subject
7
10
  I18n.t(
8
11
  "decidim.initiatives.events.spawn_committee_request_event.email_subject",
9
- applicant_nickname: applicant_nickname
12
+ applicant_nickname:
10
13
  )
11
14
  end
12
15
 
13
16
  def email_intro
14
17
  I18n.t(
15
18
  "decidim.initiatives.events.spawn_committee_request_event.email_intro",
16
- resource_title: resource_title,
17
- resource_url: resource_url,
18
- applicant_profile_url: applicant_profile_url,
19
- applicant_nickname: applicant_nickname
19
+ resource_title:,
20
+ resource_url:,
21
+ applicant_profile_url:,
22
+ applicant_nickname:
20
23
  )
21
24
  end
22
25
 
23
26
  def email_outro
24
27
  I18n.t(
25
28
  "decidim.initiatives.events.spawn_committee_request_event.email_outro",
26
- resource_title: resource_title,
27
- resource_url: resource_url
29
+ resource_title:,
30
+ resource_url:
28
31
  )
29
32
  end
30
33
 
31
34
  def notification_title
32
35
  I18n.t(
33
36
  "decidim.initiatives.events.spawn_committee_request_event.notification_title",
34
- resource_title: resource_title,
35
- resource_url: resource_url,
36
- applicant_profile_url: applicant_profile_url,
37
- applicant_nickname: applicant_nickname
37
+ resource_title:,
38
+ resource_url:,
39
+ applicant_profile_url:,
40
+ applicant_nickname:
38
41
  ).html_safe
39
42
  end
40
43
 
@@ -95,7 +95,7 @@ module Decidim
95
95
  @type ||= type_id ? Decidim::InitiativesType.find(type_id) : context.initiative.type
96
96
  end
97
97
 
98
- # This method will add an error to the `attachment` field only if there's
98
+ # This method will add an error to the `attachment` field only if there is
99
99
  # any error in any other field. This is needed because when the form has
100
100
  # an error, the attachment is lost, so we need a way to inform the user of
101
101
  # this problem.
@@ -3,16 +3,12 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  # A form object used to collect the data for a new initiative.
6
- class InitiativeForm < Form
6
+ class InitiativeForm < PreviousForm
7
7
  include TranslatableAttributes
8
8
  include AttachmentAttributes
9
9
 
10
10
  mimic :initiative
11
11
 
12
- attribute :title, String
13
- attribute :description, String
14
- attribute :type_id, Integer
15
- attribute :scope_id, Integer
16
12
  attribute :area_id, Integer
17
13
  attribute :decidim_user_group_id, Integer
18
14
  attribute :signature_type, String
@@ -20,18 +16,16 @@ module Decidim
20
16
  attribute :state, String
21
17
  attribute :attachment, AttachmentForm
22
18
  attribute :hashtag, String
19
+ attribute :scope_id, Integer
23
20
 
24
21
  attachments_attribute :photos
25
22
  attachments_attribute :documents
26
23
 
27
- validates :title, :description, presence: true
28
- validates :title, length: { maximum: 150 }
29
24
  validates :signature_type, presence: true
30
- validates :type_id, presence: true
31
25
  validates :area, presence: true, if: ->(form) { form.area_id.present? }
32
- validate :scope_exists
33
26
  validate :notify_missing_attachment_if_errored
34
27
  validate :trigger_attachment_errors
28
+ validate :scope_exists
35
29
  validates :signature_end_date, date: { after: Date.current }, if: lambda { |form|
36
30
  form.context.initiative_type.custom_signature_end_date_enabled? && form.signature_end_date.present?
37
31
  }
@@ -39,7 +33,8 @@ module Decidim
39
33
  def map_model(model)
40
34
  self.type_id = model.type.id
41
35
  self.scope_id = model.scope&.id
42
- self.signature_type = model.signature_type
36
+ self.decidim_user_group_id = model.decidim_user_group_id
37
+ self.signature_type = model.signature_type || initiative_type.signature_type
43
38
  self.title = translated_attribute(model.title)
44
39
  self.description = translated_attribute(model.description)
45
40
  end
@@ -56,12 +51,6 @@ module Decidim
56
51
  @area_updatable ||= current_user.admin? || context.initiative.created?
57
52
  end
58
53
 
59
- def scope_id
60
- return nil if initiative_type.only_global_scope_enabled?
61
-
62
- super.presence
63
- end
64
-
65
54
  def area
66
55
  @area ||= current_organization.areas.find_by(id: area_id)
67
56
  end
@@ -70,37 +59,39 @@ module Decidim
70
59
  @initiative_type ||= type_id ? InitiativesType.find(type_id) : context.initiative.type
71
60
  end
72
61
 
73
- def available_scopes
74
- @available_scopes ||= if initiative_type.only_global_scope_enabled?
75
- initiative_type.scopes.where(scope: nil)
76
- else
77
- initiative_type.scopes
78
- end
62
+ def scoped_type_id
63
+ return unless type && scope_id
64
+
65
+ type.scopes.find_by(decidim_scopes_id: scope_id.presence).id
79
66
  end
80
67
 
81
68
  def scope
82
69
  @scope ||= Scope.find(scope_id) if scope_id.present?
83
70
  end
84
71
 
85
- def scoped_type_id
86
- return unless type && scope_id
72
+ def scope_id
73
+ return nil if type.only_global_scope_enabled?
87
74
 
88
- type.scopes.find_by(decidim_scopes_id: scope_id.presence).id
75
+ super.presence
89
76
  end
90
77
 
91
- private
92
-
93
- def type
94
- @type ||= type_id ? Decidim::InitiativesType.find(type_id) : context.initiative.type
78
+ def available_scopes
79
+ @available_scopes ||= if type.only_global_scope_enabled?
80
+ type.scopes.where(scope: nil)
81
+ else
82
+ type.scopes
83
+ end
95
84
  end
96
85
 
86
+ private
87
+
97
88
  def scope_exists
98
89
  return if scope_id.blank?
99
90
 
100
- errors.add(:scope_id, :invalid) unless InitiativesTypeScope.exists?(type: initiative_type, scope: scope)
91
+ errors.add(:scope_id, :invalid) unless InitiativesTypeScope.exists?(type:, scope:)
101
92
  end
102
93
 
103
- # This method will add an error to the `attachment` field only if there's
94
+ # This method will add an error to the `attachment` field only if there is
104
95
  # any error in any other field. This is needed because when the form has
105
96
  # an error, the attachment is lost, so we need a way to inform the user of
106
97
  # this problem.
@@ -15,6 +15,10 @@ module Decidim
15
15
  validates :title, :description, presence: true
16
16
  validates :title, length: { maximum: 150 }
17
17
  validates :type_id, presence: true
18
+
19
+ def type
20
+ @type ||= type_id ? Decidim::InitiativesType.find(type_id) : context.initiative.type
21
+ end
18
22
  end
19
23
  end
20
24
  end
@@ -109,10 +109,10 @@ module Decidim
109
109
 
110
110
  def metadata
111
111
  {
112
- name_and_surname: name_and_surname,
113
- document_number: document_number,
114
- date_of_birth: date_of_birth,
115
- postal_code: postal_code
112
+ name_and_surname:,
113
+ document_number:,
114
+ date_of_birth:,
115
+ postal_code:
116
116
  }
117
117
  end
118
118
 
@@ -137,9 +137,9 @@ module Decidim
137
137
  errors.add(:document_number, :invalid) unless authorized? && authorization_handler && authorization.unique_id == authorization_handler.unique_id
138
138
  end
139
139
 
140
- # Private: Checks if there's any existing vote that matches the user's data.
140
+ # Private: Checks if there is any existing vote that matches the user's data.
141
141
  def already_voted?
142
- errors.add(:document_number, :taken) if initiative.votes.exists?(hash_id: hash_id, scope: scope)
142
+ errors.add(:document_number, :taken) if initiative.votes.exists?(hash_id:, scope:)
143
143
  end
144
144
 
145
145
  def author
@@ -158,7 +158,7 @@ module Decidim
158
158
  ).first
159
159
  end
160
160
 
161
- # Private: Checks if the authorization hasn't expired or is invalid.
161
+ # Private: Checks if the authorization has not expired or is invalid.
162
162
  def authorized?
163
163
  authorization_status&.first == :ok
164
164
  end
@@ -180,10 +180,10 @@ module Decidim
180
180
  return unless document_number && handler_name
181
181
 
182
182
  @authorization_handler ||= Decidim::AuthorizationHandler.handler_for(handler_name,
183
- document_number: document_number,
184
- name_and_surname: name_and_surname,
185
- date_of_birth: date_of_birth,
186
- postal_code: postal_code)
183
+ document_number:,
184
+ name_and_surname:,
185
+ date_of_birth:,
186
+ postal_code:)
187
187
  end
188
188
 
189
189
  # Private: The AuthorizationHandler name used to verify the user's
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  module InitiativesHelper
7
7
  def export_dropdown(collection_ids = nil)
8
- render partial: "decidim/initiatives/admin/exports/dropdown", locals: { collection_ids: collection_ids }
8
+ render partial: "decidim/initiatives/admin/exports/dropdown", locals: { collection_ids: }
9
9
  end
10
10
 
11
11
  def export_dropdowns(query)
@@ -6,6 +6,8 @@ module Decidim
6
6
  #
7
7
  module ApplicationHelper
8
8
  include Decidim::CheckBoxesTreeHelper
9
+ include Decidim::DateRangeHelper
10
+ include InitiativesHelper
9
11
 
10
12
  def filter_states_values
11
13
  TreeNode.new(
@@ -24,39 +26,10 @@ module Decidim
24
26
  )
25
27
  end
26
28
 
27
- def filter_scopes_values
28
- main_scopes = current_organization.scopes.top_level
29
-
30
- scopes_values = main_scopes.includes(:scope_type, :children).flat_map do |scope|
31
- TreeNode.new(
32
- TreePoint.new(scope.id.to_s, translated_attribute(scope.name, current_organization)),
33
- scope_children_to_tree(scope)
34
- )
35
- end
36
-
37
- scopes_values.prepend(TreePoint.new("global", t("decidim.scopes.global")))
38
-
39
- TreeNode.new(
40
- TreePoint.new("", t("decidim.initiatives.application_helper.filter_scope_values.all")),
41
- scopes_values
42
- )
43
- end
44
-
45
- def scope_children_to_tree(scope)
46
- return unless scope.children.any?
47
-
48
- scope.children.includes(:scope_type, :children).flat_map do |child|
49
- TreeNode.new(
50
- TreePoint.new(child.id.to_s, translated_attribute(child.name, current_organization)),
51
- scope_children_to_tree(child)
52
- )
53
- end
54
- end
55
-
56
29
  def filter_types_values
57
30
  types_values = Decidim::InitiativesType.where(organization: current_organization).map do |type|
58
31
  TreeNode.new(
59
- TreePoint.new(type.id.to_s, decidim_escape_translated(type.title))
32
+ TreePoint.new(type.id.to_s, type.title[I18n.locale.to_s])
60
33
  )
61
34
  end
62
35
 
@@ -66,38 +39,8 @@ module Decidim
66
39
  )
67
40
  end
68
41
 
69
- def filter_areas_values
70
- areas_or_types = areas_for_select(current_organization)
71
-
72
- areas_values = if areas_or_types.first.is_a?(Decidim::Area)
73
- filter_areas(areas_or_types)
74
- else
75
- filter_areas_and_types(areas_or_types)
76
- end
77
-
78
- TreeNode.new(
79
- TreePoint.new("", t("decidim.initiatives.application_helper.filter_area_values.all")),
80
- areas_values
81
- )
82
- end
83
-
84
- def filter_areas(areas)
85
- areas.map do |area|
86
- TreeNode.new(
87
- TreePoint.new(area.id.to_s, area.name[I18n.locale.to_s])
88
- )
89
- end
90
- end
91
-
92
- def filter_areas_and_types(area_types)
93
- area_types.map do |area_type|
94
- TreeNode.new(
95
- TreePoint.new(area_type.area_ids.join("_"), decidim_escape_translated(area_type.name)),
96
- area_type.areas.map do |area|
97
- TreePoint.new(area.id.to_s, area.name[I18n.locale.to_s])
98
- end
99
- )
100
- end
42
+ def component_name
43
+ (defined?(current_component) && translated_attribute(current_component&.name).presence) || t("decidim.admin.models.initiatives.fields.title")
101
44
  end
102
45
  end
103
46
  end
@@ -19,6 +19,19 @@ module Decidim
19
19
  "warning"
20
20
  end
21
21
 
22
+ def metadata_badge_css_class(initiative)
23
+ case initiative
24
+ when "accepted", "published"
25
+ "success"
26
+ when "rejected", "discarded"
27
+ "alert"
28
+ when "validating"
29
+ "warning"
30
+ else
31
+ "muted"
32
+ end
33
+ end
34
+
22
35
  # Public: The state of an initiative in a way a human can understand.
23
36
  #
24
37
  # initiative - Decidim::Initiative.
@@ -85,22 +98,42 @@ module Decidim
85
98
  initiative.percentage >= 100
86
99
  end
87
100
 
88
- def authorized_vote_modal_button(initiative, html_options, &block)
101
+ def authorized_create_modal_button(type, html_options, &)
102
+ tag = "button"
103
+ html_options ||= {}
104
+
105
+ if current_user
106
+ if action_authorized_to("create", permissions_holder: type).ok?
107
+ html_options["data-dialog-open"] = "not-authorized-modal"
108
+ else
109
+ html_options["data-dialog-open"] = "authorizationModal"
110
+ html_options["data-dialog-remote-url"] = authorization_create_modal_initiative_path(type)
111
+ end
112
+ else
113
+ html_options["data-dialog-open"] = "loginModal"
114
+ end
115
+
116
+ html_options["onclick"] = "event.preventDefault();"
117
+
118
+ send("#{tag}_to", "", html_options, &)
119
+ end
120
+
121
+ def authorized_vote_modal_button(initiative, html_options, &)
89
122
  return if current_user && action_authorized_to("vote", resource: initiative, permissions_holder: initiative.type).ok?
90
123
 
91
124
  tag = "button"
92
125
  html_options ||= {}
93
126
 
94
127
  if current_user
95
- html_options["data-open"] = "authorizationModal"
96
- html_options["data-open-url"] = authorization_sign_modal_initiative_path(initiative)
128
+ html_options["data-dialog-open"] = "authorizationModal"
129
+ html_options["data-dialog-remote-url"] = authorization_sign_modal_initiative_path(initiative)
97
130
  else
98
- html_options["data-open"] = "loginModal"
131
+ html_options["data-dialog-open"] = "loginModal"
99
132
  end
100
133
 
101
134
  html_options["onclick"] = "event.preventDefault();"
102
135
 
103
- send("#{tag}_to", "", html_options, &block)
136
+ send("#{tag}_to", "", html_options, &)
104
137
  end
105
138
 
106
139
  def can_edit_custom_signature_end_date?(initiative)
@@ -114,6 +147,16 @@ module Decidim
114
147
 
115
148
  initiative.created? || initiative.validating?
116
149
  end
150
+
151
+ def render_committee_tooltip
152
+ with_tooltip t("decidim.initiatives.create_initiative.share_committee_link.invite_to_committee_help"), class: "left" do
153
+ icon "file-copy-line"
154
+ end
155
+ end
156
+
157
+ def hero_background_path(initiative)
158
+ initiative.attachments.find(&:image?)&.url
159
+ end
117
160
  end
118
161
  end
119
162
  end