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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59d295e16fde2eada468ccb94da312ecf5a2b48154627275645bd2f4f20943fa
4
- data.tar.gz: 86e6dc47360ed063ef296422bf44c61a141ce82f68d33fbe49a0ed0fff5d1a11
3
+ metadata.gz: 71d5922fc9d0c0fcd65aa19a561fe47b3428adaae05524ffd1b9871d31d50171
4
+ data.tar.gz: f0b7c78b54c9681d37276569176bdd2d1c0e4e2fc79095b2b54523dd315e1102
5
5
  SHA512:
6
- metadata.gz: 5c4f7bde0ad8c721a92012e4a4a30847dbb6e92c0ade84334db0e0d3250b018bdec64024bcb68a593b9f80333c1e931f2ff4b8d8d5065d9e006bcd1b740db168
7
- data.tar.gz: 837ab0a2cda44e0e9b673bc2812e565c5bb8ef53cc7eeedd3b6921259eb71ed7305481b02df5ce06957c9846d10a5a0829053a8724f42ab91e303ec086627864
6
+ metadata.gz: 733c03d48b67d7e26db9d60e0a8e9f7cfd996f652b11bda14214698e9c17dc5f0b1a37171869ca3fb0714c2a5680858c7ad41b0772f422c794cfd15dd1e15bbf
7
+ data.tar.gz: ab4f8cddd4e7aed1f349c49c5d30ad04693ee0e63a3ae4e4a0444bad387c43288a3655aa854196ceb0a29209784de70871081d9c782eb24ffe1bcafb9bafd43f
data/README.md CHANGED
@@ -49,18 +49,22 @@ Some of the settings of the module need to be set in the code of your app, for e
49
49
  This is the case if you want to enable the creation of initiatives even when no authorization method is set.
50
50
 
51
51
  Just use the following line:
52
- ```
52
+
53
+ ```ruby
53
54
  Decidim::Initiatives.do_not_require_authorization = true
54
55
  ```
55
56
 
56
57
  All the settings and their default values which can be overriden can be found in the file [`lib/decidim/initiatives.rb`](https://github.com/decidim/decidim/blob/develop/decidim-initiatives/lib/decidim/initiatives.rb).
57
58
 
58
59
  For example, you can also change the minimum number of required committee members to 1 (default is 2) by adding this line:
59
- ```
60
+
61
+ ```ruby
60
62
  Decidim::Initiatives.minimum_committee_members = 1
61
63
  ```
64
+
62
65
  Or change the number of days given to gather signatures to 365 (default is 120) with:
63
- ```
66
+
67
+ ```ruby
64
68
  Decidim::Initiatives.default_signature_time_period_length = 365
65
69
  ```
66
70
 
@@ -3,37 +3,36 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  module ContentBlocks
6
- class HighlightedInitiativesCell < Decidim::ViewModel
7
- include Decidim::SanitizeHelper
6
+ class HighlightedInitiativesCell < Decidim::ContentBlocks::HighlightedParticipatorySpacesCell
7
+ BLOCK_ID = "highlighted-initiatives"
8
8
 
9
9
  delegate :current_organization, to: :controller
10
10
 
11
- def show
12
- render if highlighted_initiatives.any?
11
+ def highlighted_spaces
12
+ @highlighted_spaces ||= OrganizationPrioritizedInitiatives
13
+ .new(current_organization, order)
14
+ .query
13
15
  end
14
16
 
15
- def max_results
16
- model.settings.max_results
17
+ def i18n_scope
18
+ "decidim.initiatives.pages.home.highlighted_initiatives"
17
19
  end
18
20
 
19
- def order
20
- model.settings.order
21
+ def all_path
22
+ Decidim::Initiatives::Engine.routes.url_helpers.initiatives_path
21
23
  end
22
24
 
23
- def highlighted_initiatives
24
- @highlighted_initiatives ||= OrganizationPrioritizedInitiatives
25
- .new(current_organization, order)
26
- .query
27
- .limit(max_results)
28
- end
25
+ private
29
26
 
30
- def i18n_scope
31
- "decidim.initiatives.pages.home.highlighted_initiatives"
27
+ def max_results
28
+ model.settings.max_results
32
29
  end
33
30
 
34
- def decidim_initiatives
35
- Decidim::Initiatives::Engine.routes.url_helpers
31
+ def order
32
+ model.settings.order
36
33
  end
34
+
35
+ def block_id = BLOCK_ID
37
36
  end
38
37
  end
39
38
  end
@@ -12,7 +12,12 @@ module Decidim
12
12
  private
13
13
 
14
14
  def card_size
15
- "decidim/initiatives/initiative_m"
15
+ case @options[:size]
16
+ when :s
17
+ "decidim/initiatives/initiative_s"
18
+ else
19
+ "decidim/initiatives/initiative_g"
20
+ end
16
21
  end
17
22
  end
18
23
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ class InitiativeDropdownMetadataCell < Decidim::ParticipatorySpaceDropdownMetadataCell
6
+ include InitiativesHelper
7
+ include Decidim::ComponentPathHelper
8
+ include ActiveLinkTo
9
+
10
+ def decidim_initiatives
11
+ Decidim::Initiatives::Engine.routes.url_helpers
12
+ end
13
+
14
+ private
15
+
16
+ def nav_items_method = :initiative_nav_items
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ # This cell renders the Grid (:g) initiative card
6
+ # for a given instance of an Initiative
7
+ class InitiativeGCell < Decidim::CardGCell
8
+ private
9
+
10
+ def resource_path
11
+ Decidim::Initiatives::Engine.routes.url_helpers.initiative_path(model)
12
+ end
13
+
14
+ def has_image?
15
+ image.present?
16
+ end
17
+
18
+ def image
19
+ @image ||= model.attachments.find(&:image?)
20
+ end
21
+
22
+ def resource_image_path
23
+ image.url if has_image?
24
+ end
25
+
26
+ def metadata_cell
27
+ "decidim/initiatives/initiative_metadata_g"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ # This cell renders the assembly metadata for g card
6
+ class InitiativeMetadataGCell < Decidim::CardMetadataCell
7
+ include Cell::ViewModel::Partial
8
+ include Decidim::Initiatives::InitiativeHelper
9
+
10
+ alias current_initiative resource
11
+ alias initiative resource
12
+
13
+ def initialize(*)
14
+ super
15
+
16
+ @items.prepend(*initiative_items)
17
+ end
18
+
19
+ private
20
+
21
+ def initiative_items
22
+ [dates_item, progress_bar_item, state_item].compact
23
+ end
24
+
25
+ def start_date
26
+ initiative.signature_start_date
27
+ end
28
+
29
+ def end_date
30
+ initiative.signature_end_date
31
+ end
32
+
33
+ def state_item
34
+ return if initiative.state.blank?
35
+
36
+ {
37
+ text: content_tag(
38
+ :span,
39
+ t(initiative.state, scope: "decidim.initiatives.show.badge_name"),
40
+ class: "label #{metadata_badge_css_class(initiative.state)} initiative-status"
41
+ )
42
+ }
43
+ end
44
+
45
+ def progress_bar_item
46
+ return if %w(created validating discarded).include?(initiative.state)
47
+
48
+ type_scope = initiative.votable_initiative_type_scopes[0]
49
+
50
+ {
51
+ cell: "decidim/progress_bar",
52
+ args: [initiative.supports_count_for(type_scope.scope), {
53
+ total: type_scope.supports_required,
54
+ element_id: "initiative-#{initiative.id}-votes-count",
55
+ class: "progress-bar__sm"
56
+ }],
57
+ icon: nil
58
+ }
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ # This cell renders the Search (:s) initiative card
6
+ # for a given instance of an Initiative
7
+ class InitiativeSCell < Decidim::CardSCell
8
+ private
9
+
10
+ def metadata_cell
11
+ "decidim/initiatives/initiative_metadata_g"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,33 +1,39 @@
1
+ <% collect_user_extra_fields = model.initiative.type.collect_user_extra_fields %>
2
+ <% cell_small_width = collect_user_extra_fields ? "9.4%" : "15.6%" %>
3
+ <% style_initiatives_votes_table_row = "width: 100%; display: inline-block; min-height: 33pt; border-bottom: 1pt solid black;" %>
4
+ <% style_initiatives_votes_table_cell = "width: #{cell_small_width}; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;" %>
1
5
  <br>
2
- <div class="initiatives-votes-table-row" style="width: 100%; display: inline-block; min-height: 33pt; border-bottom: 1pt solid black;">
3
- <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
6
+ <div class="initiatives-votes-table-row" style="<%= style_initiatives_votes_table_row %>">
7
+ <div class="initiatives-votes-table-cell w11" style="<%= style_initiatives_votes_table_cell %>">
4
8
  <%= initiative_id %>
5
9
  </div>
6
- <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
10
+ <div class="initiatives-votes-table-cell w11" style="<%= style_initiatives_votes_table_cell %>">
7
11
  <%= initiative_title %>
8
12
  </div>
9
- <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
10
- <%= name_and_surname %>
11
- </div>
12
- <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
13
- <%= document_number %>
14
- </div>
15
- <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
16
- <%= date_of_birth %>
17
- </div>
18
- <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
19
- <%= postal_code %>
20
- </div>
21
- <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
13
+ <% if collect_user_extra_fields %>
14
+ <div class="initiatives-votes-table-cell w11" style="<%= style_initiatives_votes_table_cell %>">
15
+ <%= name_and_surname %>
16
+ </div>
17
+ <div class="initiatives-votes-table-cell w11" style="<%= style_initiatives_votes_table_cell %>">
18
+ <%= document_number %>
19
+ </div>
20
+ <div class="initiatives-votes-table-cell w11" style="<%= style_initiatives_votes_table_cell %>">
21
+ <%= date_of_birth %>
22
+ </div>
23
+ <div class="initiatives-votes-table-cell w11" style="<%= style_initiatives_votes_table_cell %>">
24
+ <%= postal_code %>
25
+ </div>
26
+ <% end %>
27
+ <div class="initiatives-votes-table-cell w11" style="<%= style_initiatives_votes_table_cell %>">
22
28
  <%= time_and_date %>
23
29
  </div>
24
- <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
30
+ <div class="initiatives-votes-table-cell w11" style="<%= style_initiatives_votes_table_cell %>">
25
31
  <%= timestamp %>
26
32
  </div>
27
- <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
33
+ <div class="initiatives-votes-table-cell w11" style="<%= style_initiatives_votes_table_cell %>">
28
34
  <%= hash_id %>
29
35
  </div>
30
- <div class="initiatives-votes-table-cell w11" style="width: 9.4%; padding-left: 5pt; word-wrap: break-word; display: inline-block; float: left; min-height: 36pt;">
36
+ <div class="initiatives-votes-table-cell w11" style="<%= style_initiatives_votes_table_cell %>">
31
37
  <%= scope %>
32
38
  </div>
33
39
  </div>
@@ -3,6 +3,8 @@
3
3
  module Decidim
4
4
  module InitiativesVotes
5
5
  class VoteCell < Decidim::ViewModel
6
+ include Decidim::SanitizeHelper
7
+
6
8
  delegate :timestamp, :hash_id, to: :model
7
9
 
8
10
  def show
@@ -14,7 +16,7 @@ module Decidim
14
16
  end
15
17
 
16
18
  def initiative_title
17
- translated_attribute(model.initiative.title)
19
+ decidim_sanitize(translated_attribute(model.initiative.title))
18
20
  end
19
21
 
20
22
  def name_and_surname
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ module Admin
6
+ # A command with all the business logic that accepts an
7
+ # existing initiative.
8
+ class AcceptInitiative < Decidim::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # initiative - Decidim::Initiative
12
+ # current_user - the user performing the action
13
+ def initialize(initiative, current_user)
14
+ @initiative = initiative
15
+ @current_user = current_user
16
+ end
17
+
18
+ # Executes the command. Broadcasts these events:
19
+ #
20
+ # - :ok when everything is valid.
21
+ # - :invalid if the form was not valid and we could not proceed.
22
+ #
23
+ # Returns nothing.
24
+ def call
25
+ return broadcast(:invalid) if initiative.accepted?
26
+
27
+ @initiative = Decidim.traceability.perform_action!(:accept, initiative, current_user) do
28
+ initiative.accepted!
29
+ initiative
30
+ end
31
+ broadcast(:ok, initiative)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :initiative, :current_user
37
+ end
38
+ end
39
+ end
40
+ end
@@ -16,7 +16,7 @@ module Decidim
16
16
  # Executes the command. Broadcasts these events:
17
17
  #
18
18
  # - :ok when everything is valid.
19
- # - :invalid if the form wasn't valid and we couldn't proceed.
19
+ # - :invalid if the form was not valid and we could not proceed.
20
20
  #
21
21
  # Returns nothing.
22
22
  def call
@@ -15,7 +15,7 @@ module Decidim
15
15
  # Executes the command. Broadcasts these events:
16
16
  #
17
17
  # - :ok when everything is valid.
18
- # - :invalid if the form wasn't valid and we couldn't proceed.
18
+ # - :invalid if the form was not valid and we could not proceed.
19
19
  #
20
20
  # Returns nothing.
21
21
  def call
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ module Admin
6
+ # A command with all the business logic that discards an
7
+ # existing initiative.
8
+ class DiscardInitiative < Decidim::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # initiative - Decidim::Initiative
12
+ # current_user - the user performing the action
13
+ def initialize(initiative, current_user)
14
+ @initiative = initiative
15
+ @current_user = current_user
16
+ end
17
+
18
+ # Executes the command. Broadcasts these events:
19
+ #
20
+ # - :ok when everything is valid.
21
+ # - :invalid if the form was not valid and we could not proceed.
22
+ #
23
+ # Returns nothing.
24
+ def call
25
+ return broadcast(:invalid) if initiative.discarded?
26
+
27
+ @initiative = Decidim.traceability.perform_action!(:discard, initiative, current_user) do
28
+ initiative.discarded!
29
+ initiative
30
+ end
31
+ broadcast(:ok, initiative)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :initiative, :current_user
37
+ end
38
+ end
39
+ end
40
+ end
@@ -18,7 +18,7 @@ module Decidim
18
18
  # Executes the command. Broadcasts these events:
19
19
  #
20
20
  # - :ok when everything is valid.
21
- # - :invalid if the form wasn't valid and we couldn't proceed.
21
+ # - :invalid if the form was not valid and we could not proceed.
22
22
  #
23
23
  # Returns nothing.
24
24
  def call
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Initiatives
5
+ module Admin
6
+ # A command with all the business logic that rejects an
7
+ # existing initiative.
8
+ class RejectInitiative < Decidim::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # initiative - Decidim::Initiative
12
+ # current_user - the user performing the action
13
+ def initialize(initiative, current_user)
14
+ @initiative = initiative
15
+ @current_user = current_user
16
+ end
17
+
18
+ # Executes the command. Broadcasts these events:
19
+ #
20
+ # - :ok when everything is valid.
21
+ # - :invalid if the form was not valid and we could not proceed.
22
+ #
23
+ # Returns nothing.
24
+ def call
25
+ return broadcast(:invalid) if initiative.rejected?
26
+
27
+ @initiative = Decidim.traceability.perform_action!(:reject, initiative, current_user) do
28
+ initiative.rejected!
29
+ initiative
30
+ end
31
+ broadcast(:ok, initiative)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :initiative, :current_user
37
+ end
38
+ end
39
+ end
40
+ end
@@ -18,7 +18,7 @@ module Decidim
18
18
  # Executes the command. Broadcasts these events:
19
19
  #
20
20
  # - :ok when everything is valid.
21
- # - :invalid if the form wasn't valid and we couldn't proceed.
21
+ # - :invalid if the form was not valid and we could not proceed.
22
22
  #
23
23
  # Returns nothing.
24
24
  def call
@@ -47,7 +47,7 @@ module Decidim
47
47
  event: "decidim.events.initiatives.admin.initiative_sent_to_technical_validation",
48
48
  event_class: Decidim::Initiatives::Admin::InitiativeSentToTechnicalValidationEvent,
49
49
  resource: initiative,
50
- affected_users: affected_users,
50
+ affected_users:,
51
51
  force_send: true
52
52
  }
53
53
 
@@ -18,7 +18,7 @@ module Decidim
18
18
  # Executes the command. Broadcasts these events:
19
19
  #
20
20
  # - :ok when everything is valid.
21
- # - :invalid if the form wasn't valid and we couldn't proceed.
21
+ # - :invalid if the form was not valid and we could not proceed.
22
22
  #
23
23
  # Returns nothing.
24
24
  def call
@@ -22,7 +22,7 @@ module Decidim
22
22
  # Executes the command. Broadcasts these events:
23
23
  #
24
24
  # - :ok when everything is valid.
25
- # - :invalid if the form wasn't valid and we couldn't proceed.
25
+ # - :invalid if the form was not valid and we could not proceed.
26
26
  #
27
27
  # Returns nothing.
28
28
  def call
@@ -20,7 +20,7 @@ module Decidim
20
20
  # Executes the command. Broadcasts these events:
21
21
  #
22
22
  # - :ok when everything is valid.
23
- # - :invalid if the form wasn't valid and we couldn't proceed.
23
+ # - :invalid if the form was not valid and we could not proceed.
24
24
  #
25
25
  # Returns nothing.
26
26
  def call
@@ -21,7 +21,7 @@ module Decidim
21
21
  # Executes the command. Broadcasts these events:
22
22
  #
23
23
  # - :ok when everything is valid.
24
- # - :invalid if the form wasn't valid and we couldn't proceed.
24
+ # - :invalid if the form was not valid and we could not proceed.
25
25
  #
26
26
  # Returns nothing.
27
27
  def call
@@ -18,7 +18,7 @@ module Decidim
18
18
  # Executes the command. Broadcasts these events:
19
19
  #
20
20
  # - :ok when everything is valid.
21
- # - :invalid if the form wasn't valid and we couldn't proceed.
21
+ # - :invalid if the form was not valid and we could not proceed.
22
22
  #
23
23
  # Returns nothing.
24
24
  def call
@@ -18,7 +18,7 @@ module Decidim
18
18
  # Executes the command. Broadcasts these events:
19
19
  #
20
20
  # - :ok when everything is valid.
21
- # - :invalid if the form or initiatives_settings isn't valid and we couldn't proceed.
21
+ # - :invalid if the form or initiatives_settings is not valid and we could not proceed.
22
22
  #
23
23
  # Returns nothing.
24
24
  def call
@@ -3,31 +3,9 @@
3
3
  module Decidim
4
4
  module Initiatives
5
5
  module AttachmentMethods
6
- private
7
-
8
- def build_attachment(attached_to = nil)
9
- attached_to = @attached_to if attached_to.blank?
10
- attached_to = form.current_organization if attached_to.blank? && form.respond_to?(:current_organization)
11
-
12
- @attachment = Attachment.new(
13
- title: { I18n.locale => @form.attachment.title },
14
- attached_to: attached_to,
15
- file: @form.attachment.file, # Define attached_to before this
16
- content_type: @form.attachment.file.content_type
17
- )
18
- end
6
+ include Decidim::AttachmentMethods
19
7
 
20
- def attachment_invalid?
21
- if attachment.invalid? && attachment.errors.has_key?(:file)
22
- @form.attachment.errors.add :file, attachment.errors[:file]
23
- true
24
- end
25
- end
26
-
27
- def create_attachment
28
- attachment.attached_to = @attached_to
29
- attachment.save!
30
- end
8
+ private
31
9
 
32
10
  def process_attachments?
33
11
  @form.attachment && @form.attachment.file.present? &&