decidim-core 0.29.1 → 0.30.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (517) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/activity_cell.rb +0 -3
  3. data/app/cells/decidim/amendable/amend_button_card/show.erb +6 -4
  4. data/app/cells/decidim/amendable/amend_button_card_cell.rb +8 -0
  5. data/app/cells/decidim/amendable/amendments/show.erb +1 -1
  6. data/app/cells/decidim/amendable/promote_button_card/show.erb +2 -0
  7. data/app/cells/decidim/author/show.erb +5 -4
  8. data/app/cells/decidim/author_cell.rb +27 -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/card_s/show.erb +5 -3
  12. data/app/cells/decidim/comments_button_cell.rb +14 -2
  13. data/app/cells/decidim/content_blocks/highlighted_elements_cell.rb +2 -0
  14. data/app/cells/decidim/content_blocks/highlighted_elements_with_cell_for_list_cell.rb +1 -1
  15. data/app/cells/decidim/diff_cell.rb +4 -0
  16. data/app/cells/decidim/endorsement_block/show.erb +0 -1
  17. data/app/cells/decidim/endorsement_block_cell.rb +6 -0
  18. data/app/cells/decidim/endorsement_buttons/button_content.erb +1 -1
  19. data/app/cells/decidim/endorsement_buttons/select_identity_button.erb +1 -1
  20. data/app/cells/decidim/endorsement_buttons/show.erb +7 -7
  21. data/app/cells/decidim/endorsement_buttons/verification_modal.erb +4 -2
  22. data/app/cells/decidim/endorsers_list/empty.erb +3 -0
  23. data/app/cells/decidim/endorsers_list/full.erb +17 -5
  24. data/app/cells/decidim/endorsers_list/show.erb +19 -10
  25. data/app/cells/decidim/endorsers_list_cell.rb +19 -6
  26. data/app/cells/decidim/follow_button/show.erb +1 -2
  27. data/app/cells/decidim/follow_button_cell.rb +5 -0
  28. data/app/cells/decidim/map/show.erb +3 -0
  29. data/app/cells/decidim/map/template.erb +14 -0
  30. data/app/cells/decidim/map_cell.rb +39 -0
  31. data/app/cells/decidim/newsletter_templates/image_text_cta_cell.rb +1 -1
  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_private_user/show.erb +23 -0
  36. data/app/cells/decidim/participatory_space_private_user_cell.rb +21 -0
  37. data/app/cells/decidim/progress_bar/show.erb +2 -2
  38. data/app/cells/decidim/report_button_cell.rb +1 -0
  39. data/app/cells/decidim/resource_history/show.erb +20 -0
  40. data/app/cells/decidim/resource_history_cell.rb +66 -0
  41. data/app/cells/decidim/share_button_cell.rb +0 -4
  42. data/app/cells/decidim/share_widget/modal.erb +26 -0
  43. data/app/cells/decidim/share_widget/show.erb +2 -0
  44. data/app/cells/decidim/share_widget_cell.rb +20 -0
  45. data/app/cells/decidim/tags/show.erb +7 -4
  46. data/app/cells/decidim/tags_cell.rb +11 -72
  47. data/app/cells/decidim/translation_bar/show.erb +2 -2
  48. data/app/cells/decidim/translation_bar_cell.rb +1 -1
  49. data/app/commands/decidim/amendable/create_draft.rb +2 -2
  50. data/app/commands/decidim/create_ephemeral_user.rb +52 -0
  51. data/app/commands/decidim/create_omniauth_registration.rb +13 -3
  52. data/app/commands/decidim/create_report.rb +1 -5
  53. data/app/commands/decidim/create_user_group.rb +6 -2
  54. data/app/commands/decidim/destroy_account.rb +3 -0
  55. data/app/commands/decidim/destroy_ephemeral_user.rb +47 -0
  56. data/app/commands/decidim/update_account.rb +11 -3
  57. data/app/commands/decidim/update_notifications_settings.rb +1 -0
  58. data/app/commands/decidim/update_resources_taxonomies.rb +67 -0
  59. data/app/commands/decidim/update_user_group.rb +7 -1
  60. data/app/constraints/decidim/current_component.rb +1 -1
  61. data/app/controllers/concerns/decidim/ajax_permission_handler.rb +21 -0
  62. data/app/controllers/concerns/decidim/devise_authentication_methods.rb +3 -6
  63. data/app/controllers/concerns/decidim/devise_controllers.rb +2 -0
  64. data/app/controllers/concerns/decidim/disable_redirection_to_external_host.rb +1 -1
  65. data/app/controllers/concerns/decidim/ephemeral_session_checker.rb +87 -0
  66. data/app/controllers/concerns/decidim/filter_resource.rb +4 -2
  67. data/app/controllers/concerns/decidim/has_members_page.rb +25 -0
  68. data/app/controllers/concerns/decidim/headers/browser_feature_permissions.rb +50 -0
  69. data/app/controllers/concerns/decidim/locale_switcher.rb +2 -2
  70. data/app/controllers/concerns/decidim/needs_password_change.rb +0 -1
  71. data/app/controllers/concerns/decidim/needs_permission.rb +2 -1
  72. data/app/controllers/concerns/decidim/needs_tos_accepted.rb +4 -5
  73. data/app/controllers/concerns/decidim/onboarding_action_methods.rb +52 -0
  74. data/app/controllers/decidim/application_controller.rb +10 -0
  75. data/app/controllers/decidim/authorization_modals_controller.rb +8 -2
  76. data/app/controllers/decidim/components/base_controller.rb +3 -7
  77. data/app/controllers/decidim/devise/confirmations_controller.rb +4 -0
  78. data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +8 -1
  79. data/app/controllers/decidim/devise/registrations_controller.rb +1 -1
  80. data/app/controllers/decidim/devise/sessions_controller.rb +2 -0
  81. data/app/controllers/decidim/doorkeeper/credentials_controller.rb +1 -1
  82. data/app/controllers/decidim/download_your_data_controller.rb +33 -2
  83. data/app/controllers/decidim/editor_images_controller.rb +1 -11
  84. data/app/controllers/decidim/follows_controller.rb +1 -1
  85. data/app/controllers/decidim/geolocation_controller.rb +19 -0
  86. data/app/controllers/decidim/homepage_controller.rb +0 -1
  87. data/app/controllers/decidim/links_controller.rb +1 -1
  88. data/app/controllers/decidim/open_data_controller.rb +33 -8
  89. data/app/controllers/decidim/profiles_controller.rb +4 -0
  90. data/app/controllers/decidim/user_conversations_controller.rb +1 -11
  91. data/app/events/decidim/soft_delete_resource_event.rb +15 -0
  92. data/app/forms/decidim/amendable/form.rb +4 -2
  93. data/app/forms/decidim/ephemeral_user_form.rb +22 -0
  94. data/app/forms/decidim/notifications_settings_form.rb +1 -0
  95. data/app/forms/decidim/omniauth_registration_form.rb +14 -1
  96. data/app/helpers/concerns/decidim/flash_helper_extensions.rb +17 -2
  97. data/app/helpers/concerns/decidim/user_role_checker.rb +46 -0
  98. data/app/helpers/decidim/action_authorization_helper.rb +75 -14
  99. data/app/helpers/decidim/amendments_helper.rb +0 -9
  100. data/app/helpers/decidim/application_helper.rb +6 -2
  101. data/app/helpers/decidim/breadcrumb_helper.rb +6 -0
  102. data/app/helpers/decidim/cache_helper.rb +1 -1
  103. data/app/helpers/decidim/check_boxes_tree_helper.rb +25 -53
  104. data/app/helpers/decidim/cta_button_helper.rb +1 -1
  105. data/app/helpers/decidim/decidim_form_helper.rb +0 -44
  106. data/app/helpers/decidim/endorsable_helper.rb +0 -10
  107. data/app/helpers/decidim/layout_helper.rb +6 -0
  108. data/app/helpers/decidim/map_helper.rb +6 -1
  109. data/app/helpers/decidim/messaging/conversation_helper.rb +2 -3
  110. data/app/helpers/decidim/meta_tags_helper.rb +32 -23
  111. data/app/helpers/decidim/modal_helper.rb +23 -0
  112. data/app/helpers/decidim/omniauth_helper.rb +5 -5
  113. data/app/helpers/decidim/onboarding_action_helper.rb +13 -0
  114. data/app/helpers/decidim/passwords_helper.rb +2 -2
  115. data/app/helpers/decidim/sanitize_helper.rb +11 -2
  116. data/app/helpers/decidim/taxonomies_helper.rb +40 -0
  117. data/app/jobs/decidim/download_your_data_export_job.rb +2 -19
  118. data/app/jobs/decidim/event_publisher_job.rb +18 -9
  119. data/app/jobs/decidim/export_job.rb +5 -1
  120. data/app/jobs/decidim/export_participatory_space_job.rb +4 -1
  121. data/app/jobs/decidim/open_data_job.rb +4 -4
  122. data/app/mailers/decidim/export_mailer.rb +7 -12
  123. data/app/models/decidim/action_log.rb +11 -0
  124. data/app/models/decidim/attachment.rb +1 -1
  125. data/app/models/decidim/category.rb +4 -0
  126. data/app/models/decidim/component.rb +25 -3
  127. data/app/models/decidim/metric.rb +2 -1
  128. data/app/models/decidim/moderation.rb +16 -0
  129. data/app/models/decidim/newsletter.rb +12 -8
  130. data/app/models/decidim/organization.rb +7 -3
  131. data/app/models/decidim/participatory_space_private_user.rb +20 -0
  132. data/app/models/decidim/private_export.rb +24 -0
  133. data/app/models/decidim/push_notification_message.rb +1 -1
  134. data/app/models/decidim/scope.rb +4 -0
  135. data/app/models/decidim/share_token.rb +36 -10
  136. data/app/models/decidim/taxonomization.rb +23 -0
  137. data/app/models/decidim/taxonomy.rb +139 -0
  138. data/app/models/decidim/taxonomy_filter.rb +130 -0
  139. data/app/models/decidim/taxonomy_filter_item.rb +33 -0
  140. data/app/models/decidim/user.rb +9 -23
  141. data/app/models/decidim/user_base_entity.rb +12 -0
  142. data/app/models/decidim/user_moderation.rb +9 -0
  143. data/app/models/decidim/user_report.rb +4 -0
  144. data/app/packs/entrypoints/decidim_core.js +1 -0
  145. data/app/packs/entrypoints/decidim_geocoding.js +2 -0
  146. data/app/packs/images/decidim/brands/facebook.svg +10 -0
  147. data/app/packs/images/decidim/brands/google.svg +7 -1
  148. data/app/packs/images/decidim/brands/twitter-x.svg +3 -0
  149. data/app/packs/src/decidim/append_redirect_url_to_modals.js +14 -6
  150. data/app/packs/src/decidim/check_boxes_tree.js +0 -1
  151. data/app/packs/src/decidim/clipboard.js +18 -9
  152. data/app/packs/src/decidim/confirm.js +79 -59
  153. data/app/packs/src/decidim/decidim_application.js +1 -0
  154. data/app/packs/src/decidim/direct_uploads/upload_field.js +21 -8
  155. data/app/packs/src/decidim/form_remote.js +1 -1
  156. data/app/packs/src/decidim/geocoding/reverse_geocoding.js +60 -0
  157. data/app/packs/src/decidim/impersonation.js +1 -1
  158. data/app/packs/src/decidim/index.js +14 -1
  159. data/app/packs/src/decidim/onboarding_pending_action.js +24 -0
  160. data/app/packs/src/decidim/remote_tooltips.js +38 -0
  161. data/app/packs/src/decidim/session_timeouter.js +1 -1
  162. data/app/packs/src/decidim/sticky_footer.js +29 -0
  163. data/app/packs/src/decidim/sticky_header.js +6 -31
  164. data/app/packs/src/decidim/toggle.js +1 -1
  165. data/app/packs/src/decidim/tooltips.js +42 -22
  166. data/app/packs/src/decidim/user_registrations.js +13 -0
  167. data/app/packs/src/decidim/utilities/dom.js +148 -0
  168. data/app/packs/stylesheets/decidim/_accordion.scss +30 -0
  169. data/app/packs/stylesheets/decidim/_buttons.scss +19 -0
  170. data/app/packs/stylesheets/decidim/_dropdown.scss +1 -1
  171. data/app/packs/stylesheets/decidim/_endorsers_list.scss +26 -20
  172. data/app/packs/stylesheets/decidim/_forms.scss +2 -2
  173. data/app/packs/stylesheets/decidim/_header.scss +5 -3
  174. data/app/packs/stylesheets/decidim/_labels.scss +1 -1
  175. data/app/packs/stylesheets/decidim/_layout.scss +32 -2
  176. data/app/packs/stylesheets/decidim/_login.scss +53 -6
  177. data/app/packs/stylesheets/decidim/_modal.scss +42 -0
  178. data/app/packs/stylesheets/decidim/_modal_tos_refuse.scss +4 -0
  179. data/app/packs/stylesheets/decidim/_participatory_spaces.scss +46 -0
  180. data/app/packs/stylesheets/decidim/_profile.scss +2 -2
  181. data/app/packs/stylesheets/decidim/_progress-bar.scss +1 -1
  182. data/app/packs/stylesheets/decidim/_success_image.scss +64 -0
  183. data/app/packs/stylesheets/decidim/_tribute.scss +36 -0
  184. data/app/packs/stylesheets/decidim/application.scss +1 -0
  185. data/app/packs/stylesheets/decidim/geocoding_addons.scss +5 -0
  186. data/app/packs/stylesheets/decidim/legacy/conference-diploma.scss +2 -1
  187. data/app/packs/stylesheets/decidim/map.scss +7 -10
  188. data/app/packs/stylesheets/decidim/resource_history.scss +31 -0
  189. data/app/permissions/decidim/permissions.rb +8 -2
  190. data/app/presenters/decidim/admin_log/base_user_presenter.rb +67 -0
  191. data/app/presenters/decidim/admin_log/component_presenter.rb +32 -3
  192. data/app/presenters/decidim/admin_log/moderation_presenter.rb +30 -3
  193. data/app/presenters/decidim/admin_log/share_token_presenter.rb +39 -0
  194. data/app/presenters/decidim/admin_log/taxonomy_filter_presenter.rb +57 -0
  195. data/app/presenters/decidim/admin_log/taxonomy_presenter.rb +48 -0
  196. data/app/presenters/decidim/admin_log/user_group_presenter.rb +6 -6
  197. data/app/presenters/decidim/admin_log/user_presenter.rb +4 -18
  198. data/app/presenters/decidim/attachment_presenter.rb +1 -1
  199. data/app/presenters/decidim/log/value_types/date_presenter.rb +1 -0
  200. data/app/presenters/decidim/log/value_types/taxonomy_presenter.rb +29 -0
  201. data/app/presenters/decidim/participatory_space_private_user_presenter.rb +50 -0
  202. data/app/presenters/decidim/taxonomy_filter_presenter.rb +19 -0
  203. data/app/presenters/decidim/taxonomy_presenter.rb +14 -0
  204. data/app/queries/decidim/metrics/blocked_users_metric_manage.rb +2 -2
  205. data/app/queries/decidim/metrics/users_metric_manage.rb +2 -2
  206. data/app/queries/decidim/public_activities.rb +1 -12
  207. data/app/queries/decidim/stats_users_count.rb +2 -2
  208. data/app/resolvers/decidim/meta_image_url_resolver.rb +128 -0
  209. data/app/serializers/decidim/exporters/open_data_blocked_user_serializer.rb +25 -0
  210. data/app/serializers/decidim/exporters/open_data_metric_serializer.rb +22 -0
  211. data/app/serializers/decidim/exporters/open_data_moderation_serializer.rb +30 -0
  212. data/app/serializers/decidim/exporters/open_data_taxonomy_serializer.rb +30 -0
  213. data/app/serializers/decidim/exporters/open_data_user_group_serializer.rb +38 -0
  214. data/app/serializers/decidim/exporters/open_data_user_serializer.rb +39 -0
  215. data/app/serializers/decidim/exporters/participatory_space_serializer.rb +104 -0
  216. data/app/serializers/decidim/exporters/serializer.rb +25 -0
  217. data/app/serializers/decidim/schema_org_breadcrumb_list_serializer.rb +52 -0
  218. data/app/services/decidim/action_authorizer.rb +32 -3
  219. data/app/services/decidim/base_diff_renderer.rb +27 -3
  220. data/app/services/decidim/download_your_data_exporter.rb +58 -24
  221. data/app/services/decidim/email_notification_generator.rb +14 -5
  222. data/app/services/decidim/onboarding_manager.rb +272 -0
  223. data/app/services/decidim/open_data_exporter.rb +139 -13
  224. data/app/services/decidim/traceability.rb +13 -0
  225. data/app/uploaders/decidim/application_uploader.rb +1 -1
  226. data/app/validators/etiquette_validator.rb +9 -2
  227. data/app/validators/passthru_validator.rb +1 -1
  228. data/app/validators/translated_etiquette_validator.rb +32 -0
  229. data/app/views/decidim/account/_password_fields.html.erb +2 -2
  230. data/app/views/decidim/application/_accordion_section.html.erb +14 -0
  231. data/app/views/decidim/application/_collection.html.erb +30 -18
  232. data/app/views/decidim/devise/omniauth_registrations/new.html.erb +5 -1
  233. data/app/views/decidim/devise/omniauth_registrations/new_tos_fields.html.erb +29 -0
  234. data/app/views/decidim/devise/registrations/new.html.erb +10 -22
  235. data/app/views/decidim/devise/sessions/new.html.erb +24 -29
  236. data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +2 -4
  237. data/app/views/decidim/devise/shared/_tos_fields.html.erb +16 -0
  238. data/app/views/decidim/download_your_data/_export.html.erb +15 -0
  239. data/app/views/decidim/download_your_data/show.html.erb +51 -5
  240. data/app/views/decidim/endorsements/update_buttons_and_counters.js.erb +16 -19
  241. data/app/views/decidim/export_mailer/download_your_data_export.html.erb +2 -2
  242. data/app/views/decidim/export_mailer/export.html.erb +5 -1
  243. data/app/views/decidim/notifications_settings/show.html.erb +22 -0
  244. data/app/views/decidim/open_data/_how_to_open_accordion_section.html.erb +15 -0
  245. data/app/views/decidim/open_data/index.html.erb +108 -0
  246. data/app/views/decidim/pages/_tabbed.html.erb +2 -2
  247. data/app/views/decidim/pages/show.html.erb +2 -1
  248. data/app/views/decidim/participatory_space_private_users/_participatory_space_private_user.html.erb +1 -0
  249. data/app/views/decidim/shared/_login_modal.html.erb +26 -20
  250. data/app/views/decidim/shared/_resource_actions.html.erb +21 -0
  251. data/app/views/decidim/shared/filters/_check_boxes_tree.html.erb +1 -2
  252. data/app/views/decidim/shared/filters/_collection.html.erb +1 -1
  253. data/app/views/decidim/shared/filters/_dropdown_label.html.erb +7 -4
  254. data/app/views/layouts/decidim/_application.html.erb +0 -1
  255. data/app/views/layouts/decidim/_js_configuration.html.erb +1 -0
  256. data/app/views/layouts/decidim/_logo.html.erb +1 -1
  257. data/app/views/layouts/decidim/_logo_mobile.html.erb +1 -1
  258. data/app/views/layouts/decidim/_meta_tags_config.html.erb +6 -11
  259. data/app/views/layouts/decidim/_schema_org_breadcrumb_list.html.erb +3 -0
  260. data/app/views/layouts/decidim/_wrapper.html.erb +15 -9
  261. data/app/views/layouts/decidim/footer/_main_links.html.erb +1 -1
  262. data/app/views/layouts/decidim/header/_close_ephemeral_session.html.erb +25 -0
  263. data/app/views/layouts/decidim/header/_main.html.erb +14 -10
  264. data/app/views/layouts/decidim/header/_menu_breadcrumb_items.html.erb +2 -0
  265. data/app/views/layouts/decidim/header/_menu_breadcrumb_mobile_tablet.html.erb +1 -1
  266. data/app/views/layouts/decidim/shared/_layout_item.html.erb +1 -1
  267. data/config/assets.rb +2 -1
  268. data/config/locales/ar.yml +38 -54
  269. data/config/locales/bg.yml +3 -64
  270. data/config/locales/bn-BD.yml +1 -0
  271. data/config/locales/bs-BA.yml +98 -0
  272. data/config/locales/ca.yml +380 -69
  273. data/config/locales/cs.yml +369 -55
  274. data/config/locales/de.yml +371 -67
  275. data/config/locales/el.yml +5 -45
  276. data/config/locales/en.yml +365 -54
  277. data/config/locales/eo.yml +0 -2
  278. data/config/locales/es-MX.yml +366 -58
  279. data/config/locales/es-PY.yml +366 -58
  280. data/config/locales/es.yml +375 -64
  281. data/config/locales/eu.yml +547 -223
  282. data/config/locales/fi-plain.yml +361 -57
  283. data/config/locales/fi.yml +400 -93
  284. data/config/locales/fr-CA.yml +181 -55
  285. data/config/locales/fr.yml +182 -53
  286. data/config/locales/ga-IE.yml +4 -16
  287. data/config/locales/gl.yml +5 -30
  288. data/config/locales/hu.yml +3 -55
  289. data/config/locales/id-ID.yml +5 -30
  290. data/config/locales/is-IS.yml +4 -13
  291. data/config/locales/it.yml +10 -46
  292. data/config/locales/ja.yml +230 -69
  293. data/config/locales/lb.yml +5 -47
  294. data/config/locales/lt.yml +5 -59
  295. data/config/locales/lv.yml +5 -36
  296. data/config/locales/nl.yml +5 -48
  297. data/config/locales/no.yml +6 -47
  298. data/config/locales/pl.yml +4 -66
  299. data/config/locales/pt-BR.yml +12 -52
  300. data/config/locales/pt.yml +11 -47
  301. data/config/locales/ro-RO.yml +448 -247
  302. data/config/locales/ru.yml +4 -16
  303. data/config/locales/sk.yml +5 -37
  304. data/config/locales/sv.yml +108 -64
  305. data/config/locales/tr-TR.yml +5 -45
  306. data/config/locales/uk.yml +4 -15
  307. data/config/locales/zh-CN.yml +5 -45
  308. data/config/locales/zh-TW.yml +5 -50
  309. data/config/routes.rb +5 -10
  310. data/db/migrate/20181025082245_add_timestamps_to_components.rb +2 -0
  311. data/db/migrate/20240628111905_add_visible_to_components.rb +7 -0
  312. data/db/migrate/20240704115429_create_decidim_taxonomies.rb +23 -0
  313. data/db/migrate/20240717093514_add_registered_only_to_decidim_share_tokens.rb +7 -0
  314. data/db/migrate/20240722215500_change_object_changes_on_versions.rb +39 -0
  315. data/db/migrate/20240806065417_create_decidim_taxonomy_filters.rb +23 -0
  316. data/db/migrate/20240822161348_add_deleted_at_to_decidim_components.rb +8 -0
  317. data/db/migrate/20240906162524_add_part_of_to_taxonomies.rb +26 -0
  318. data/db/migrate/20241001135825_add_role_to_participatory_space_private_users.rb +7 -0
  319. data/db/migrate/20241001140408_add_published_to_participatory_space_private_users.rb +7 -0
  320. data/db/migrate/20241022002600_create_private_exports.rb +18 -0
  321. data/db/migrate/20241028114430_add_component_counter_to_taxonomy_filters.rb +7 -0
  322. data/db/migrate/20241111104357_add_names_and_space_boolean_to_taxonomy_filters.rb +9 -0
  323. data/db/migrate/20241127093708_add_taxonomy_to_metrics.rb +7 -0
  324. data/db/migrate/20241204121445_add_participatory_space_manifests_from_taxonomy_filters.rb +9 -0
  325. data/decidim-core.gemspec +18 -18
  326. data/lib/decidim/action_authorization.rb +3 -2
  327. data/lib/decidim/amendable.rb +1 -1
  328. data/lib/decidim/api/functions/component_list.rb +1 -1
  329. data/lib/decidim/api/functions/participatory_space_finder_base.rb +11 -1
  330. data/lib/decidim/api/input_filters/category_input_filter.rb +5 -3
  331. data/lib/decidim/api/input_filters/component_input_filter.rb +33 -20
  332. data/lib/decidim/api/input_filters/user_entity_input_filter.rb +53 -44
  333. data/lib/decidim/api/input_sorts/component_input_sort.rb +15 -13
  334. data/lib/decidim/api/input_sorts/user_entity_input_sort.rb +4 -4
  335. data/lib/decidim/api/interfaces/author_interface.rb +3 -2
  336. data/lib/decidim/api/interfaces/coauthorable_interface.rb +5 -5
  337. data/lib/decidim/api/interfaces/endorsable_interface.rb +2 -2
  338. data/lib/decidim/api/interfaces/participatory_space_interface.rb +5 -10
  339. data/lib/decidim/api/interfaces/taxonomizable_interface.rb +13 -0
  340. data/lib/decidim/api/types/amendment_type.rb +5 -7
  341. data/lib/decidim/api/types/area_api_type.rb +3 -3
  342. data/lib/decidim/api/types/attachment_type.rb +3 -3
  343. data/lib/decidim/api/types/category_type.rb +2 -2
  344. data/lib/decidim/api/types/component_type.rb +7 -0
  345. data/lib/decidim/api/types/decidim_type.rb +5 -1
  346. data/lib/decidim/api/types/fingerprint_type.rb +1 -1
  347. data/lib/decidim/api/types/localized_string_type.rb +1 -1
  348. data/lib/decidim/api/types/metric_history_type.rb +2 -0
  349. data/lib/decidim/api/types/metric_type.rb +1 -1
  350. data/lib/decidim/api/types/organization_type.rb +5 -0
  351. data/lib/decidim/api/types/participatory_space_link_type.rb +2 -2
  352. data/lib/decidim/api/types/participatory_space_manifest_type.rb +1 -1
  353. data/lib/decidim/api/types/quantifiable_translated_field_type.rb +1 -1
  354. data/lib/decidim/api/types/scope_api_type.rb +2 -3
  355. data/lib/decidim/api/types/session_type.rb +1 -2
  356. data/lib/decidim/api/types/taxonomy_type.rb +15 -0
  357. data/lib/decidim/api/types/trace_version_type.rb +2 -2
  358. data/lib/decidim/api/types/translated_field_type.rb +3 -5
  359. data/lib/decidim/api/types/user_group_type.rb +11 -20
  360. data/lib/decidim/api/types/user_type.rb +9 -18
  361. data/lib/decidim/asset_router/storage.rb +4 -4
  362. data/lib/decidim/assets/tailwind/tailwind.config.js.erb +2 -1
  363. data/lib/decidim/attachment_attributes.rb +1 -1
  364. data/lib/decidim/attribute_encryptor.rb +1 -1
  365. data/lib/decidim/attribute_object/nested_validator.rb +1 -1
  366. data/lib/decidim/attributes/integer_with_units.rb +27 -0
  367. data/lib/decidim/attributes/rich_text.rb +38 -0
  368. data/lib/decidim/attributes/time_with_zone.rb +11 -1
  369. data/lib/decidim/attributes.rb +4 -0
  370. data/lib/decidim/authorization_form_builder.rb +0 -7
  371. data/lib/decidim/coauthorable.rb +1 -1
  372. data/lib/decidim/command.rb +3 -3
  373. data/lib/decidim/commands/destroy_resource.rb +5 -1
  374. data/lib/decidim/commands/resource_handler.rb +2 -2
  375. data/lib/decidim/commands/restore_resource.rb +45 -0
  376. data/lib/decidim/commands/soft_delete_resource.rb +63 -0
  377. data/lib/decidim/component_manifest.rb +7 -0
  378. data/lib/decidim/content_parsers/blob_parser.rb +93 -0
  379. data/lib/decidim/content_parsers.rb +1 -0
  380. data/lib/decidim/content_renderers/blob_renderer.rb +90 -0
  381. data/lib/decidim/content_renderers.rb +1 -0
  382. data/lib/decidim/core/api.rb +2 -0
  383. data/lib/decidim/core/engine.rb +50 -8
  384. data/lib/decidim/core/menu.rb +0 -5
  385. data/lib/decidim/core/seeds.rb +42 -2
  386. data/lib/decidim/core/test/factories.rb +133 -2
  387. data/lib/decidim/core/test/shared_examples/admin_resource_gallery_examples.rb +85 -0
  388. data/lib/decidim/core/test/shared_examples/authorable_interface_examples.rb +1 -1
  389. data/lib/decidim/core/test/shared_examples/comments_examples.rb +408 -40
  390. data/lib/decidim/core/test/shared_examples/components_controller_hide_shared_examples.rb +11 -0
  391. data/lib/decidim/core/test/shared_examples/components_controller_reorder_shared_examples.rb +21 -0
  392. data/lib/decidim/core/test/shared_examples/download_open_data_shared_context.rb +36 -0
  393. data/lib/decidim/core/test/shared_examples/download_open_data_shared_examples.rb +45 -0
  394. data/lib/decidim/core/test/shared_examples/download_your_data_shared_examples.rb +17 -0
  395. data/lib/decidim/core/test/shared_examples/etiquette_validator_examples.rb +25 -0
  396. data/lib/decidim/core/test/shared_examples/follows_examples.rb +43 -0
  397. data/lib/decidim/core/test/shared_examples/has_taxonomies.rb +94 -0
  398. data/lib/decidim/core/test/shared_examples/manage_share_tokens_examples.rb +237 -0
  399. data/lib/decidim/core/test/shared_examples/map_examples.rb +2 -0
  400. data/lib/decidim/core/test/shared_examples/open_data_exporter_examples.rb +102 -0
  401. data/lib/decidim/core/test/shared_examples/participatory_space_members_page_examples.rb +46 -0
  402. data/lib/decidim/core/test/shared_examples/participatory_space_search_examples.rb +98 -0
  403. data/lib/decidim/core/test/shared_examples/permissions.rb +7 -7
  404. data/lib/decidim/core/test/shared_examples/preview_with_share_token_examples.rb +94 -0
  405. data/lib/decidim/core/test/shared_examples/reports_examples.rb +9 -5
  406. data/lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb +2 -2
  407. data/lib/decidim/core/test/shared_examples/resource_search_examples.rb +75 -69
  408. data/lib/decidim/core/test/shared_examples/searchable_resources_shared_context.rb +1 -1
  409. data/lib/decidim/core/test/shared_examples/simple_event.rb +33 -19
  410. data/lib/decidim/core/test/shared_examples/social_share_examples.rb +25 -0
  411. data/lib/decidim/core/test/shared_examples/softdeleteable_components_examples.rb +173 -0
  412. data/lib/decidim/core/test/shared_examples/system_endorse_resource_examples.rb +54 -8
  413. data/lib/decidim/core/test/shared_examples/taxonomizable_interface_examples.rb +20 -0
  414. data/lib/decidim/core/test/shared_examples/taxonomizable_resource_examples.rb +37 -0
  415. data/lib/decidim/core/test/shared_examples/taxonomy_settings.rb +49 -0
  416. data/lib/decidim/core/test/shared_examples/translated_event_examples.rb +1 -1
  417. data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +2 -2
  418. data/lib/decidim/core/test/shared_examples/with_endorsable_permissions_examples.rb +1 -1
  419. data/lib/decidim/core/test.rb +9 -5
  420. data/lib/decidim/core/version.rb +1 -1
  421. data/lib/decidim/core.rb +58 -0
  422. data/lib/decidim/diffy_extension.rb +18 -0
  423. data/lib/decidim/download_your_data_serializers/download_your_data_identity_serializer.rb +0 -4
  424. data/lib/decidim/download_your_data_serializers/download_your_data_participatory_space_private_user_serializer.rb +3 -1
  425. data/lib/decidim/download_your_data_serializers/download_your_data_report_serializer.rb +2 -1
  426. data/lib/decidim/download_your_data_serializers/download_your_data_user_serializer.rb +6 -7
  427. data/lib/decidim/download_your_data_serializers.rb +19 -0
  428. data/lib/decidim/exporters/csv.rb +6 -0
  429. data/lib/decidim/exporters/export_manifest.rb +14 -0
  430. data/lib/decidim/exporters/pdf.rb +26 -22
  431. data/lib/decidim/filter_form_builder.rb +12 -15
  432. data/lib/decidim/form_builder.rb +7 -130
  433. data/lib/decidim/has_category.rb +5 -1
  434. data/lib/decidim/has_private_users.rb +4 -0
  435. data/lib/decidim/has_taxonomy_settings.rb +47 -0
  436. data/lib/decidim/has_upload_validations.rb +1 -1
  437. data/lib/decidim/legacy_form_builder.rb +118 -0
  438. data/lib/decidim/maintenance/import_models/application_record.rb +93 -0
  439. data/lib/decidim/maintenance/import_models/area.rb +82 -0
  440. data/lib/decidim/maintenance/import_models/area_type.rb +12 -0
  441. data/lib/decidim/maintenance/import_models/assembly_type.rb +49 -0
  442. data/lib/decidim/maintenance/import_models/categorization.rb +14 -0
  443. data/lib/decidim/maintenance/import_models/category.rb +107 -0
  444. data/lib/decidim/maintenance/import_models/participatory_process_type.rb +21 -0
  445. data/lib/decidim/maintenance/import_models/scope.rb +163 -0
  446. data/lib/decidim/maintenance/import_models.rb +19 -0
  447. data/lib/decidim/maintenance/taxonomy_importer.rb +132 -0
  448. data/lib/decidim/maintenance/taxonomy_plan.rb +78 -0
  449. data/lib/decidim/maintenance.rb +12 -0
  450. data/lib/decidim/map/autocomplete.rb +53 -8
  451. data/lib/decidim/map/dynamic_map.rb +1 -1
  452. data/lib/decidim/map/provider/geocoding/here.rb +9 -3
  453. data/lib/decidim/map.rb +3 -6
  454. data/lib/decidim/moderation_tools.rb +14 -3
  455. data/lib/decidim/newsletter_encryptor.rb +1 -1
  456. data/lib/decidim/paddable.rb +1 -1
  457. data/lib/decidim/participable.rb +10 -10
  458. data/lib/decidim/participatory_space_user.rb +14 -0
  459. data/lib/decidim/private_download_helper.rb +15 -0
  460. data/lib/decidim/query_extensions.rb +0 -26
  461. data/lib/decidim/record_encryptor.rb +51 -46
  462. data/lib/decidim/resourceable.rb +16 -0
  463. data/lib/decidim/seeds.rb +18 -20
  464. data/lib/decidim/settings_manifest.rb +36 -1
  465. data/lib/decidim/soft_deletable.rb +17 -0
  466. data/lib/decidim/taxonomizable.rb +72 -0
  467. data/lib/decidim/translatable_attributes.rb +6 -1
  468. data/lib/decidim/view_model.rb +0 -1
  469. data/lib/tasks/decidim_download_your_data_tasks.rake +2 -4
  470. data/lib/tasks/decidim_procfile.rake +6 -0
  471. data/lib/tasks/decidim_tasks.rake +1 -0
  472. data/lib/tasks/decidim_taxonomies.rake +155 -0
  473. data/lib/tasks/upgrade/{decidim_fix_categorization.rake → clean.rake} +52 -19
  474. data/lib/tasks/upgrade/decidim_active_storage_migration_tasks.rake +1 -1
  475. data/lib/tasks/upgrade/migrations.rake +91 -0
  476. metadata +217 -103
  477. data/app/cells/decidim/amendable/amenders_list/show.erb +0 -0
  478. data/app/cells/decidim/content_blocks/base/content.erb +0 -0
  479. data/app/cells/decidim/endorsers_list/full_endorsers_list.erb +0 -3
  480. data/app/cells/decidim/endorsers_list_button/content.erb +0 -1
  481. data/app/cells/decidim/endorsers_list_button_cell.rb +0 -15
  482. data/app/cells/decidim/scopes_picker/scope_picker_prompt.erb +0 -3
  483. data/app/cells/decidim/scopes_picker/scope_picker_values.erb +0 -5
  484. data/app/cells/decidim/scopes_picker/show.erb +0 -14
  485. data/app/cells/decidim/scopes_picker_cell.rb +0 -92
  486. data/app/commands/decidim/update_user_interests.rb +0 -41
  487. data/app/controllers/decidim/scopes_controller.rb +0 -84
  488. data/app/controllers/decidim/user_interests_controller.rb +0 -30
  489. data/app/forms/decidim/user_interest_scope_form.rb +0 -25
  490. data/app/forms/decidim/user_interests_form.rb +0 -17
  491. data/app/helpers/decidim/categories_helper.rb +0 -26
  492. data/app/helpers/decidim/scopes_helper.rb +0 -105
  493. data/app/packs/images/decidim/vendor/leaflet/layers-2x.png +0 -0
  494. data/app/packs/images/decidim/vendor/leaflet/layers.png +0 -0
  495. data/app/packs/images/decidim/vendor/leaflet/marker-icon-2x.png +0 -0
  496. data/app/packs/images/decidim/vendor/leaflet/marker-icon.png +0 -0
  497. data/app/packs/images/decidim/vendor/leaflet/marker-shadow.png +0 -0
  498. data/app/packs/stylesheets/decidim/legacy/MarkerCluster.Default.scss +0 -67
  499. data/app/packs/stylesheets/decidim/legacy/MarkerCluster.scss +0 -18
  500. data/app/packs/stylesheets/decidim/legacy/leaflet.scss +0 -705
  501. data/app/validators/scope_belongs_to_component_validator.rb +0 -16
  502. data/app/views/decidim/account/_user_groups.html.erb +0 -0
  503. data/app/views/decidim/scopes/_scopes_picker_input.html.erb +0 -19
  504. data/app/views/decidim/scopes/picker.html.erb +0 -53
  505. data/app/views/decidim/shared/_comments.html.erb +0 -0
  506. data/app/views/decidim/shared/_share_modal.html.erb +0 -26
  507. data/app/views/decidim/shared/_tags.html.erb +0 -1
  508. data/app/views/decidim/user_interests/_areas.html.erb +0 -14
  509. data/app/views/decidim/user_interests/_scopes.html.erb +0 -22
  510. data/app/views/decidim/user_interests/show.html.erb +0 -22
  511. data/config/initializers/foundation_rails_helper.rb +0 -4
  512. data/lib/decidim/core/test/shared_examples/has_category.rb +0 -38
  513. data/lib/decidim/core/test/shared_examples/has_scope.rb +0 -11
  514. data/lib/decidim/core/test/shared_examples/manage_component_share_tokens.rb +0 -83
  515. data/lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb +0 -49
  516. data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +0 -93
  517. data/lib/decidim/seven_zip_wrapper.rb +0 -29
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples_for "a download your data entity" do
4
+ let(:data) { subject.send(:readme) }
5
+
6
+ before do
7
+ subject.send(:data_and_attachments_for_user) # to create the data and get the help definitions
8
+ end
9
+
10
+ it "does not have any missing translation" do
11
+ expect(data).not_to include("Translation missing"), data
12
+ end
13
+
14
+ it "has the correct help definition" do
15
+ expect(data).to include(help_definition_string)
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples "etiquette validator" do |options|
4
+ options[:fields].map(&:to_sym).each do |field|
5
+ let!(field) { options[:i18n] ? { en: string } : string }
6
+
7
+ context "when #{field} contains too many caps" do
8
+ let(:string) { "#{"A" * 50}#{"a" * 49}" }
9
+
10
+ it { is_expected.to be_invalid }
11
+ end
12
+
13
+ context "when #{field} not starting with caps" do
14
+ let(:string) { "aa#{"A" * 50}#{"a" * 49}" }
15
+
16
+ it { is_expected.to be_invalid }
17
+ end
18
+
19
+ context "when #{field} containing too many marks" do
20
+ let(:string) { "#{"A" * 5}#{"a" * 49}!!??" }
21
+
22
+ it { is_expected.to be_invalid }
23
+ end
24
+ end
25
+ end
@@ -14,6 +14,8 @@ shared_examples "followable content for users" do
14
14
  context "when user clicks the Follow button" do
15
15
  it "makes the user follow the followable" do
16
16
  visit followable_path
17
+ find("#dropdown-trigger-resource-#{followable.id}").click
18
+
17
19
  expect do
18
20
  click_on "Follow"
19
21
  expect(page).to have_content "Stop following"
@@ -30,6 +32,45 @@ shared_examples "followable content for users" do
30
32
  context "when user clicks the Follow button" do
31
33
  it "makes the user follow the followable" do
32
34
  visit followable_path
35
+ find("#dropdown-trigger-resource-#{followable.id}").click
36
+
37
+ expect do
38
+ click_on "Stop following"
39
+ expect(page).to have_content "Follow"
40
+ end.to change(Decidim::Follow, :count).by(-1)
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ shared_examples "followable space content for users" do
47
+ before do
48
+ switch_to_host(organization.host)
49
+ login_as user, scope: :user
50
+ end
51
+
52
+ context "when not following the followable" do
53
+ context "when user clicks the Follow button" do
54
+ it "makes the user follow the followable" do
55
+ visit followable_path
56
+
57
+ expect do
58
+ click_on "Follow"
59
+ expect(page).to have_content "Stop following"
60
+ end.to change(Decidim::Follow, :count).by(1)
61
+ end
62
+ end
63
+ end
64
+
65
+ context "when the user is following the followable" do
66
+ before do
67
+ create(:follow, followable:, user:)
68
+ end
69
+
70
+ context "when user clicks the Follow button" do
71
+ it "makes the user follow the followable" do
72
+ visit followable_path
73
+
33
74
  expect do
34
75
  click_on "Stop following"
35
76
  expect(page).to have_content "Follow"
@@ -51,6 +92,8 @@ shared_examples "followable content for users with a component" do
51
92
  context "when user clicks the Follow button" do
52
93
  it "makes the user follow the followable" do
53
94
  visit followable_path
95
+ find("#dropdown-trigger-resource-#{followable.id}").click
96
+
54
97
  expect do
55
98
  click_on "Follow"
56
99
  expect(page).to have_content "Stop following"
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples_for "has taxonomies" do
4
+ describe "taxonomies" do
5
+ context "when valid taxonomies are assigned" do
6
+ let(:taxonomy) { create(:taxonomy, :with_parent, organization: subject.organization) }
7
+ before do
8
+ subject.taxonomies = [taxonomy]
9
+ end
10
+
11
+ it { is_expected.to be_valid }
12
+ end
13
+
14
+ context "when a root taxonomy is assigned" do
15
+ let!(:taxonomy) { create(:taxonomy, organization: subject.organization) }
16
+
17
+ it "is not valid" do
18
+ expect { subject.taxonomies = [taxonomy] }.to raise_error(ActiveRecord::RecordInvalid).or change { subject.valid? }.to(false)
19
+ end
20
+ end
21
+
22
+ context "when a taxonomy from another organization is assigned" do
23
+ let(:taxonomy) { create(:taxonomy, :with_parent) }
24
+ before do
25
+ subject.taxonomies = [taxonomy]
26
+ end
27
+
28
+ it { is_expected.to be_invalid }
29
+ end
30
+ end
31
+
32
+ describe "scopes" do
33
+ let(:root_taxonomy) { create(:taxonomy, organization: subject.organization) }
34
+ let(:taxonomy) { create(:taxonomy, parent: root_taxonomy, organization: subject.organization) }
35
+
36
+ let(:another_taxonomy) { create(:taxonomy, parent: root_taxonomy, organization: subject.organization) }
37
+ let!(:taxonomization) { create(:taxonomization, taxonomizable: subject, taxonomy:) }
38
+ let!(:another_taxonomization) { create(:taxonomization, taxonomy: another_taxonomy) }
39
+
40
+ describe ".with_taxonomy" do
41
+ it "returns the taxonomizable" do
42
+ expect(described_class.with_taxonomy(taxonomy.id)).to eq([subject])
43
+ expect(described_class.with_taxonomy(root_taxonomy.id)).to eq([subject])
44
+ end
45
+
46
+ it "returns empty if not in the taxonomy" do
47
+ expect(described_class.with_taxonomy(another_taxonomy.id)).to be_empty
48
+ end
49
+ end
50
+
51
+ describe ".with_taxonomies" do
52
+ it "returns the taxonomizable" do
53
+ expect(described_class.with_taxonomies(taxonomy.id, another_taxonomization.id)).to eq([subject])
54
+ expect(described_class.with_taxonomies(root_taxonomy.id, another_taxonomization.id)).to eq([subject])
55
+ end
56
+
57
+ it "returns empty if not in the taxonomy" do
58
+ expect(described_class.with_taxonomies(another_taxonomy.id)).to be_empty
59
+ end
60
+ end
61
+
62
+ describe ".with_any_taxonomies" do
63
+ let!(:missing_taxonomy) { create(:taxonomy, parent: root_taxonomy, organization: subject.organization) }
64
+ let(:second_root_taxonomy) { create(:taxonomy, organization: subject.organization) }
65
+ let(:second_taxonomy) { create(:taxonomy, parent: second_root_taxonomy, organization: subject.organization) }
66
+ let!(:second_taxonomization) { create(:taxonomization, taxonomizable: subject, taxonomy: second_taxonomy) }
67
+ let(:third_root_taxonomy) { create(:taxonomy, organization: subject.organization) }
68
+ let(:third_taxonomy) { create(:taxonomy, parent: third_root_taxonomy, organization: subject.organization) }
69
+ let!(:third_taxonomization) { create(:taxonomization, taxonomizable: subject, taxonomy: third_taxonomy) }
70
+
71
+ it "returns the taxonomizable matching all subsets" do
72
+ subset1 = [root_taxonomy.id, [taxonomy.id, another_taxonomy.id]]
73
+ subset2 = [second_root_taxonomy.id, [second_taxonomy.id]]
74
+ subset3 = [third_root_taxonomy.id, [third_taxonomy.id]]
75
+ expect(described_class.with_any_taxonomies(subset1, subset2, subset3)).to eq([subject])
76
+ end
77
+
78
+ it "returns empty if one subset is missing" do
79
+ subset1 = [root_taxonomy.id, [missing_taxonomy.id]]
80
+ subset2 = [second_root_taxonomy.id, [second_taxonomy.id]]
81
+ subset3 = [third_root_taxonomy.id, [third_taxonomy.id]]
82
+ expect(described_class.with_any_taxonomies(subset1, subset2, subset3)).to be_empty
83
+ end
84
+
85
+ it "returns the taxonomizable if all taxonomies are present in the missing subset" do
86
+ subset1 = [root_taxonomy.id, [missing_taxonomy.id, "all"]]
87
+ subset2 = [second_root_taxonomy.id, [second_taxonomy.id]]
88
+ subset3 = [third_root_taxonomy.id, [third_taxonomy.id]]
89
+
90
+ expect(described_class.with_any_taxonomies(subset1, subset2, subset3)).to eq([subject])
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,237 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples "manage resource share tokens" do
4
+ context "when there are no tokens" do
5
+ let(:last_token) { Decidim::ShareToken.last }
6
+ before do
7
+ visit_share_tokens_page
8
+ end
9
+
10
+ it "displays empty message" do
11
+ expect(page).to have_content "There are no active access links"
12
+ end
13
+
14
+ it "can create a new token with default options" do
15
+ click_on "New access link"
16
+
17
+ click_on "Create"
18
+
19
+ expect(page).to have_content("Access link created successfully")
20
+ expect(page).to have_css("tbody tr", count: 1)
21
+ within "tbody tr:last-child td", text: last_token.token do
22
+ expect(page).to have_content(last_token.token)
23
+ end
24
+ within "tbody tr:last-child td:nth-child(2)" do
25
+ expect(page).to have_content("Never")
26
+ end
27
+ within "tbody tr:last-child td:nth-child(3)" do
28
+ expect(page).to have_content("No")
29
+ end
30
+ end
31
+
32
+ it "can create a new token with custom options" do
33
+ click_on "New access link"
34
+
35
+ find_by_id("share_token_automatic_token_false").click
36
+ find_by_id("share_token_no_expiration_false").click
37
+ find_by_id("share_token_registered_only_true").click
38
+ click_on "Create"
39
+ expect(page).to have_content("cannot be blank", count: 2)
40
+
41
+ fill_in "share_token_token", with: " custom token "
42
+ fill_in_datepicker :share_token_expires_at_date, with: 1.day.from_now.strftime("%d/%m/%Y")
43
+ fill_in_timepicker :share_token_expires_at_time, with: "00:00"
44
+ click_on "Create"
45
+
46
+ expect(page).to have_content("Access link created successfully")
47
+ expect(page).to have_css("tbody tr", count: 1)
48
+ within "tbody tr:last-child td", text: last_token.token do
49
+ expect(page).to have_content("CUSTOM-TOKEN")
50
+ end
51
+ within "tbody tr:last-child td:nth-child(2)" do
52
+ expect(page).to have_content(1.day.from_now.strftime("%d/%m/%Y 00:00"))
53
+ end
54
+ within "tbody tr:last-child td:nth-child(3)" do
55
+ expect(page).to have_content("Yes")
56
+ end
57
+ end
58
+ end
59
+
60
+ context "when there are tokens" do
61
+ let!(:share_tokens) { create_list(:share_token, 3, :with_token, token_for: resource, organization:, registered_only: true) }
62
+ let(:last_token) { share_tokens.last }
63
+
64
+ before do
65
+ visit_share_tokens_page
66
+ end
67
+
68
+ it "displays all tokens" do
69
+ within ".share_tokens" do
70
+ expect(page).to have_css("tbody tr", count: 3)
71
+ end
72
+ end
73
+
74
+ it "displays relevant attributes for each token" do
75
+ share_tokens.each do |share_token|
76
+ within ".share_tokens tbody" do
77
+ expect(page).to have_content share_token.token
78
+ expect(page).to have_content share_token.expires_at.to_s
79
+ end
80
+ end
81
+ end
82
+
83
+ context "when ordering" do
84
+ let(:share_tokens) do
85
+ [
86
+ create(:share_token, :with_token, token_for: resource, organization:, token: "b", expires_at: 1.day.from_now, registered_only: true, times_used: 3),
87
+ create(:share_token, :with_token, token_for: resource, organization:, token: "a", expires_at: 3.days.from_now, registered_only: true, times_used: 2),
88
+ create(:share_token, :with_token, token_for: resource, organization:, token: "c", expires_at: 2.days.from_now, registered_only: false, times_used: 1)
89
+ ]
90
+ end
91
+
92
+ it "can be ordered by token and other attributes" do
93
+ within ".share_tokens" do
94
+ click_on "Access link" # order by token
95
+ expect(page).to have_css("tbody tr:first-child", text: "c")
96
+ click_on "Access link" # order by token
97
+ expect(page).to have_css("tbody tr:first-child", text: "a")
98
+ click_on "Expires at" # order by expires_at
99
+ expect(page).to have_css("tbody tr:first-child", text: share_tokens.second.expires_at.strftime("%d/%m/%Y %H:%M"))
100
+ click_on "Expires at" # order by expires_at
101
+ expect(page).to have_css("tbody tr:first-child", text: share_tokens.first.expires_at.strftime("%d/%m/%Y %H:%M"))
102
+ click_on "Registered only" # order by registered_only
103
+ expect(page).to have_css("tbody tr:first-child", text: "Yes")
104
+ click_on "Registered only" # order by registered_only
105
+ expect(page).to have_css("tbody tr:first-child", text: "No")
106
+ click_on "Times used" # order by times_used
107
+ expect(page).to have_css("tbody tr:first-child", text: "3")
108
+ click_on "Times used" # order by times_used
109
+ expect(page).to have_css("tbody tr:first-child", text: "1")
110
+ end
111
+ end
112
+ end
113
+
114
+ it "can edit a share token" do
115
+ within "tbody tr", text: last_token.token do
116
+ expect(page).to have_content("Yes")
117
+ end
118
+ within ".share_tokens tbody tr", text: last_token.token do
119
+ click_on "Edit"
120
+ end
121
+
122
+ expect(page).to have_content("Edit access links for: #{resource_name}")
123
+ find_by_id("share_token_no_expiration_false").click
124
+ find_by_id("share_token_registered_only_false").click
125
+ click_on "Update"
126
+ expect(page).to have_content("cannot be blank", count: 1)
127
+
128
+ fill_in_datepicker :share_token_expires_at_date, with: 1.day.from_now.strftime("%d/%m/%Y")
129
+ fill_in_timepicker :share_token_expires_at_time, with: "00:00"
130
+
131
+ click_on "Update"
132
+
133
+ expect(page).to have_content("Access link updated successfully")
134
+ expect(page).to have_css("tbody tr", count: 3)
135
+ within "tbody tr", text: last_token.token do
136
+ expect(page).to have_content(1.day.from_now.strftime("%d/%m/%Y 00:00"))
137
+ end
138
+ within "tbody tr", text: last_token.token do
139
+ expect(page).to have_content("No")
140
+ end
141
+ end
142
+
143
+ it "allows copying the share link from the share token" do
144
+ within ".share_tokens tbody tr", text: last_token.token do
145
+ click_on "Copy link"
146
+ expect(page).to have_content("copied!")
147
+ expect(page).to have_css("[data-clipboard-copy-label]")
148
+ expect(page).to have_css("[data-clipboard-copy-message]")
149
+ expect(page).to have_css("[data-clipboard-content]")
150
+ end
151
+ end
152
+
153
+ it "has a share link for each token" do
154
+ urls = share_tokens.map(&:url)
155
+ within ".share_tokens tbody tr", text: last_token.token do
156
+ share_window = window_opened_by { click_on "Preview" }
157
+
158
+ within_window share_window do
159
+ expect(urls).to include(page.current_url)
160
+ end
161
+ end
162
+ end
163
+
164
+ it "has a share button that opens the share url for the resource" do
165
+ within ".share_tokens tbody tr", text: last_token.token do
166
+ share_window = window_opened_by { click_on "Preview", wait: 2 }
167
+
168
+ within_window share_window do
169
+ expect(current_url).to include(last_token.url)
170
+ end
171
+ end
172
+ end
173
+
174
+ it "can delete tokens" do
175
+ within ".share_tokens tbody tr", text: last_token.token do
176
+ accept_confirm { click_on "Delete" }
177
+ end
178
+
179
+ expect(page).to have_admin_callout("Access link successfully destroyed")
180
+ expect(page).to have_css("tbody tr", count: 2)
181
+ end
182
+ end
183
+
184
+ context "when there are many pages" do
185
+ let!(:share_tokens) { create_list(:share_token, 26, :with_token, token_for: resource, organization:) }
186
+
187
+ before do
188
+ visit_share_tokens_page
189
+ end
190
+
191
+ it "displays pagination" do
192
+ expect(page).to have_css("tbody tr", count: 25)
193
+ within '[aria-label="Pagination"]' do
194
+ click_on "Next"
195
+ end
196
+ expect(page).to have_css("tbody tr", count: 1)
197
+ end
198
+ end
199
+ end
200
+
201
+ shared_examples "manage component share tokens" do
202
+ let!(:components_path) { participatory_space_engine.components_path(participatory_space) }
203
+ let!(:component) { create(:component, participatory_space:, published_at: nil) }
204
+ let(:resource) { component }
205
+ let(:resource_name) { translated(component.name) }
206
+
207
+ before do
208
+ switch_to_host(organization.host)
209
+ login_as user, scope: :user
210
+ end
211
+
212
+ def visit_share_tokens_page
213
+ visit components_path
214
+ within ".table-list" do
215
+ click_on "Access links"
216
+ end
217
+ end
218
+
219
+ it_behaves_like "manage resource share tokens"
220
+ end
221
+
222
+ shared_examples "manage participatory space share tokens" do
223
+ let(:resource) { participatory_space }
224
+ let(:resource_name) { translated(resource.title) }
225
+
226
+ before do
227
+ switch_to_host(organization.host)
228
+ login_as user, scope: :user
229
+ end
230
+
231
+ def visit_share_tokens_page
232
+ visit participatory_spaces_path
233
+ click_on "Access links"
234
+ end
235
+
236
+ it_behaves_like "manage resource share tokens"
237
+ end
@@ -14,6 +14,8 @@ shared_context "with frontend map builder" do
14
14
 
15
15
  let(:template_class) do
16
16
  Class.new(ActionView::Base) do
17
+ include Decidim::LayoutHelper
18
+
17
19
  def protect_against_forgery?
18
20
  false
19
21
  end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples_for "default open data exporter" do
4
+ let(:organization) { create(:organization) }
5
+ let(:path) { "/tmp/test-open-data-#{resource_file_name}.zip" }
6
+ let(:zip_contents) { Zip::File.open(path) }
7
+
8
+ let(:file_name) { "*open-data-#{resource_file_name}.csv" }
9
+ let(:file) { zip_contents.glob(file_name).first }
10
+ let(:data) { file.get_input_stream.read }
11
+
12
+ before do
13
+ subject.export
14
+ end
15
+
16
+ it "includes a CSV" do
17
+ expect(file).not_to be_nil
18
+ end
19
+
20
+ describe "README content" do
21
+ let(:file_name) { "README.md" }
22
+
23
+ it "includes the resource help description" do
24
+ expect(data).to include(resource_title)
25
+ help_lines.each do |line|
26
+ expect(data).to include(line)
27
+ end
28
+ end
29
+
30
+ it "does not have any missing translation" do
31
+ expect(data).not_to include("Translation missing")
32
+ end
33
+ end
34
+ end
35
+
36
+ shared_examples_for "open users data exporter" do
37
+ include_examples "default open data exporter"
38
+
39
+ it "includes the resource data" do
40
+ expect(data).to include(resource.nickname.gsub("\"", "\"\""))
41
+ end
42
+
43
+ context "with unpublished components" do
44
+ it "does not include the resource data" do
45
+ expect(data).not_to include(unpublished_resource.nickname.gsub("\"", "\"\""))
46
+ end
47
+ end
48
+ end
49
+
50
+ shared_examples_for "open moderation data exporter" do
51
+ include_examples "default open data exporter"
52
+
53
+ it "includes the resource data" do
54
+ if resource.respond_to?(:reportable)
55
+ expect(data).to include(resource.reportable.reported_content_url.gsub("\"", "\"\""))
56
+ elsif resource.respond_to?(:reported?)
57
+ expect(data).to include(resource.id.to_s)
58
+ else
59
+ raise "Failed to understand the model"
60
+ end
61
+ end
62
+
63
+ context "with unpublished components" do
64
+ it "does not include the resource data" do
65
+ if unpublished_resource.respond_to?(:reportable)
66
+ expect(data).not_to include(unpublished_resource.reportable.reported_content_url.gsub("\"", "\"\""))
67
+ elsif unpublished_resource.respond_to?(:reported?)
68
+ expect(data).not_to include(unpublished_resource.id.to_s)
69
+ else
70
+ raise "Failed to understand the model"
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ shared_examples_for "open data exporter" do
77
+ include_examples "default open data exporter"
78
+
79
+ it "includes the resource data" do
80
+ if resource.respond_to?(:title)
81
+ expect(data).to include(translated(resource.title).gsub("\"", "\"\""))
82
+ elsif resource.respond_to?(:body)
83
+ # Seems like the comments are always taking the first alphabetical language for the export
84
+ # We should fix it in the future
85
+ expect(data).to include(resource.body.min.second)
86
+ else
87
+ raise "Failed to understand the model"
88
+ end
89
+ end
90
+
91
+ context "with unpublished components" do
92
+ it "does not include the resource data" do
93
+ if unpublished_resource.respond_to?(:title)
94
+ expect(data).not_to include(translated(unpublished_resource.title).gsub("\"", "\"\""))
95
+ elsif unpublished_resource.respond_to?(:body)
96
+ expect(data).not_to include(translated(unpublished_resource.body).gsub("\"", "\"\""))
97
+ else
98
+ raise "Failed to understand the model"
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples "participatory space members page examples" do
4
+ let(:user1) { create(:user, organization: privatable_to.organization) }
5
+ let(:user2) { create(:user, organization: privatable_to.organization) }
6
+ let(:user3) { create(:user, organization: privatable_to.organization) }
7
+
8
+ before do
9
+ request.env["decidim.current_organization"] = organization
10
+ end
11
+
12
+ describe "GET index" do
13
+ context "when participatory space has no members" do
14
+ it "redirects to 404" do
15
+ expect { get :index, params: { slug_param => slug } }
16
+ .to raise_error(ActionController::RoutingError)
17
+ end
18
+ end
19
+
20
+ context "when participatory space has members" do
21
+ let!(:member1) { create(:participatory_space_private_user, privatable_to:, user: user1, published: true) }
22
+ let!(:member2) { create(:participatory_space_private_user, privatable_to:, user: user2, published: true) }
23
+ let!(:non_published) { create(:participatory_space_private_user, privatable_to:, user: user3, published: false) }
24
+
25
+ context "when user has permissions" do
26
+ it "displays list of members" do
27
+ get :index, params: { slug_param => slug }
28
+
29
+ expect(controller.helpers.collection).to contain_exactly(member1, member2)
30
+ end
31
+ end
32
+
33
+ context "when user does not have permissions" do
34
+ before do
35
+ allow(controller).to receive(:current_user_can_visit_space?).and_return(false)
36
+ end
37
+
38
+ it "redirects to participatory space path" do
39
+ get :index, params: { slug_param => slug }
40
+
41
+ expect(response).to redirect_to(privatable_to)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end