decidim-core 0.29.3 → 0.30.0.rc1

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 (532) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/amendable/amend_button_card/show.erb +6 -4
  3. data/app/cells/decidim/amendable/amend_button_card_cell.rb +8 -0
  4. data/app/cells/decidim/amendable/amendments/show.erb +1 -1
  5. data/app/cells/decidim/amendable/promote_button_card/show.erb +2 -0
  6. data/app/cells/decidim/author/flag.erb +6 -0
  7. data/app/cells/decidim/author/flag_user.erb +14 -0
  8. data/app/cells/decidim/author_cell.rb +1 -1
  9. data/app/cells/decidim/card_l/extra_data.erb +1 -0
  10. data/app/cells/decidim/card_metadata_cell.rb +9 -16
  11. data/app/cells/decidim/comments_button_cell.rb +14 -2
  12. data/app/cells/decidim/content_blocks/highlighted_elements_cell.rb +2 -0
  13. data/app/cells/decidim/content_blocks/highlighted_elements_with_cell_for_list_cell.rb +1 -1
  14. data/app/cells/decidim/endorsement_block/show.erb +0 -1
  15. data/app/cells/decidim/endorsement_block_cell.rb +6 -0
  16. data/app/cells/decidim/endorsement_buttons/button_content.erb +1 -1
  17. data/app/cells/decidim/endorsement_buttons/select_identity_button.erb +1 -1
  18. data/app/cells/decidim/endorsement_buttons/show.erb +7 -7
  19. data/app/cells/decidim/endorsement_buttons/verification_modal.erb +4 -2
  20. data/app/cells/decidim/endorsers_list/empty.erb +3 -0
  21. data/app/cells/decidim/endorsers_list/full.erb +17 -5
  22. data/app/cells/decidim/endorsers_list/show.erb +19 -10
  23. data/app/cells/decidim/endorsers_list_cell.rb +19 -6
  24. data/app/cells/decidim/flag_modal/flag_user.erb +34 -0
  25. data/app/cells/decidim/flag_modal/show.erb +52 -0
  26. data/app/cells/decidim/flag_modal_cell.rb +56 -0
  27. data/app/cells/decidim/follow_button/show.erb +1 -2
  28. data/app/cells/decidim/follow_button_cell.rb +5 -0
  29. data/app/cells/decidim/map/show.erb +3 -0
  30. data/app/cells/decidim/map/template.erb +14 -0
  31. data/app/cells/decidim/map_cell.rb +39 -0
  32. data/app/cells/decidim/notification_actions/buttons_cell.rb +1 -1
  33. data/app/cells/decidim/onboarding_action_message/show.erb +15 -0
  34. data/app/cells/decidim/onboarding_action_message_cell.rb +81 -0
  35. data/app/cells/decidim/participatory_space_dropdown_metadata/show.erb +3 -5
  36. data/app/cells/decidim/participatory_space_private_user/show.erb +23 -0
  37. data/app/cells/decidim/participatory_space_private_user_cell.rb +21 -0
  38. data/app/cells/decidim/profile_actions/show.erb +1 -1
  39. data/app/cells/decidim/profile_sidebar/show.erb +167 -0
  40. data/app/cells/decidim/profile_sidebar_cell.rb +68 -0
  41. data/app/cells/decidim/progress_bar/show.erb +2 -2
  42. data/app/cells/decidim/report_button/already_reported_modal.erb +2 -2
  43. data/app/cells/decidim/report_button/flag_modal.erb +27 -13
  44. data/app/cells/decidim/report_button_cell.rb +9 -2
  45. data/app/cells/decidim/resource_history/show.erb +20 -0
  46. data/app/cells/decidim/resource_history_cell.rb +66 -0
  47. data/app/cells/decidim/resource_types_filter/show.erb +1 -1
  48. data/app/cells/decidim/resource_types_filter_cell.rb +6 -6
  49. data/app/cells/decidim/share_button_cell.rb +0 -4
  50. data/app/cells/decidim/share_widget/modal.erb +26 -0
  51. data/app/cells/decidim/share_widget/show.erb +2 -0
  52. data/app/cells/decidim/share_widget_cell.rb +20 -0
  53. data/app/cells/decidim/tags/show.erb +7 -4
  54. data/app/cells/decidim/tags_cell.rb +11 -72
  55. data/app/cells/decidim/user_activity/show.erb +1 -1
  56. data/app/commands/decidim/amendable/create_draft.rb +2 -2
  57. data/app/commands/decidim/create_ephemeral_user.rb +52 -0
  58. data/app/commands/decidim/create_omniauth_registration.rb +21 -17
  59. data/app/commands/decidim/create_report.rb +7 -6
  60. data/app/commands/decidim/create_user_group.rb +6 -2
  61. data/app/commands/decidim/destroy_ephemeral_user.rb +47 -0
  62. data/app/commands/decidim/search.rb +0 -14
  63. data/app/commands/decidim/update_account.rb +11 -3
  64. data/app/commands/decidim/update_notifications_settings.rb +1 -0
  65. data/app/commands/decidim/update_resources_taxonomies.rb +67 -0
  66. data/app/commands/decidim/update_user_group.rb +7 -1
  67. data/app/constraints/decidim/current_component.rb +1 -1
  68. data/app/controllers/concerns/decidim/ajax_permission_handler.rb +21 -0
  69. data/app/controllers/concerns/decidim/devise_authentication_methods.rb +3 -6
  70. data/app/controllers/concerns/decidim/devise_controllers.rb +2 -0
  71. data/app/controllers/concerns/decidim/disable_redirection_to_external_host.rb +1 -1
  72. data/app/controllers/concerns/decidim/ephemeral_session_checker.rb +87 -0
  73. data/app/controllers/concerns/decidim/filter_resource.rb +4 -2
  74. data/app/controllers/concerns/decidim/has_members_page.rb +25 -0
  75. data/app/controllers/concerns/decidim/headers/browser_feature_permissions.rb +50 -0
  76. data/app/controllers/concerns/decidim/locale_switcher.rb +2 -2
  77. data/app/controllers/concerns/decidim/needs_password_change.rb +0 -1
  78. data/app/controllers/concerns/decidim/needs_permission.rb +2 -1
  79. data/app/controllers/concerns/decidim/needs_tos_accepted.rb +4 -5
  80. data/app/controllers/concerns/decidim/onboarding_action_methods.rb +52 -0
  81. data/app/controllers/decidim/application_controller.rb +10 -0
  82. data/app/controllers/decidim/authorization_modals_controller.rb +8 -2
  83. data/app/controllers/decidim/components/base_controller.rb +3 -7
  84. data/app/controllers/decidim/devise/confirmations_controller.rb +4 -0
  85. data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +8 -1
  86. data/app/controllers/decidim/devise/registrations_controller.rb +1 -1
  87. data/app/controllers/decidim/devise/sessions_controller.rb +2 -0
  88. data/app/controllers/decidim/download_your_data_controller.rb +33 -2
  89. data/app/controllers/decidim/editor_images_controller.rb +1 -11
  90. data/app/controllers/decidim/follows_controller.rb +1 -1
  91. data/app/controllers/decidim/geolocation_controller.rb +19 -0
  92. data/app/controllers/decidim/homepage_controller.rb +0 -1
  93. data/app/controllers/decidim/open_data_controller.rb +33 -8
  94. data/app/controllers/decidim/profiles_controller.rb +2 -2
  95. data/app/controllers/decidim/reports_controller.rb +1 -1
  96. data/app/controllers/decidim/user_activities_controller.rb +1 -1
  97. data/app/controllers/decidim/user_conversations_controller.rb +1 -11
  98. data/app/events/decidim/soft_delete_resource_event.rb +15 -0
  99. data/app/forms/decidim/account_form.rb +2 -5
  100. data/app/forms/decidim/amendable/form.rb +4 -2
  101. data/app/forms/decidim/ephemeral_user_form.rb +22 -0
  102. data/app/forms/decidim/notifications_settings_form.rb +1 -0
  103. data/app/forms/decidim/omniauth_registration_form.rb +14 -1
  104. data/app/helpers/concerns/decidim/flash_helper_extensions.rb +17 -2
  105. data/app/helpers/decidim/action_authorization_helper.rb +75 -14
  106. data/app/helpers/decidim/amendments_helper.rb +0 -9
  107. data/app/helpers/decidim/application_helper.rb +6 -2
  108. data/app/helpers/decidim/breadcrumb_helper.rb +6 -0
  109. data/app/helpers/decidim/cache_helper.rb +1 -1
  110. data/app/helpers/decidim/check_boxes_tree_helper.rb +25 -53
  111. data/app/helpers/decidim/decidim_form_helper.rb +0 -44
  112. data/app/helpers/decidim/endorsable_helper.rb +0 -10
  113. data/app/helpers/decidim/layout_helper.rb +6 -0
  114. data/app/helpers/decidim/messaging/conversation_helper.rb +2 -3
  115. data/app/helpers/decidim/meta_tags_helper.rb +32 -23
  116. data/app/helpers/decidim/modal_helper.rb +23 -0
  117. data/app/helpers/decidim/omniauth_helper.rb +5 -5
  118. data/app/helpers/decidim/onboarding_action_helper.rb +13 -0
  119. data/app/helpers/decidim/orders_helper.rb +1 -2
  120. data/app/helpers/decidim/participatory_space_helpers.rb +1 -1
  121. data/app/helpers/decidim/passwords_helper.rb +2 -2
  122. data/app/helpers/decidim/taxonomies_helper.rb +40 -0
  123. data/app/jobs/decidim/download_your_data_export_job.rb +2 -19
  124. data/app/jobs/decidim/event_publisher_job.rb +18 -9
  125. data/app/jobs/decidim/export_job.rb +5 -1
  126. data/app/jobs/decidim/export_participatory_space_job.rb +4 -1
  127. data/app/jobs/decidim/open_data_job.rb +4 -4
  128. data/app/mailers/decidim/export_mailer.rb +7 -12
  129. data/app/mailers/decidim/reported_mailer.rb +0 -1
  130. data/app/models/decidim/action_log.rb +20 -1
  131. data/app/models/decidim/category.rb +4 -0
  132. data/app/models/decidim/component.rb +25 -3
  133. data/app/models/decidim/metric.rb +2 -1
  134. data/app/models/decidim/moderation.rb +16 -0
  135. data/app/models/decidim/newsletter.rb +12 -8
  136. data/app/models/decidim/organization.rb +7 -3
  137. data/app/models/decidim/participatory_space_private_user.rb +20 -0
  138. data/app/models/decidim/private_export.rb +24 -0
  139. data/app/models/decidim/push_notification_message.rb +1 -1
  140. data/app/models/decidim/report.rb +1 -1
  141. data/app/models/decidim/scope.rb +4 -0
  142. data/app/models/decidim/share_token.rb +36 -10
  143. data/app/models/decidim/taxonomization.rb +23 -0
  144. data/app/models/decidim/taxonomy.rb +139 -0
  145. data/app/models/decidim/taxonomy_filter.rb +130 -0
  146. data/app/models/decidim/taxonomy_filter_item.rb +33 -0
  147. data/app/models/decidim/user.rb +13 -23
  148. data/app/models/decidim/user_base_entity.rb +12 -4
  149. data/app/models/decidim/user_moderation.rb +9 -0
  150. data/app/models/decidim/user_report.rb +4 -0
  151. data/app/packs/entrypoints/decidim_core.js +1 -0
  152. data/app/packs/entrypoints/decidim_geocoding.js +2 -0
  153. data/app/packs/images/decidim/brands/facebook.svg +10 -0
  154. data/app/packs/images/decidim/brands/google.svg +7 -1
  155. data/app/packs/images/decidim/brands/twitter-x.svg +3 -0
  156. data/app/packs/src/decidim/check_boxes_tree.js +0 -1
  157. data/app/packs/src/decidim/clipboard.js +18 -9
  158. data/app/packs/src/decidim/confirm.js +79 -59
  159. data/app/packs/src/decidim/datepicker/datepicker_functions.js +3 -3
  160. data/app/packs/src/decidim/decidim_application.js +1 -0
  161. data/app/packs/src/decidim/form_remote.js +1 -1
  162. data/app/packs/src/decidim/geocoding/reverse_geocoding.js +60 -0
  163. data/app/packs/src/decidim/impersonation.js +1 -1
  164. data/app/packs/src/decidim/index.js +13 -5
  165. data/app/packs/src/decidim/map/provider/here.js +1 -1
  166. data/app/packs/src/decidim/onboarding_pending_action.js +24 -0
  167. data/app/packs/src/decidim/session_timeouter.js +1 -1
  168. data/app/packs/src/decidim/sticky_footer.js +29 -0
  169. data/app/packs/src/decidim/sticky_header.js +6 -31
  170. data/app/packs/src/decidim/user_registrations.js +13 -0
  171. data/app/packs/src/decidim/utilities/dom.js +148 -0
  172. data/app/packs/src/decidim/vendor/leaflet-tilelayer-here.js +212 -0
  173. data/app/packs/stylesheets/decidim/_accordion.scss +30 -0
  174. data/app/packs/stylesheets/decidim/_buttons.scss +19 -0
  175. data/app/packs/stylesheets/decidim/_content_blocks.scss +0 -4
  176. data/app/packs/stylesheets/decidim/_dropdown.scss +1 -1
  177. data/app/packs/stylesheets/decidim/_endorsers_list.scss +26 -20
  178. data/app/packs/stylesheets/decidim/_forms.scss +2 -2
  179. data/app/packs/stylesheets/decidim/_header.scss +2 -6
  180. data/app/packs/stylesheets/decidim/_layout.scss +32 -2
  181. data/app/packs/stylesheets/decidim/_login.scss +53 -6
  182. data/app/packs/stylesheets/decidim/_modal.scss +42 -0
  183. data/app/packs/stylesheets/decidim/_modal_tos_refuse.scss +4 -0
  184. data/app/packs/stylesheets/decidim/_participatory_spaces.scss +46 -0
  185. data/app/packs/stylesheets/decidim/_profile.scss +1 -1
  186. data/app/packs/stylesheets/decidim/_success_image.scss +64 -0
  187. data/app/packs/stylesheets/decidim/_tribute.scss +36 -0
  188. data/app/packs/stylesheets/decidim/application.scss +1 -1
  189. data/app/packs/stylesheets/decidim/geocoding_addons.scss +5 -0
  190. data/app/packs/stylesheets/decidim/map.scss +7 -10
  191. data/app/packs/stylesheets/decidim/resource_history.scss +31 -0
  192. data/app/permissions/decidim/permissions.rb +8 -2
  193. data/app/presenters/decidim/admin_log/base_user_presenter.rb +67 -0
  194. data/app/presenters/decidim/admin_log/component_presenter.rb +32 -3
  195. data/app/presenters/decidim/admin_log/moderation_presenter.rb +30 -3
  196. data/app/presenters/decidim/admin_log/share_token_presenter.rb +39 -0
  197. data/app/presenters/decidim/admin_log/taxonomy_filter_presenter.rb +57 -0
  198. data/app/presenters/decidim/admin_log/taxonomy_presenter.rb +48 -0
  199. data/app/presenters/decidim/admin_log/user_group_presenter.rb +6 -6
  200. data/app/presenters/decidim/admin_log/user_presenter.rb +4 -18
  201. data/app/presenters/decidim/log/user_presenter.rb +0 -1
  202. data/app/presenters/decidim/log/value_types/date_presenter.rb +1 -0
  203. data/app/presenters/decidim/log/value_types/taxonomy_presenter.rb +29 -0
  204. data/app/presenters/decidim/participatory_space_private_user_presenter.rb +50 -0
  205. data/app/presenters/decidim/taxonomy_filter_presenter.rb +19 -0
  206. data/app/presenters/decidim/taxonomy_presenter.rb +14 -0
  207. data/app/presenters/decidim/user_presenter.rb +1 -1
  208. data/app/queries/decidim/metrics/blocked_users_metric_manage.rb +2 -2
  209. data/app/queries/decidim/metrics/users_metric_manage.rb +2 -2
  210. data/app/queries/decidim/public_activities.rb +1 -12
  211. data/app/queries/decidim/stats_users_count.rb +2 -2
  212. data/app/resolvers/decidim/meta_image_url_resolver.rb +128 -0
  213. data/app/serializers/decidim/exporters/open_data_blocked_user_serializer.rb +25 -0
  214. data/app/serializers/decidim/exporters/open_data_metric_serializer.rb +22 -0
  215. data/app/serializers/decidim/exporters/open_data_moderation_serializer.rb +30 -0
  216. data/app/serializers/decidim/exporters/open_data_taxonomy_serializer.rb +30 -0
  217. data/app/serializers/decidim/exporters/open_data_user_group_serializer.rb +38 -0
  218. data/app/serializers/decidim/exporters/open_data_user_serializer.rb +39 -0
  219. data/app/serializers/decidim/exporters/participatory_space_serializer.rb +104 -0
  220. data/app/serializers/decidim/exporters/serializer.rb +25 -0
  221. data/app/serializers/decidim/schema_org_breadcrumb_list_serializer.rb +52 -0
  222. data/app/services/decidim/action_authorizer.rb +32 -3
  223. data/app/services/decidim/base_diff_renderer.rb +1 -3
  224. data/app/services/decidim/download_your_data_exporter.rb +58 -24
  225. data/app/services/decidim/onboarding_manager.rb +272 -0
  226. data/app/services/decidim/open_data_exporter.rb +139 -13
  227. data/app/services/decidim/static_map_generator.rb +1 -1
  228. data/app/services/decidim/traceability.rb +13 -0
  229. data/app/uploaders/decidim/application_uploader.rb +1 -1
  230. data/app/validators/etiquette_validator.rb +9 -2
  231. data/app/validators/passthru_validator.rb +1 -1
  232. data/app/validators/translated_etiquette_validator.rb +32 -0
  233. data/app/views/decidim/account/_password_fields.html.erb +2 -2
  234. data/app/views/decidim/application/_accordion_section.html.erb +14 -0
  235. data/app/views/decidim/application/_collection.html.erb +30 -18
  236. data/app/views/decidim/devise/omniauth_registrations/new.html.erb +5 -1
  237. data/app/views/decidim/devise/omniauth_registrations/new_tos_fields.html.erb +29 -0
  238. data/app/views/decidim/devise/registrations/new.html.erb +10 -22
  239. data/app/views/decidim/devise/sessions/new.html.erb +24 -29
  240. data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +2 -4
  241. data/app/views/decidim/devise/shared/_tos_fields.html.erb +16 -0
  242. data/app/views/decidim/download_your_data/_export.html.erb +15 -0
  243. data/app/views/decidim/download_your_data/show.html.erb +51 -5
  244. data/app/views/decidim/endorsements/update_buttons_and_counters.js.erb +16 -19
  245. data/app/views/decidim/export_mailer/download_your_data_export.html.erb +2 -2
  246. data/app/views/decidim/export_mailer/export.html.erb +5 -1
  247. data/app/views/decidim/last_activities/index.html.erb +1 -1
  248. data/app/views/decidim/notifications_settings/show.html.erb +22 -0
  249. data/app/views/decidim/open_data/_how_to_open_accordion_section.html.erb +15 -0
  250. data/app/views/decidim/open_data/index.html.erb +108 -0
  251. data/app/views/decidim/pages/show.html.erb +2 -1
  252. data/app/views/decidim/participatory_space_private_users/_participatory_space_private_user.html.erb +1 -0
  253. data/app/views/decidim/reported_mailer/hide.html.erb +1 -17
  254. data/app/views/decidim/reported_mailer/report.html.erb +1 -1
  255. data/app/views/decidim/searches/_count.html.erb +1 -1
  256. data/app/views/decidim/searches/_filters.html.erb +38 -40
  257. data/app/views/decidim/shared/_login_modal.html.erb +26 -20
  258. data/app/views/decidim/shared/_orders.html.erb +2 -2
  259. data/app/views/decidim/shared/_resource_actions.html.erb +21 -0
  260. data/app/views/decidim/shared/filters/_check_boxes_tree.html.erb +1 -2
  261. data/app/views/decidim/shared/filters/_collection.html.erb +1 -1
  262. data/app/views/decidim/shared/filters/_dropdown_label.html.erb +7 -4
  263. data/app/views/layouts/decidim/_application.html.erb +0 -1
  264. data/app/views/layouts/decidim/_js_configuration.html.erb +1 -0
  265. data/app/views/layouts/decidim/_logo.html.erb +1 -1
  266. data/app/views/layouts/decidim/_logo_mobile.html.erb +1 -1
  267. data/app/views/layouts/decidim/_meta_tags_config.html.erb +6 -11
  268. data/app/views/layouts/decidim/_schema_org_breadcrumb_list.html.erb +3 -0
  269. data/app/views/layouts/decidim/_wrapper.html.erb +15 -9
  270. data/app/views/layouts/decidim/footer/_main_legal.html.erb +1 -1
  271. data/app/views/layouts/decidim/footer/_main_links.html.erb +1 -1
  272. data/app/views/layouts/decidim/header/_close_ephemeral_session.html.erb +25 -0
  273. data/app/views/layouts/decidim/header/_main.html.erb +14 -10
  274. data/app/views/layouts/decidim/header/_menu_breadcrumb_items.html.erb +2 -0
  275. data/app/views/layouts/decidim/shared/_layout_item.html.erb +1 -1
  276. data/config/assets.rb +2 -1
  277. data/config/locales/ar.yml +29 -74
  278. data/config/locales/bg.yml +27 -74
  279. data/config/locales/bs-BA.yml +0 -2
  280. data/config/locales/ca.yml +369 -90
  281. data/config/locales/cs.yml +370 -84
  282. data/config/locales/de.yml +348 -72
  283. data/config/locales/el.yml +16 -58
  284. data/config/locales/en.yml +349 -70
  285. data/config/locales/eo.yml +0 -4
  286. data/config/locales/es-MX.yml +362 -86
  287. data/config/locales/es-PY.yml +367 -91
  288. data/config/locales/es.yml +369 -90
  289. data/config/locales/eu.yml +422 -140
  290. data/config/locales/fi-plain.yml +360 -76
  291. data/config/locales/fi.yml +364 -77
  292. data/config/locales/fr-CA.yml +172 -83
  293. data/config/locales/fr.yml +172 -80
  294. data/config/locales/ga-IE.yml +4 -25
  295. data/config/locales/gl.yml +15 -58
  296. data/config/locales/hu.yml +24 -62
  297. data/config/locales/id-ID.yml +16 -57
  298. data/config/locales/is-IS.yml +0 -25
  299. data/config/locales/it.yml +31 -94
  300. data/config/locales/ja.yml +226 -97
  301. data/config/locales/lb.yml +23 -76
  302. data/config/locales/lt.yml +18 -64
  303. data/config/locales/lv.yml +16 -58
  304. data/config/locales/nl.yml +18 -75
  305. data/config/locales/no.yml +18 -70
  306. data/config/locales/pl.yml +24 -72
  307. data/config/locales/pt-BR.yml +35 -63
  308. data/config/locales/pt.yml +18 -70
  309. data/config/locales/ro-RO.yml +109 -188
  310. data/config/locales/ru.yml +8 -43
  311. data/config/locales/sk.yml +19 -70
  312. data/config/locales/sl.yml +0 -4
  313. data/config/locales/sr-CS.yml +0 -2
  314. data/config/locales/sv.yml +127 -79
  315. data/config/locales/tr-TR.yml +24 -74
  316. data/config/locales/uk.yml +1 -29
  317. data/config/locales/zh-CN.yml +16 -68
  318. data/config/locales/zh-TW.yml +17 -62
  319. data/config/routes.rb +4 -10
  320. data/db/migrate/20181025082245_add_timestamps_to_components.rb +2 -0
  321. data/db/migrate/20240628111905_add_visible_to_components.rb +7 -0
  322. data/db/migrate/20240704115429_create_decidim_taxonomies.rb +23 -0
  323. data/db/migrate/20240717093514_add_registered_only_to_decidim_share_tokens.rb +7 -0
  324. data/db/migrate/20240722215500_change_object_changes_on_versions.rb +39 -0
  325. data/db/migrate/20240806065417_create_decidim_taxonomy_filters.rb +23 -0
  326. data/db/migrate/20240822161348_add_deleted_at_to_decidim_components.rb +8 -0
  327. data/db/migrate/20240906162524_add_part_of_to_taxonomies.rb +26 -0
  328. data/db/migrate/20241001135825_add_role_to_participatory_space_private_users.rb +7 -0
  329. data/db/migrate/20241001140408_add_published_to_participatory_space_private_users.rb +7 -0
  330. data/db/migrate/20241022002600_create_private_exports.rb +18 -0
  331. data/db/migrate/20241028114430_add_component_counter_to_taxonomy_filters.rb +7 -0
  332. data/db/migrate/20241111104357_add_names_and_space_boolean_to_taxonomy_filters.rb +9 -0
  333. data/db/migrate/20241127093708_add_taxonomy_to_metrics.rb +7 -0
  334. data/db/migrate/20241204121445_add_participatory_space_manifests_from_taxonomy_filters.rb +9 -0
  335. data/decidim-core.gemspec +14 -17
  336. data/lib/decidim/action_authorization.rb +3 -2
  337. data/lib/decidim/amendable.rb +1 -1
  338. data/lib/decidim/api/input_filters/category_input_filter.rb +5 -3
  339. data/lib/decidim/api/input_filters/component_input_filter.rb +33 -20
  340. data/lib/decidim/api/input_filters/user_entity_input_filter.rb +53 -44
  341. data/lib/decidim/api/input_sorts/component_input_sort.rb +15 -13
  342. data/lib/decidim/api/input_sorts/user_entity_input_sort.rb +4 -4
  343. data/lib/decidim/api/interfaces/author_interface.rb +3 -2
  344. data/lib/decidim/api/interfaces/coauthorable_interface.rb +5 -5
  345. data/lib/decidim/api/interfaces/endorsable_interface.rb +2 -2
  346. data/lib/decidim/api/interfaces/participatory_space_interface.rb +5 -10
  347. data/lib/decidim/api/interfaces/taxonomizable_interface.rb +13 -0
  348. data/lib/decidim/api/types/amendment_type.rb +5 -7
  349. data/lib/decidim/api/types/area_api_type.rb +3 -3
  350. data/lib/decidim/api/types/attachment_type.rb +3 -3
  351. data/lib/decidim/api/types/category_type.rb +2 -2
  352. data/lib/decidim/api/types/decidim_type.rb +5 -1
  353. data/lib/decidim/api/types/fingerprint_type.rb +1 -1
  354. data/lib/decidim/api/types/localized_string_type.rb +1 -1
  355. data/lib/decidim/api/types/metric_history_type.rb +2 -0
  356. data/lib/decidim/api/types/metric_type.rb +1 -1
  357. data/lib/decidim/api/types/organization_type.rb +5 -0
  358. data/lib/decidim/api/types/participatory_space_link_type.rb +2 -2
  359. data/lib/decidim/api/types/participatory_space_manifest_type.rb +1 -1
  360. data/lib/decidim/api/types/quantifiable_translated_field_type.rb +1 -1
  361. data/lib/decidim/api/types/scope_api_type.rb +2 -3
  362. data/lib/decidim/api/types/session_type.rb +1 -2
  363. data/lib/decidim/api/types/taxonomy_type.rb +15 -0
  364. data/lib/decidim/api/types/trace_version_type.rb +2 -2
  365. data/lib/decidim/api/types/translated_field_type.rb +3 -5
  366. data/lib/decidim/api/types/user_group_type.rb +7 -20
  367. data/lib/decidim/api/types/user_type.rb +7 -20
  368. data/lib/decidim/asset_router/storage.rb +6 -11
  369. data/lib/decidim/assets/tailwind/tailwind.config.js.erb +2 -1
  370. data/lib/decidim/attachment_attributes.rb +1 -1
  371. data/lib/decidim/attribute_encryptor.rb +1 -1
  372. data/lib/decidim/attribute_object/nested_validator.rb +1 -1
  373. data/lib/decidim/attributes/integer_with_units.rb +27 -0
  374. data/lib/decidim/attributes/time_with_zone.rb +1 -5
  375. data/lib/decidim/attributes.rb +2 -0
  376. data/lib/decidim/authorization_form_builder.rb +0 -7
  377. data/lib/decidim/coauthorable.rb +1 -1
  378. data/lib/decidim/command.rb +3 -3
  379. data/lib/decidim/commands/destroy_resource.rb +5 -1
  380. data/lib/decidim/commands/resource_handler.rb +2 -2
  381. data/lib/decidim/commands/restore_resource.rb +45 -0
  382. data/lib/decidim/commands/soft_delete_resource.rb +63 -0
  383. data/lib/decidim/component_manifest.rb +7 -0
  384. data/lib/decidim/content_parsers/blob_parser.rb +8 -10
  385. data/lib/decidim/content_parsers/user_parser.rb +1 -1
  386. data/lib/decidim/core/api.rb +2 -0
  387. data/lib/decidim/core/engine.rb +21 -7
  388. data/lib/decidim/core/menu.rb +0 -5
  389. data/lib/decidim/core/seeds.rb +42 -2
  390. data/lib/decidim/core/test/factories.rb +105 -2
  391. data/lib/decidim/core/test/shared_examples/admin_resource_gallery_examples.rb +85 -0
  392. data/lib/decidim/core/test/shared_examples/comments_examples.rb +393 -38
  393. data/lib/decidim/core/test/shared_examples/components_controller_hide_shared_examples.rb +11 -0
  394. data/lib/decidim/core/test/shared_examples/components_controller_reorder_shared_examples.rb +21 -0
  395. data/lib/decidim/core/test/shared_examples/download_open_data_shared_context.rb +36 -0
  396. data/lib/decidim/core/test/shared_examples/download_open_data_shared_examples.rb +45 -0
  397. data/lib/decidim/core/test/shared_examples/download_your_data_shared_examples.rb +17 -0
  398. data/lib/decidim/core/test/shared_examples/etiquette_validator_examples.rb +25 -0
  399. data/lib/decidim/core/test/shared_examples/follows_examples.rb +43 -0
  400. data/lib/decidim/core/test/shared_examples/has_taxonomies.rb +94 -0
  401. data/lib/decidim/core/test/shared_examples/manage_share_tokens_examples.rb +237 -0
  402. data/lib/decidim/core/test/shared_examples/map_examples.rb +2 -0
  403. data/lib/decidim/core/test/shared_examples/open_data_exporter_examples.rb +102 -0
  404. data/lib/decidim/core/test/shared_examples/participatory_space_members_page_examples.rb +46 -0
  405. data/lib/decidim/core/test/shared_examples/participatory_space_search_examples.rb +98 -0
  406. data/lib/decidim/core/test/shared_examples/permissions.rb +7 -7
  407. data/lib/decidim/core/test/shared_examples/preview_with_share_token_examples.rb +94 -0
  408. data/lib/decidim/core/test/shared_examples/reports_examples.rb +15 -53
  409. data/lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb +2 -2
  410. data/lib/decidim/core/test/shared_examples/resource_search_examples.rb +75 -69
  411. data/lib/decidim/core/test/shared_examples/searchable_resources_shared_context.rb +1 -1
  412. data/lib/decidim/core/test/shared_examples/simple_event.rb +33 -19
  413. data/lib/decidim/core/test/shared_examples/social_share_examples.rb +7 -14
  414. data/lib/decidim/core/test/shared_examples/softdeleteable_components_examples.rb +173 -0
  415. data/lib/decidim/core/test/shared_examples/system_endorse_resource_examples.rb +54 -8
  416. data/lib/decidim/core/test/shared_examples/taxonomizable_interface_examples.rb +20 -0
  417. data/lib/decidim/core/test/shared_examples/taxonomizable_resource_examples.rb +37 -0
  418. data/lib/decidim/core/test/shared_examples/taxonomy_settings.rb +49 -0
  419. data/lib/decidim/core/test/shared_examples/translated_event_examples.rb +1 -1
  420. data/lib/decidim/core/test/shared_examples/uncommentable_component_examples.rb +0 -26
  421. data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +2 -28
  422. data/lib/decidim/core/test/shared_examples/with_endorsable_permissions_examples.rb +1 -1
  423. data/lib/decidim/core/test.rb +9 -5
  424. data/lib/decidim/core/version.rb +1 -1
  425. data/lib/decidim/core.rb +58 -0
  426. data/lib/decidim/download_your_data_serializers/download_your_data_identity_serializer.rb +0 -4
  427. data/lib/decidim/download_your_data_serializers/download_your_data_participatory_space_private_user_serializer.rb +3 -1
  428. data/lib/decidim/download_your_data_serializers/download_your_data_report_serializer.rb +2 -1
  429. data/lib/decidim/download_your_data_serializers/download_your_data_user_serializer.rb +6 -7
  430. data/lib/decidim/download_your_data_serializers.rb +19 -0
  431. data/lib/decidim/exporters/csv.rb +6 -0
  432. data/lib/decidim/exporters/export_manifest.rb +14 -0
  433. data/lib/decidim/exporters/pdf.rb +26 -22
  434. data/lib/decidim/filter_form_builder.rb +12 -15
  435. data/lib/decidim/form_builder.rb +6 -129
  436. data/lib/decidim/has_category.rb +5 -1
  437. data/lib/decidim/has_private_users.rb +4 -0
  438. data/lib/decidim/has_taxonomy_settings.rb +47 -0
  439. data/lib/decidim/has_upload_validations.rb +1 -1
  440. data/lib/decidim/legacy_form_builder.rb +118 -0
  441. data/lib/decidim/maintenance/import_models/application_record.rb +93 -0
  442. data/lib/decidim/maintenance/import_models/area.rb +82 -0
  443. data/lib/decidim/maintenance/import_models/area_type.rb +12 -0
  444. data/lib/decidim/maintenance/import_models/assembly_type.rb +49 -0
  445. data/lib/decidim/maintenance/import_models/categorization.rb +14 -0
  446. data/lib/decidim/maintenance/import_models/category.rb +107 -0
  447. data/lib/decidim/maintenance/import_models/participatory_process_type.rb +21 -0
  448. data/lib/decidim/maintenance/import_models/scope.rb +163 -0
  449. data/lib/decidim/maintenance/import_models.rb +19 -0
  450. data/lib/decidim/maintenance/taxonomy_importer.rb +132 -0
  451. data/lib/decidim/maintenance/taxonomy_plan.rb +78 -0
  452. data/lib/decidim/maintenance.rb +12 -0
  453. data/lib/decidim/map/autocomplete.rb +52 -8
  454. data/lib/decidim/map/dynamic_map.rb +1 -1
  455. data/lib/decidim/map/provider/dynamic_map/here.rb +40 -1
  456. data/lib/decidim/map/provider/geocoding/here.rb +9 -3
  457. data/lib/decidim/map/provider/static_map/here.rb +0 -34
  458. data/lib/decidim/map.rb +3 -6
  459. data/lib/decidim/moderation_tools.rb +16 -19
  460. data/lib/decidim/newsletter_encryptor.rb +1 -1
  461. data/lib/decidim/nicknamizable.rb +1 -1
  462. data/lib/decidim/paddable.rb +1 -1
  463. data/lib/decidim/participable.rb +10 -10
  464. data/lib/decidim/participatory_space_user.rb +10 -0
  465. data/lib/decidim/private_download_helper.rb +15 -0
  466. data/lib/decidim/record_encryptor.rb +51 -46
  467. data/lib/decidim/reportable.rb +2 -6
  468. data/lib/decidim/resourceable.rb +16 -0
  469. data/lib/decidim/seeds.rb +18 -20
  470. data/lib/decidim/settings_manifest.rb +34 -1
  471. data/lib/decidim/soft_deletable.rb +17 -0
  472. data/lib/decidim/taxonomizable.rb +72 -0
  473. data/lib/decidim/translatable_attributes.rb +1 -5
  474. data/lib/decidim/view_model.rb +0 -1
  475. data/lib/tasks/decidim_download_your_data_tasks.rake +2 -4
  476. data/lib/tasks/decidim_procfile.rake +6 -0
  477. data/lib/tasks/decidim_tasks.rake +1 -0
  478. data/lib/tasks/decidim_taxonomies.rake +155 -0
  479. data/lib/tasks/upgrade/{decidim_fix_categorization.rake → clean.rake} +25 -18
  480. data/lib/tasks/upgrade/decidim_active_storage_migration_tasks.rake +1 -1
  481. data/lib/tasks/upgrade/decidim_fix_nickname_uniqueness.rake +20 -23
  482. data/lib/tasks/upgrade/migrations.rake +91 -0
  483. metadata +202 -110
  484. data/app/cells/decidim/amendable/amenders_list/show.erb +0 -0
  485. data/app/cells/decidim/content_blocks/base/content.erb +0 -0
  486. data/app/cells/decidim/endorsers_list/full_endorsers_list.erb +0 -3
  487. data/app/cells/decidim/endorsers_list_button/content.erb +0 -1
  488. data/app/cells/decidim/endorsers_list_button_cell.rb +0 -15
  489. data/app/cells/decidim/report_user_button/already_reported_modal.erb +0 -11
  490. data/app/cells/decidim/report_user_button/flag_modal.erb +0 -46
  491. data/app/cells/decidim/report_user_button/show.erb +0 -2
  492. data/app/cells/decidim/report_user_button_cell.rb +0 -59
  493. data/app/cells/decidim/scopes_picker/scope_picker_prompt.erb +0 -3
  494. data/app/cells/decidim/scopes_picker/scope_picker_values.erb +0 -5
  495. data/app/cells/decidim/scopes_picker/show.erb +0 -14
  496. data/app/cells/decidim/scopes_picker_cell.rb +0 -92
  497. data/app/commands/decidim/update_user_interests.rb +0 -41
  498. data/app/controllers/decidim/scopes_controller.rb +0 -84
  499. data/app/controllers/decidim/user_interests_controller.rb +0 -30
  500. data/app/forms/decidim/user_interest_scope_form.rb +0 -25
  501. data/app/forms/decidim/user_interests_form.rb +0 -17
  502. data/app/helpers/decidim/categories_helper.rb +0 -26
  503. data/app/helpers/decidim/scopes_helper.rb +0 -105
  504. data/app/jobs/decidim/hide_child_resources_job.rb +0 -24
  505. data/app/packs/images/decidim/vendor/leaflet/layers-2x.png +0 -0
  506. data/app/packs/images/decidim/vendor/leaflet/layers.png +0 -0
  507. data/app/packs/images/decidim/vendor/leaflet/marker-icon-2x.png +0 -0
  508. data/app/packs/images/decidim/vendor/leaflet/marker-icon.png +0 -0
  509. data/app/packs/images/decidim/vendor/leaflet/marker-shadow.png +0 -0
  510. data/app/packs/stylesheets/decidim/_hashtags.scss +0 -5
  511. data/app/packs/stylesheets/decidim/legacy/MarkerCluster.Default.scss +0 -67
  512. data/app/packs/stylesheets/decidim/legacy/MarkerCluster.scss +0 -18
  513. data/app/packs/stylesheets/decidim/legacy/leaflet.scss +0 -705
  514. data/app/validators/scope_belongs_to_component_validator.rb +0 -16
  515. data/app/views/decidim/account/_user_groups.html.erb +0 -0
  516. data/app/views/decidim/scopes/_scopes_picker_input.html.erb +0 -19
  517. data/app/views/decidim/scopes/picker.html.erb +0 -53
  518. data/app/views/decidim/shared/_comments.html.erb +0 -0
  519. data/app/views/decidim/shared/_share_modal.html.erb +0 -26
  520. data/app/views/decidim/shared/_tags.html.erb +0 -1
  521. data/app/views/decidim/user_interests/_areas.html.erb +0 -14
  522. data/app/views/decidim/user_interests/_scopes.html.erb +0 -22
  523. data/app/views/decidim/user_interests/show.html.erb +0 -22
  524. data/config/initializers/foundation_rails_helper.rb +0 -4
  525. data/config/locales/ca-IT.yml +0 -2111
  526. data/lib/decidim/core/test/shared_examples/has_category.rb +0 -38
  527. data/lib/decidim/core/test/shared_examples/has_scope.rb +0 -11
  528. data/lib/decidim/core/test/shared_examples/manage_component_share_tokens.rb +0 -83
  529. data/lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb +0 -49
  530. data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +0 -93
  531. data/lib/decidim/seven_zip_wrapper.rb +0 -29
  532. data/lib/tasks/upgrade/clean_hidden_resources.rake +0 -33
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Maintenance
5
+ class TaxonomyImporter
6
+ def initialize(organization, roots)
7
+ @organization = organization
8
+ @roots = roots
9
+ @result = { taxonomy_map: {}, taxonomies_created: [], taxonomies_assigned: {}, filters_created: {}, components_assigned: {}, failed_resources: [], failed_components: [] }
10
+ end
11
+
12
+ attr_reader :organization, :roots, :result
13
+
14
+ def import!(&)
15
+ roots.each do |name, element|
16
+ root = find_taxonomy!(root_taxonomies, name)
17
+ element["taxonomies"].each do |item_name, taxonomy|
18
+ import_taxonomy_item(root, item_name, taxonomy)
19
+ yield "Taxonomy imported", item_name if block_given?
20
+ end
21
+ element["filters"].each do |filter|
22
+ import_filter(root, filter)
23
+ yield "Filter imported", filter["name"] if block_given?
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def import_taxonomy_item(parent, name, item)
31
+ taxonomy = find_taxonomy!(parent.children, name)
32
+ taxonomy.update!(name: item["name"]) if item["name"].present?
33
+ result[:taxonomy_map][taxonomy.id] = item["origin"]
34
+
35
+ item["resources"].each do |object_id, _name|
36
+ apply_taxonomy_to_resource(object_id, taxonomy)
37
+ end
38
+ item["children"].each do |child_name, child|
39
+ import_taxonomy_item(taxonomy, child_name, child)
40
+ end
41
+ end
42
+
43
+ def apply_taxonomy_to_resource(object_id, taxonomy)
44
+ resource = GlobalID::Locator.locate(object_id)
45
+ return result[:failed_resources] << object_id unless resource
46
+
47
+ name = taxonomy.name[organization.default_locale]
48
+
49
+ begin
50
+ if resource.respond_to? :taxonomy
51
+ resource.update(decidim_taxonomy_id: taxonomy.id)
52
+ else
53
+ return if resource.taxonomies.include?(taxonomy)
54
+
55
+ resource.taxonomies << taxonomy
56
+ end
57
+ result[:taxonomies_assigned][name] ||= []
58
+ result[:taxonomies_assigned][name] << object_id unless result[:taxonomies_assigned][name].include?(object_id)
59
+ rescue ActiveRecord::RecordInvalid
60
+ result[:failed_resources] << object_id
61
+ end
62
+ end
63
+
64
+ def import_filter(root, data)
65
+ filter = find_taxonomy_filter!(root, data)
66
+
67
+ data["items"].each do |item_names|
68
+ taxonomy = root
69
+ item_names.each do |item_name|
70
+ taxonomy = find_taxonomy!(taxonomy.children, item_name)
71
+ end
72
+ next if filter.filter_items.exists?(taxonomy_item: taxonomy)
73
+
74
+ filter.filter_items.create!(taxonomy_item: taxonomy) do
75
+ result[:filters_created][filter.internal_name[organization.default_locale]] ||= []
76
+ result[:filters_created][filter.internal_name[organization.default_locale]] << item_names.join(" > ")
77
+ end
78
+ end
79
+
80
+ data["components"].each do |component_id|
81
+ component = GlobalID::Locator.locate(component_id)
82
+ if component
83
+ begin
84
+ component.update!(settings: { taxonomy_filters: [filter.id.to_s] })
85
+ result[:components_assigned][filter.internal_name[organization.default_locale]] ||= []
86
+ result[:components_assigned][filter.internal_name[organization.default_locale]] << component_id
87
+ rescue ActiveRecord::RecordInvalid
88
+ result[:failed_components] << component_id
89
+ end
90
+ else
91
+ result[:failed_components] << component_id
92
+ end
93
+ end
94
+ end
95
+
96
+ def find_taxonomy(association, name)
97
+ association.find_by("name->>? = ?", organization.default_locale, name)
98
+ end
99
+
100
+ def find_taxonomy!(association, name)
101
+ find_taxonomy(association, name) || create_taxonomy!(association, name)
102
+ end
103
+
104
+ def create_taxonomy!(association, name)
105
+ association.create!(name: { organization.default_locale => name }, organization:) do
106
+ result[:taxonomies_created] << name
107
+ end
108
+ end
109
+
110
+ def find_taxonomy_filter!(root_taxonomy, data)
111
+ name = data["internal_name"] || data["name"]
112
+ attributes = {
113
+ "participatory_space_manifests" => data["participatory_space_manifests"] || []
114
+ }
115
+ attributes["internal_name"] = { organization.default_locale => data["internal_name"] } if data["internal_name"]
116
+ attributes["name"] = { organization.default_locale => data["public_name"] } if data["public_name"]
117
+
118
+ find_taxonomy_filter(root_taxonomy, name:, participatory_space_manifests: data["participatory_space_manifests"]) || root_taxonomy.taxonomy_filters.create!(attributes)
119
+ end
120
+
121
+ def find_taxonomy_filter(root_taxonomy, name:, participatory_space_manifests:)
122
+ root_taxonomy.taxonomy_filters.all.detect do |filter|
123
+ filter.internal_name[organization.default_locale] == name && filter.participatory_space_manifests == participatory_space_manifests
124
+ end
125
+ end
126
+
127
+ def root_taxonomies
128
+ organization.taxonomies.roots
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Maintenance
5
+ class TaxonomyPlan
6
+ def initialize(organization, models, importer: TaxonomyImporter)
7
+ @organization = organization
8
+ @models = models
9
+ @importer = importer
10
+ end
11
+
12
+ attr_reader :organization, :models, :importer
13
+
14
+ def import(data, &)
15
+ data["imported_taxonomies"].each do |model_name, taxonomies|
16
+ klass = importer.new(organization, taxonomies)
17
+ if block_given?
18
+ yield klass, model_name
19
+ else
20
+ klass.import!
21
+ end
22
+ end
23
+ end
24
+
25
+ def to_json(*_args, &)
26
+ I18n.with_locale(organization.default_locale) do
27
+ JSON.pretty_generate(to_h(&))
28
+ end
29
+ end
30
+
31
+ def to_h(&)
32
+ {
33
+ organization: {
34
+ id: organization.id,
35
+ locale: organization.default_locale,
36
+ host: organization.host,
37
+ name: translate(organization.name)
38
+ },
39
+ existing_taxonomies:,
40
+ imported_taxonomies: imported_taxonomies(&)
41
+ }
42
+ end
43
+
44
+ def imported_taxonomies
45
+ return @imported_taxonomies if defined?(@imported_taxonomies)
46
+
47
+ @imported_taxonomies = {}
48
+ models.map do |model|
49
+ yield model if block_given?
50
+ @imported_taxonomies[model.table_name] = model.with(organization).to_taxonomies
51
+ end
52
+ @imported_taxonomies
53
+ end
54
+
55
+ def existing_taxonomies
56
+ organization.taxonomies.roots.to_h do |root|
57
+ [
58
+ translate(root.name),
59
+ root.children.to_h do |taxonomy|
60
+ [
61
+ translate(taxonomy.name),
62
+ taxonomy.children.map do |child|
63
+ translate(child.name)
64
+ end
65
+ ]
66
+ end
67
+ ]
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ def translate(translatable)
74
+ return translatable[organization.default_locale.to_s]
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/maintenance/import_models"
4
+ module Decidim
5
+ # This class should not be imported automatically by the Decidim web app
6
+ # It holds utilities for maintenance tasks (such as importing taxonomies)
7
+ # and compatibility models that might not be longer present in the current Decidim version
8
+ module Maintenance
9
+ autoload :TaxonomyImporter, "decidim/maintenance/taxonomy_importer"
10
+ autoload :TaxonomyPlan, "decidim/maintenance/taxonomy_plan"
11
+ end
12
+ end
@@ -9,24 +9,68 @@ module Decidim
9
9
  # Provides all the necessary functionality to initialize the front-end
10
10
  # geocoding autocompletion functionality.
11
11
  class Builder < Decidim::Map::Frontend::Builder
12
- # Displays the geocoding field element's markup for the view.
12
+ delegate :icon, :content_tag, :asset_pack_path, to: :template
13
+
14
+ # Renders the geocoding field element for the view. If the component supports
15
+ # geolocation (as determined by `show_my_location_button?`), the field will include
16
+ # a button allowing the user to use their current location to autofill the address.
17
+ # Otherwise, a standard geocoding input field is rendered without the location button.
13
18
  #
14
- # @param object_name [String, Symbol] The name for the object for which
15
- # the field is generated for.
16
- # @param method [String, Symbol] The method/property in the object that
17
- # the field is for.
18
- # @param options [Hash] Extra options for the field.
19
- # @return [String] The field element's markup.
19
+ # @param object_name [String, Symbol] The name of the object the field is being generated for.
20
+ # @param method [String, Symbol] The specific attribute or property of the object.
21
+ # @param options [Hash] Additional options for customizing the field's behavior and appearance.
22
+ # @return [String] The HTML markup for the geocoding field.
20
23
  def geocoding_field(object_name, method, options = {})
21
24
  options[:autocomplete] ||= "off"
22
-
23
25
  append_assets
26
+
27
+ if show_my_location_button?
28
+ geocoding_field_with_location_button(object_name, method, options)
29
+ else
30
+ geocoding_field_without_location_button(object_name, method, options)
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def geocoding_field_with_location_button(object_name, method, options)
37
+ template.snippets.add(:decidim_geocoding_scripts, template.append_javascript_pack_tag("decidim_geocoding"))
38
+ template.snippets.add(:decidim_geocoding_styles, template.append_stylesheet_pack_tag("decidim_geocoding"))
39
+
40
+ template.content_tag(:div, class: "geocoding-container") do
41
+ template.text_field(
42
+ object_name,
43
+ method,
44
+ options.merge("data-decidim-geocoding" => view_options.to_json)
45
+ ) +
46
+ template.content_tag(:div, class: "input-group-button user-device-location") do
47
+ template.content_tag(:button, class: "button button__sm md:button__sm button__text-secondary", type: "button", data: {
48
+ input: "#{object_name}_#{method}",
49
+ latitude: "#{object_name}_latitude",
50
+ longitude: "#{object_name}_longitude",
51
+ error_no_location: I18n.t("errors.no_device_location", scope: "decidim.proposals.forms"),
52
+ error_unsupported: I18n.t("errors.device_not_supported", scope: "decidim.proposals.forms"),
53
+ url: Decidim::Core::Engine.routes.url_helpers.locate_path
54
+ }) do
55
+ icon("map-pin-line", role: "img", "aria-hidden": true) + " #{I18n.t("use_my_location", scope: "decidim.proposals.forms")}"
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ def geocoding_field_without_location_button(object_name, method, options)
24
62
  template.text_field(
25
63
  object_name,
26
64
  method,
27
65
  options.merge("data-decidim-geocoding" => view_options.to_json)
28
66
  )
29
67
  end
68
+
69
+ def show_my_location_button?
70
+ return unless template.respond_to?(:current_component)
71
+
72
+ template.current_component.manifest_name.to_sym == :proposals
73
+ end
30
74
  end
31
75
 
32
76
  # This module will be included in the main application's form builder in
@@ -71,7 +71,7 @@ module Decidim
71
71
  content = template.capture { yield }.html_safe if block_given?
72
72
 
73
73
  template.content_tag(:div, map_html_options) do
74
- (content || "")
74
+ content || ""
75
75
  end
76
76
  end
77
77
 
@@ -49,7 +49,46 @@ module Decidim
49
49
  private
50
50
 
51
51
  def language_code
52
- I18n.locale.to_s
52
+ primary = I18n.locale.to_s
53
+ secondary = primary.split("-")[0]
54
+ available_language_codes[primary] || available_language_codes[secondary] || ""
55
+ end
56
+
57
+ def available_language_codes
58
+ @available_language_codes ||= {
59
+ "ar" => "ara", # Arabic
60
+ "eu" => "baq", # Basque
61
+ "ca" => "cat", # Catalan
62
+ "zh" => "chi", # Chinese (simplified)
63
+ # "" => "cht", # Chinese (traditional)
64
+ "cs" => "cze", # Czech
65
+ "da" => "dan", # Danish
66
+ "nl" => "dut", # Dutch
67
+ "en" => "eng", # English
68
+ "fi" => "fin", # Finnish
69
+ "fr" => "fre", # French
70
+ "de" => "ger", # German
71
+ "ga" => "gle", # Gaelic
72
+ "el" => "gre", # Greek
73
+ "he" => "heb", # Hebrew
74
+ "hi" => "hin", # Hindi
75
+ "id" => "ind", # Indonesian
76
+ "it" => "ita", # Italian
77
+ "no" => "nor", # Norwegian
78
+ "fa" => "per", # Persian
79
+ "pl" => "pol", # Polish
80
+ "pt" => "por", # Portuguese
81
+ "ru" => "rus", # Russian
82
+ "si" => "sin", # Sinhalese
83
+ "es" => "spa", # Spanish
84
+ "sv" => "swe", # Swedish
85
+ "th" => "tha", # Thai
86
+ "tr" => "tur", # Turkish
87
+ "uk" => "ukr", # Ukrainian
88
+ "ur" => "urd", # Urdu
89
+ "vi" => "vie", # Vietnamese
90
+ "cy" => "wel" # Welsh
91
+ }
53
92
  end
54
93
  end
55
94
  end
@@ -29,9 +29,7 @@ module Decidim
29
29
  # Some of the matches that have "resultType" == "street" do not even
30
30
  # contain the street name unless they also have the "streets" key in
31
31
  # the "scoring" -> "fieldScore" attribute defined.
32
- street_result = results.find do |r|
33
- r.data["scoring"]["fieldScore"].has_key?("streets")
34
- end
32
+ street_result = find_street_with_name(results)
35
33
  return street_result.address if street_result
36
34
 
37
35
  # Otherwise, sort the results based on their exact distances from
@@ -51,6 +49,14 @@ module Decidim
51
49
 
52
50
  results.first.address
53
51
  end
52
+
53
+ private
54
+
55
+ def find_street_with_name(results)
56
+ results.find do |r|
57
+ r.data && r.data["scoring"] && r.data["scoring"]["fieldScore"] && r.data["scoring"]["fieldScore"].has_key?("streets")
58
+ end
59
+ end
54
60
  end
55
61
  end
56
62
  end
@@ -6,42 +6,8 @@ module Decidim
6
6
  module StaticMap
7
7
  # The static map utility class for the HERE maps service
8
8
  class Here < ::Decidim::Map::StaticMap
9
- def url(latitude:, longitude:, options: {})
10
- map_url = configuration.fetch(:url, nil)
11
- return super unless map_url
12
-
13
- return super unless map_url.include?("mia/v3")
14
-
15
- w = options[:width] || Decidim::Map::StaticMap::DEFAULT_SIZE
16
- h = options[:height] || Decidim::Map::StaticMap::DEFAULT_SIZE
17
-
18
- params = {
19
- apiKey: configuration[:api_key],
20
- overlay: "point:#{latitude},#{longitude};icon=cp;size=large|#{latitude},#{longitude};style=circle;width=50m;color=%231B9D2C60"
21
- }
22
-
23
- URI.parse("#{map_url}:radius=90/#{w}x#{h}/png8").tap do |uri|
24
- uri.query = URI.encode_www_form(params)
25
- end.to_s
26
- end
27
-
28
9
  # @See Decidim::Map::StaticMap#url_params
29
10
  def url_params(latitude:, longitude:, options: {})
30
- ActiveSupport::Deprecation.warn(
31
- <<~DEPRECATION.strip
32
- Please use a V3 version HERE maps.
33
- For further information, see:
34
- https://www.here.com/docs/bundle/map-image-migration-guide-v3/page/README.html
35
- Also make sure your Decidim.maps configurations are using the
36
- up to date format.
37
- You need to change:
38
- static_url = "https://image.maps.ls.hereapi.com/mia/1.6/mapview" if static_provider == "here" && static_url.blank?
39
- to:
40
- static_url = "https://image.maps.hereapi.com/mia/v3/base/mc/overlay" if static_provider == "here"
41
- in your config/initializers/decidim.rb file.
42
- DEPRECATION
43
- )
44
-
45
11
  params = {
46
12
  c: "#{latitude}, #{longitude}",
47
13
  z: options[:zoom] || Decidim::Map::StaticMap::DEFAULT_ZOOM,
data/lib/decidim/map.rb CHANGED
@@ -73,12 +73,9 @@ module Decidim
73
73
  @utility_modules ||= {}
74
74
  @utility_modules[category] = mod
75
75
 
76
- # Dynamically define the category method.
77
- module_eval %{
78
- def self.#{category}(options) # def self.dynamic(options)
79
- utility(:#{category}, options) # utility(:dynamic, options)
80
- end # end
81
- }, __FILE__, __LINE__ - 4
76
+ define_singleton_method(category) do |options|
77
+ utility(category, options)
78
+ end
82
79
 
83
80
  mod
84
81
  end
@@ -28,12 +28,16 @@ module Decidim
28
28
 
29
29
  # Public: fetches the participatory space of the resource's component or from the resource itself
30
30
  def participatory_space
31
- @participatory_space ||= @reportable.component&.participatory_space || @reportable.try(:participatory_space)
31
+ @participatory_space ||= if reportable.class.respond_to?(:participatory_space?)
32
+ reportable
33
+ else
34
+ reportable.component&.participatory_space || reportable.try(:participatory_space)
35
+ end
32
36
  end
33
37
 
34
38
  # Public: updates the reported content for the moderation object associated with resource
35
39
  def update_reported_content!
36
- moderation.update!(reported_content: @reportable.reported_searchable_content_text)
40
+ moderation.update!(reported_content: reportable.reported_searchable_content_text)
37
41
  end
38
42
 
39
43
  # Public: creates a new report for the given resource, having a basic set of options
@@ -59,18 +63,16 @@ module Decidim
59
63
  event_class: Decidim::ResourceHiddenEvent,
60
64
  resource: @reportable,
61
65
  extra: {
62
- report_reasons:,
63
- force_email: true
66
+ report_reasons:
64
67
  },
65
- affected_users:,
66
- force_send: true
68
+ affected_users: @reportable.try(:authors) || [@reportable.try(:normalized_author)]
67
69
  }
68
70
 
69
71
  Decidim::EventsManager.publish(**data)
70
72
  end
71
73
 
72
74
  # Public: hides the resource
73
- def hide!
75
+ def hide_with_admin_log!
74
76
  Decidim.traceability.perform_action!(
75
77
  "hide",
76
78
  moderation,
@@ -79,25 +81,20 @@ module Decidim
79
81
  reportable_type: @reportable.class.name
80
82
  }
81
83
  ) do
82
- @reportable.moderation.update!(hidden_at: Time.current)
83
- @reportable.try(:touch)
84
+ hide!
84
85
  end
86
+ end
85
87
 
86
- if @reportable.is_a?(Decidim::Comments::Commentable)
87
- @reportable.comment_threads.each do |comment|
88
- Decidim::HideChildResourcesJob.perform_later(comment, @current_user.id)
89
- end
88
+ # Public: hides the resources
89
+ def hide!
90
+ Decidim.traceability.perform_action_without_log!(current_user) do
91
+ @reportable.moderation.update!(hidden_at: Time.current)
92
+ @reportable.try(:touch)
90
93
  end
91
-
92
- send_notification_to_author
93
94
  end
94
95
 
95
96
  private
96
97
 
97
- def affected_users
98
- @affected_users ||= (@reportable.try(:authors) || [@reportable.try(:author)]).select { |author| author.is_a?(Decidim::User) }
99
- end
100
-
101
98
  def report_reasons
102
99
  @reportable.moderation.reports.pluck(:reason).uniq
103
100
  end
@@ -14,7 +14,7 @@ module Decidim
14
14
 
15
15
  def self.crypt_data
16
16
  key = ActiveSupport::KeyGenerator.new("sent_at").generate_key(
17
- Rails.application.secrets.secret_key_base, ActiveSupport::MessageEncryptor.key_len
17
+ Rails.application.secret_key_base, ActiveSupport::MessageEncryptor.key_len
18
18
  )
19
19
  ActiveSupport::MessageEncryptor.new(key)
20
20
  end
@@ -52,7 +52,7 @@ module Decidim
52
52
  candidate = name
53
53
 
54
54
  2.step do |n|
55
- return candidate if Decidim::UserBaseEntity.where(nickname: candidate.downcase).where(scope).empty?
55
+ return candidate if Decidim::UserBaseEntity.where("nickname ILIKE ?", candidate.downcase).where(scope).empty?
56
56
 
57
57
  candidate = numbered_variation_of(name, n)
58
58
  end
@@ -66,7 +66,7 @@ module Decidim
66
66
  return tokenizer.hex_digest(id)
67
67
  end
68
68
 
69
- Digest::MD5.hexdigest("#{id}-#{Rails.application.secrets.secret_key_base}")
69
+ Digest::MD5.hexdigest("#{id}-#{Rails.application.secret_key_base}")
70
70
  end
71
71
 
72
72
  def build_pad_url(id)
@@ -14,25 +14,25 @@ module Decidim
14
14
 
15
15
  def skip_space_slug?(method_name)
16
16
  [
17
- "edit_#{underscored_name}_path".to_sym,
18
- "edit_#{underscored_name}_url".to_sym,
19
- "new_#{underscored_name}_path".to_sym,
20
- "new_#{underscored_name}_url".to_sym,
21
- "#{underscored_name}_path".to_sym,
22
- "#{underscored_name}_url".to_sym,
23
- "#{underscored_name.pluralize}_path".to_sym,
24
- "#{underscored_name.pluralize}_url".to_sym
17
+ :"edit_#{underscored_name}_path",
18
+ :"edit_#{underscored_name}_url",
19
+ :"new_#{underscored_name}_path",
20
+ :"new_#{underscored_name}_url",
21
+ :"#{underscored_name}_path",
22
+ :"#{underscored_name}_url",
23
+ :"#{underscored_name.pluralize}_path",
24
+ :"#{underscored_name.pluralize}_url"
25
25
  ].include?(method_name)
26
26
  end
27
27
 
28
28
  def slug_param_name
29
- "#{underscored_name}_slug".to_sym
29
+ :"#{underscored_name}_slug"
30
30
  end
31
31
 
32
32
  def mounted_params
33
33
  {
34
34
  :host => organization.host,
35
- "#{underscored_name}_slug".to_sym => slug
35
+ :"#{underscored_name}_slug" => slug
36
36
  }
37
37
  end
38
38
 
@@ -37,6 +37,16 @@ module Decidim
37
37
  raise "Not implemented"
38
38
  end
39
39
 
40
+ def self.ransackable_attributes(auth_object = nil)
41
+ return [] unless auth_object&.admin?
42
+
43
+ %w(name nickname email invitation_accepted_at last_sign_in_at role)
44
+ end
45
+
46
+ def self.ransackable_associations(_auth_object = nil)
47
+ []
48
+ end
49
+
40
50
  def self.order_by_name
41
51
  includes(:user).order("decidim_users.name ASC")
42
52
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module PrivateDownloadHelper
5
+ def attach_archive(export_data, name, user)
6
+ private_exports = user.private_exports.build
7
+ private_exports.export_type = name
8
+ private_exports.file.attach(io: StringIO.open(FileZipper.new(export_data.filename(name), export_data.read).zip), filename: "#{name}.zip")
9
+ private_exports.expires_at = Decidim.download_your_data_expiry_time.from_now
10
+ private_exports.metadata = {}
11
+ private_exports.save!
12
+ private_exports.reload
13
+ end
14
+ end
15
+ end