decidim-initiatives 0.27.4 → 0.28.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
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 +1 -1
  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 +12 -12
  59. data/app/events/decidim/initiatives/create_initiative_event.rb +6 -6
  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 +1 -1
  63. data/app/events/decidim/initiatives/milestone_completed_event.rb +1 -1
  64. data/app/events/decidim/initiatives/revoke_membership_request_event.rb +12 -12
  65. data/app/events/decidim/initiatives/spawn_committee_request_event.rb +12 -12
  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 +4 -61
  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 +17 -20
  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 +59 -31
  83. data/app/packs/stylesheets/initiatives.scss +171 -0
  84. data/app/permissions/decidim/initiatives/permissions.rb +3 -3
  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 -70
  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 +14 -5
  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/environment.rb +3 -0
  159. data/config/initializers/wicked_pdf.rb +1 -1
  160. data/config/locales/ar.yml +1 -92
  161. data/config/locales/ca.yml +65 -104
  162. data/config/locales/cs.yml +70 -109
  163. data/config/locales/de.yml +71 -110
  164. data/config/locales/el.yml +1 -97
  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 +65 -104
  169. data/config/locales/eu.yml +171 -161
  170. data/config/locales/fi-plain.yml +67 -106
  171. data/config/locales/fi.yml +67 -106
  172. data/config/locales/fr-CA.yml +72 -106
  173. data/config/locales/fr.yml +70 -104
  174. data/config/locales/ga-IE.yml +0 -35
  175. data/config/locales/gl.yml +1 -87
  176. data/config/locales/hu.yml +25 -107
  177. data/config/locales/id-ID.yml +1 -88
  178. data/config/locales/is-IS.yml +1 -57
  179. data/config/locales/it.yml +6 -111
  180. data/config/locales/ja.yml +63 -109
  181. data/config/locales/lb.yml +6 -73
  182. data/config/locales/lt.yml +72 -101
  183. data/config/locales/lv.yml +1 -98
  184. data/config/locales/nl.yml +6 -103
  185. data/config/locales/no.yml +6 -114
  186. data/config/locales/pl.yml +11 -111
  187. data/config/locales/pt-BR.yml +21 -116
  188. data/config/locales/pt.yml +6 -111
  189. data/config/locales/ro-RO.yml +13 -108
  190. data/config/locales/ru.yml +1 -65
  191. data/config/locales/sk.yml +1 -84
  192. data/config/locales/sl.yml +3 -5
  193. data/config/locales/sq-AL.yml +1 -0
  194. data/config/locales/sv.yml +20 -107
  195. data/config/locales/th-TH.yml +1 -0
  196. data/config/locales/tr-TR.yml +9 -111
  197. data/config/locales/uk.yml +1 -65
  198. data/config/locales/zh-CN.yml +6 -102
  199. data/config/locales/zh-TW.yml +31 -97
  200. data/db/migrate/20171017091734_add_scopes_for_all_initiative_types.rb +1 -1
  201. data/db/migrate/20171017095143_update_initiative_scoped_type.rb +1 -1
  202. data/db/migrate/20191002082220_move_signature_type_to_initative_type.rb +1 -1
  203. data/lib/decidim/api/initiative_committee_member_type.rb +2 -2
  204. data/lib/decidim/initiatives/admin_engine.rb +13 -93
  205. data/lib/decidim/initiatives/content_blocks/registry_manager.rb +22 -0
  206. data/lib/decidim/initiatives/engine.rb +45 -23
  207. data/lib/decidim/initiatives/menu.rb +150 -0
  208. data/lib/decidim/initiatives/participatory_space.rb +6 -91
  209. data/lib/decidim/initiatives/query_extensions.rb +5 -5
  210. data/lib/decidim/initiatives/seeds.rb +95 -0
  211. data/lib/decidim/initiatives/test/factories.rb +25 -7
  212. data/lib/decidim/initiatives/version.rb +1 -1
  213. data/lib/decidim/initiatives.rb +1 -1
  214. data/lib/tasks/decidim_initiatives.rake +2 -2
  215. data/lib/tasks/initiatives/upgrade/decidim_initiatives_upgrade_tasks.rake +1 -1
  216. metadata +49 -75
  217. data/app/cells/decidim/initiatives/content_blocks/highlighted_initiatives/show.erb +0 -28
  218. data/app/cells/decidim/initiatives/initiative_m/author.erb +0 -10
  219. data/app/cells/decidim/initiatives/initiative_m/footer.erb +0 -28
  220. data/app/cells/decidim/initiatives/initiative_m/tags.erb +0 -9
  221. data/app/cells/decidim/initiatives/initiative_m_cell.rb +0 -77
  222. data/app/controllers/decidim/initiatives/widgets_controller.rb +0 -30
  223. data/app/packs/stylesheets/decidim/initiatives/admin.scss +0 -33
  224. data/app/packs/stylesheets/decidim/initiatives/initiatives.scss +0 -64
  225. data/app/packs/stylesheets/decidim/initiatives/popularity_item.scss +0 -76
  226. data/app/packs/stylesheets/decidim/initiatives/statistics.scss +0 -15
  227. data/app/views/decidim/initiatives/create_initiative/_finish_help.html.erb +0 -2
  228. data/app/views/decidim/initiatives/create_initiative/previous_form.html.erb +0 -40
  229. data/app/views/decidim/initiatives/create_initiative/show_similar_initiatives.html.erb +0 -23
  230. data/app/views/decidim/initiatives/initiatives/_author.html.erb +0 -35
  231. data/app/views/decidim/initiatives/initiatives/_count.html.erb +0 -1
  232. data/app/views/decidim/initiatives/initiatives/_filters.html.erb +0 -33
  233. data/app/views/decidim/initiatives/initiatives/_filters_small_view.html.erb +0 -18
  234. data/app/views/decidim/initiatives/initiatives/_index_header.html.erb +0 -44
  235. data/app/views/decidim/initiatives/initiatives/_tags.html.erb +0 -7
  236. data/app/views/decidim/initiatives/versions/index.html.erb +0 -8
  237. data/db/seeds/city.jpeg +0 -0
  238. data/db/seeds/city2.jpeg +0 -0
  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
@@ -9,35 +9,35 @@ module Decidim
9
9
  def email_subject
10
10
  I18n.t(
11
11
  "decidim.initiatives.events.approve_membership_request.email_subject",
12
- author_nickname: author_nickname
12
+ author_nickname:
13
13
  )
14
14
  end
15
15
 
16
16
  def email_intro
17
17
  I18n.t(
18
18
  "decidim.initiatives.events.approve_membership_request.email_intro",
19
- resource_title: resource_title,
20
- resource_url: resource_url,
21
- author_profile_url: author_profile_url,
22
- author_nickname: author_nickname
19
+ resource_title:,
20
+ resource_url:,
21
+ author_profile_url:,
22
+ author_nickname:
23
23
  )
24
24
  end
25
25
 
26
26
  def email_outro
27
27
  I18n.t(
28
28
  "decidim.initiatives.events.approve_membership_request.email_outro",
29
- resource_title: resource_title,
30
- resource_url: resource_url
29
+ resource_title:,
30
+ resource_url:
31
31
  )
32
32
  end
33
33
 
34
34
  def notification_title
35
35
  I18n.t(
36
36
  "decidim.initiatives.events.approve_membership_request.notification_title",
37
- resource_title: resource_title,
38
- resource_url: resource_url,
39
- author_profile_url: author_profile_url,
40
- author_nickname: author_nickname
37
+ resource_title:,
38
+ resource_url:,
39
+ author_profile_url:,
40
+ author_nickname:
41
41
  ).html_safe
42
42
  end
43
43
 
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
@@ -9,7 +9,7 @@ module Decidim
9
9
  def email_subject
10
10
  I18n.t(
11
11
  "decidim.initiatives.events.create_initiative_event.email_subject",
12
- resource_title: resource_title,
12
+ resource_title:,
13
13
  author_nickname: author.nickname,
14
14
  author_name: author.name
15
15
  )
@@ -18,7 +18,7 @@ module Decidim
18
18
  def email_intro
19
19
  I18n.t(
20
20
  "decidim.initiatives.events.create_initiative_event.email_intro",
21
- resource_title: resource_title,
21
+ resource_title:,
22
22
  author_nickname: author.nickname,
23
23
  author_name: author.name
24
24
  )
@@ -27,7 +27,7 @@ module Decidim
27
27
  def email_outro
28
28
  I18n.t(
29
29
  "decidim.initiatives.events.create_initiative_event.email_outro",
30
- resource_title: resource_title,
30
+ resource_title:,
31
31
  author_nickname: author.nickname,
32
32
  author_name: author.name
33
33
  )
@@ -36,8 +36,8 @@ module Decidim
36
36
  def notification_title
37
37
  I18n.t(
38
38
  "decidim.initiatives.events.create_initiative_event.notification_title",
39
- resource_title: resource_title,
40
- resource_path: resource_path,
39
+ resource_title:,
40
+ resource_path:,
41
41
  author_nickname: author.nickname,
42
42
  author_name: author.name,
43
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
@@ -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
@@ -9,35 +9,35 @@ module Decidim
9
9
  def email_subject
10
10
  I18n.t(
11
11
  "decidim.initiatives.events.revoke_membership_request.email_subject",
12
- author_nickname: author_nickname
12
+ author_nickname:
13
13
  )
14
14
  end
15
15
 
16
16
  def email_intro
17
17
  I18n.t(
18
18
  "decidim.initiatives.events.revoke_membership_request.email_intro",
19
- resource_title: resource_title,
20
- resource_url: resource_url,
21
- author_profile_url: author_profile_url,
22
- author_nickname: author_nickname
19
+ resource_title:,
20
+ resource_url:,
21
+ author_profile_url:,
22
+ author_nickname:
23
23
  )
24
24
  end
25
25
 
26
26
  def email_outro
27
27
  I18n.t(
28
28
  "decidim.initiatives.events.revoke_membership_request.email_outro",
29
- resource_title: resource_title,
30
- resource_url: resource_url
29
+ resource_title:,
30
+ resource_url:
31
31
  )
32
32
  end
33
33
 
34
34
  def notification_title
35
35
  I18n.t(
36
36
  "decidim.initiatives.events.revoke_membership_request.notification_title",
37
- resource_title: resource_title,
38
- resource_url: resource_url,
39
- author_profile_url: author_profile_url,
40
- author_nickname: author_nickname
37
+ resource_title:,
38
+ resource_url:,
39
+ author_profile_url:,
40
+ author_nickname:
41
41
  ).html_safe
42
42
  end
43
43
 
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Initiatives
@@ -9,35 +9,35 @@ module Decidim
9
9
  def email_subject
10
10
  I18n.t(
11
11
  "decidim.initiatives.events.spawn_committee_request_event.email_subject",
12
- applicant_nickname: applicant_nickname
12
+ applicant_nickname:
13
13
  )
14
14
  end
15
15
 
16
16
  def email_intro
17
17
  I18n.t(
18
18
  "decidim.initiatives.events.spawn_committee_request_event.email_intro",
19
- resource_title: resource_title,
20
- resource_url: resource_url,
21
- applicant_profile_url: applicant_profile_url,
22
- applicant_nickname: applicant_nickname
19
+ resource_title:,
20
+ resource_url:,
21
+ applicant_profile_url:,
22
+ applicant_nickname:
23
23
  )
24
24
  end
25
25
 
26
26
  def email_outro
27
27
  I18n.t(
28
28
  "decidim.initiatives.events.spawn_committee_request_event.email_outro",
29
- resource_title: resource_title,
30
- resource_url: resource_url
29
+ resource_title:,
30
+ resource_url:
31
31
  )
32
32
  end
33
33
 
34
34
  def notification_title
35
35
  I18n.t(
36
36
  "decidim.initiatives.events.spawn_committee_request_event.notification_title",
37
- resource_title: resource_title,
38
- resource_url: resource_url,
39
- applicant_profile_url: applicant_profile_url,
40
- applicant_nickname: applicant_nickname
37
+ resource_title:,
38
+ resource_url:,
39
+ applicant_profile_url:,
40
+ applicant_nickname:
41
41
  ).html_safe
42
42
  end
43
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,35 +26,6 @@ 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(
@@ -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("_"), area_type.name[I18n.locale.to_s]),
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
@@ -4,18 +4,16 @@ module Decidim
4
4
  module Initiatives
5
5
  # Helper functions for initiatives views
6
6
  module InitiativesHelper
7
- def initiatives_filter_form_for(filter)
8
- content_tag :div, class: "filters" do
9
- form_for filter,
10
- namespace: filter_form_namespace,
11
- builder: Decidim::Initiatives::InitiativesFilterFormBuilder,
12
- url: url_for,
13
- as: :filter,
14
- method: :get,
15
- remote: true,
16
- html: { id: nil } do |form|
17
- yield form
18
- end
7
+ # Items to display in the navigation of an initiative
8
+ def initiative_nav_items(participatory_space)
9
+ components = participatory_space.components.published.or(Decidim::Component.where(id: try(:current_component)))
10
+
11
+ components.map do |component|
12
+ {
13
+ name: translated_attribute(component.name),
14
+ url: main_component_path(component),
15
+ active: is_active_link?(main_component_path(component), :inclusive)
16
+ }
19
17
  end
20
18
  end
21
19
 
@@ -27,6 +25,29 @@ module Decidim
27
25
  def filter_form_namespace
28
26
  "filters_#{SecureRandom.uuid}"
29
27
  end
28
+
29
+ # i18n-tasks-use t('decidim.initiatives.initiatives.filters.state')
30
+ # i18n-tasks-use t('decidim.initiatives.initiatives.filters.scope')
31
+ # i18n-tasks-use t('decidim.initiatives.initiatives.filters.type')
32
+ # i18n-tasks-use t('decidim.initiatives.initiatives.filters.area')
33
+ # i18n-tasks-use t('decidim.initiatives.initiatives.filters.author')
34
+ def filter_sections
35
+ sections = [
36
+ { method: :with_any_state, collection: filter_states_values, label_scope: "decidim.initiatives.initiatives.filters", id: "state" },
37
+ { method: :with_any_scope, collection: filter_global_scopes_values, label_scope: "decidim.initiatives.initiatives.filters", id: "scope" }
38
+ ]
39
+ sections.append(method: :with_any_type, collection: filter_types_values, label_scope: "decidim.initiatives.initiatives.filters", id: "type") unless single_initiative_type?
40
+ sections.append(method: :with_any_area, collection: filter_areas_values, label_scope: "decidim.initiatives.initiatives.filters", id: "area")
41
+ sections.append(method: :author, collection: filter_author_values, label_scope: "decidim.initiatives.initiatives.filters", id: "author") if current_user
42
+ sections.reject { |item| item[:collection].blank? }
43
+ end
44
+
45
+ def filter_author_values
46
+ [
47
+ ["any", t("any", scope: "decidim.initiatives.initiatives.filters")],
48
+ ["myself", t("myself", scope: "decidim.initiatives.initiatives.filters")]
49
+ ]
50
+ end
30
51
  end
31
52
  end
32
53
  end
@@ -17,7 +17,7 @@ module Decidim
17
17
  private
18
18
 
19
19
  def collection_to_export(ids, organization)
20
- collection = Decidim::Initiative.where(organization: organization)
20
+ collection = Decidim::Initiative.where(organization:)
21
21
 
22
22
  collection = collection.where(id: ids) if ids.present?
23
23