decidim-core 0.26.4 → 0.27.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim-core might be problematic. Click here for more details.

Files changed (569) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/cells/decidim/amendable/announcement_cell.rb +4 -9
  4. data/app/cells/decidim/announcement_cell.rb +1 -1
  5. data/app/cells/decidim/author_cell.rb +1 -1
  6. data/app/cells/decidim/card_m_cell.rb +1 -1
  7. data/app/cells/decidim/content_blocks/cta/show.erb +1 -1
  8. data/app/cells/decidim/content_blocks/footer_sub_hero/show.erb +1 -1
  9. data/app/cells/decidim/content_blocks/hero/show.erb +1 -1
  10. data/app/cells/decidim/content_blocks/highlighted_content_banner/show.erb +4 -4
  11. data/app/cells/decidim/content_blocks/highlighted_elements_cell.rb +1 -1
  12. data/app/cells/decidim/content_blocks/how_to_participate/show.erb +1 -1
  13. data/app/cells/decidim/content_blocks/last_activity/show.erb +1 -1
  14. data/app/cells/decidim/content_blocks/last_activity_cell.rb +3 -3
  15. data/app/cells/decidim/content_blocks/stats_cell.rb +4 -5
  16. data/app/cells/decidim/content_blocks/sub_hero/show.erb +1 -1
  17. data/app/cells/decidim/data_consent/category.erb +64 -0
  18. data/app/cells/decidim/data_consent/dialog.erb +29 -0
  19. data/app/cells/decidim/data_consent/modal.erb +39 -0
  20. data/app/cells/decidim/data_consent/show.erb +3 -0
  21. data/app/cells/decidim/data_consent_cell.rb +21 -0
  22. data/app/cells/decidim/follow_button_cell.rb +5 -7
  23. data/app/cells/decidim/profile_sidebar_cell.rb +1 -1
  24. data/app/cells/decidim/search_results_cell.rb +1 -1
  25. data/app/cells/decidim/tos_page/refuse_btn_modal.erb +1 -1
  26. data/app/cells/decidim/upload_modal/files.erb +52 -0
  27. data/app/cells/decidim/upload_modal/modal.erb +49 -0
  28. data/app/cells/decidim/upload_modal/show.erb +3 -0
  29. data/app/cells/decidim/upload_modal_cell.rb +205 -0
  30. data/app/cells/decidim/user_conversation/reply.erb +1 -1
  31. data/app/cells/decidim/user_conversations/add_conversation_users.erb +5 -3
  32. data/app/cells/decidim/version_cell.rb +2 -13
  33. data/app/cells/decidim/versions_list_cell.rb +2 -13
  34. data/app/cells/decidim/versions_list_item_cell.rb +2 -13
  35. data/app/commands/decidim/accept_group_invitation.rb +1 -1
  36. data/app/commands/decidim/accept_user_group_join_request.rb +1 -1
  37. data/app/commands/decidim/amendable/accept.rb +1 -1
  38. data/app/commands/decidim/amendable/create_draft.rb +1 -1
  39. data/app/commands/decidim/amendable/destroy_draft.rb +1 -1
  40. data/app/commands/decidim/amendable/promote.rb +1 -1
  41. data/app/commands/decidim/amendable/publish_draft.rb +1 -1
  42. data/app/commands/decidim/amendable/reject.rb +1 -1
  43. data/app/commands/decidim/amendable/update_draft.rb +1 -1
  44. data/app/commands/decidim/amendable/withdraw.rb +1 -1
  45. data/app/commands/decidim/attachment_methods.rb +3 -2
  46. data/app/commands/decidim/create_editor_image.rb +1 -1
  47. data/app/commands/decidim/create_follow.rb +1 -1
  48. data/app/commands/decidim/create_omniauth_registration.rb +2 -3
  49. data/app/commands/decidim/create_registration.rb +1 -2
  50. data/app/commands/decidim/create_report.rb +1 -1
  51. data/app/commands/decidim/create_user_group.rb +2 -2
  52. data/app/commands/decidim/create_user_report.rb +5 -3
  53. data/app/commands/decidim/delete_follow.rb +1 -1
  54. data/app/commands/decidim/demote_membership.rb +1 -1
  55. data/app/commands/decidim/destroy_account.rb +1 -1
  56. data/app/commands/decidim/endorse_resource.rb +1 -1
  57. data/app/commands/decidim/gallery_methods.rb +45 -10
  58. data/app/commands/decidim/invite_user.rb +1 -3
  59. data/app/commands/decidim/invite_user_again.rb +1 -1
  60. data/app/commands/decidim/invite_user_to_group.rb +1 -1
  61. data/app/commands/decidim/join_user_group.rb +1 -1
  62. data/app/commands/decidim/leave_user_group.rb +8 -2
  63. data/app/commands/decidim/messaging/reply_to_conversation.rb +2 -2
  64. data/app/commands/decidim/messaging/start_conversation.rb +2 -2
  65. data/app/commands/decidim/multiple_attachments_methods.rb +44 -5
  66. data/app/commands/decidim/promote_membership.rb +1 -1
  67. data/app/commands/decidim/reject_group_invitation.rb +1 -1
  68. data/app/commands/decidim/reject_user_group_join_request.rb +1 -1
  69. data/app/commands/decidim/remove_user_from_group.rb +1 -1
  70. data/app/commands/decidim/resend_confirmation_instructions.rb +18 -0
  71. data/app/commands/decidim/search.rb +10 -9
  72. data/app/commands/decidim/unendorse_resource.rb +1 -1
  73. data/app/commands/decidim/unsubscribe_settings.rb +1 -1
  74. data/app/commands/decidim/update_account.rb +2 -2
  75. data/app/commands/decidim/update_notifications_settings.rb +3 -2
  76. data/app/commands/decidim/update_password.rb +31 -0
  77. data/app/commands/decidim/update_user_group.rb +2 -2
  78. data/app/commands/decidim/update_user_interests.rb +1 -1
  79. data/app/commands/decidim/validate_upload.rb +15 -0
  80. data/app/controllers/concerns/decidim/devise_controllers.rb +0 -1
  81. data/app/controllers/concerns/decidim/filter_resource.rb +23 -24
  82. data/app/controllers/concerns/decidim/force_authentication.rb +1 -2
  83. data/app/controllers/concerns/decidim/http_caching_disabler.rb +1 -1
  84. data/app/controllers/concerns/decidim/needs_password_change.rb +43 -0
  85. data/app/controllers/concerns/decidim/needs_tos_accepted.rb +3 -3
  86. data/app/controllers/concerns/decidim/orderable.rb +1 -1
  87. data/app/controllers/concerns/decidim/participatory_space_context.rb +2 -2
  88. data/app/controllers/concerns/decidim/resource_versions_concern.rb +0 -4
  89. data/app/controllers/decidim/account_controller.rb +45 -0
  90. data/app/controllers/decidim/application_controller.rb +1 -1
  91. data/app/controllers/decidim/devise/invitations_controller.rb +4 -9
  92. data/app/controllers/decidim/devise/passwords_controller.rb +33 -0
  93. data/app/controllers/decidim/devise/registrations_controller.rb +3 -5
  94. data/app/controllers/decidim/devise/sessions_controller.rb +2 -0
  95. data/app/controllers/decidim/{data_portability_controller.rb → download_your_data_controller.rb} +8 -8
  96. data/app/controllers/decidim/groups_controller.rb +5 -0
  97. data/app/controllers/decidim/last_activities_controller.rb +7 -9
  98. data/app/controllers/decidim/manifests_controller.rb +11 -0
  99. data/app/controllers/decidim/newsletters_controller.rb +1 -1
  100. data/app/controllers/decidim/notifications_subscriptions_controller.rb +16 -0
  101. data/app/controllers/decidim/offline_controller.rb +7 -0
  102. data/app/controllers/decidim/profiles_controller.rb +1 -1
  103. data/app/controllers/decidim/searches_controller.rb +4 -3
  104. data/app/controllers/decidim/short_links_controller.rb +35 -0
  105. data/app/controllers/decidim/upload_validations_controller.rb +44 -0
  106. data/app/controllers/decidim/user_activities_controller.rb +32 -16
  107. data/app/controllers/decidim/user_interests_controller.rb +0 -2
  108. data/app/controllers/decidim/user_timeline_controller.rb +6 -8
  109. data/app/events/decidim/change_nickname_event.rb +21 -0
  110. data/app/events/decidim/resource_endorsed_event.rb +1 -2
  111. data/app/forms/decidim/account_form.rb +3 -3
  112. data/app/forms/decidim/amendable/form.rb +1 -2
  113. data/app/forms/decidim/form.rb +1 -1
  114. data/app/forms/decidim/messaging/conversation_form.rb +1 -1
  115. data/app/forms/decidim/notifications_settings_form.rb +8 -2
  116. data/app/forms/decidim/password_form.rb +10 -0
  117. data/app/forms/decidim/registration_form.rb +2 -2
  118. data/app/forms/decidim/upload_validation_form.rb +54 -0
  119. data/app/forms/decidim/user_group_form.rb +1 -1
  120. data/app/forms/decidim/user_interest_scope_form.rb +1 -1
  121. data/app/forms/decidim/user_interests_form.rb +1 -1
  122. data/app/forms/translatable_presence_validator.rb +2 -2
  123. data/app/forms/url_validator.rb +1 -1
  124. data/app/helpers/decidim/application_helper.rb +2 -2
  125. data/app/helpers/decidim/attachments_helper.rb +1 -1
  126. data/app/helpers/decidim/cells_paginate_helper.rb +1 -1
  127. data/app/helpers/decidim/datalist_select_helper.rb +40 -0
  128. data/app/helpers/decidim/decidim_form_helper.rb +1 -1
  129. data/app/helpers/decidim/filters_helper.rb +1 -5
  130. data/app/helpers/decidim/followable_helper.rb +1 -1
  131. data/app/helpers/decidim/icon_helper.rb +1 -1
  132. data/app/helpers/decidim/layout_helper.rb +15 -1
  133. data/app/helpers/decidim/map_helper.rb +12 -8
  134. data/app/helpers/decidim/meta_tags_helper.rb +0 -2
  135. data/app/helpers/decidim/notifications_settings_helper.rb +15 -0
  136. data/app/helpers/decidim/passwords_helper.rb +41 -0
  137. data/app/helpers/decidim/sanitize_helper.rb +1 -0
  138. data/app/helpers/decidim/searches_helper.rb +6 -6
  139. data/app/helpers/decidim/short_link_helper.rb +28 -0
  140. data/app/helpers/decidim/translations_helper.rb +2 -2
  141. data/app/jobs/decidim/{data_portability_export_job.rb → download_your_data_export_job.rb} +5 -5
  142. data/app/jobs/decidim/email_notifications_digest_generator_job.rb +21 -0
  143. data/app/jobs/decidim/notification_generator_for_recipient_job.rb +5 -3
  144. data/app/jobs/decidim/reminder_generator_job.rb +12 -0
  145. data/app/jobs/decidim/resend_confirmation_instructions_job.rb +11 -0
  146. data/app/jobs/decidim/user_report_job.rb +2 -2
  147. data/app/mailers/concerns/decidim/multitenant_asset_host.rb +11 -3
  148. data/app/mailers/decidim/application_mailer.rb +1 -1
  149. data/app/mailers/decidim/block_user_mailer.rb +8 -7
  150. data/app/mailers/decidim/export_mailer.rb +2 -2
  151. data/app/mailers/decidim/newsletter_mailer.rb +2 -2
  152. data/app/mailers/decidim/newsletters_opt_in_mailer.rb +7 -5
  153. data/app/mailers/decidim/notification_mailer.rb +0 -1
  154. data/app/mailers/decidim/notifications_digest_mailer.rb +23 -0
  155. data/app/mailers/decidim/user_report_mailer.rb +10 -11
  156. data/app/models/decidim/action_log.rb +95 -11
  157. data/app/models/decidim/amendment.rb +0 -1
  158. data/app/models/decidim/area.rb +1 -2
  159. data/app/models/decidim/area_type.rb +5 -0
  160. data/app/models/decidim/attachment.rb +6 -0
  161. data/app/models/decidim/attachment_collection.rb +5 -0
  162. data/app/models/decidim/category.rb +9 -4
  163. data/app/models/decidim/coauthorship.rb +0 -2
  164. data/app/models/decidim/contextual_help_section.rb +5 -1
  165. data/app/models/decidim/follow.rb +2 -2
  166. data/app/models/decidim/gamification/badge_score.rb +0 -1
  167. data/app/models/decidim/identity.rb +2 -2
  168. data/app/models/decidim/messaging/conversation.rb +4 -4
  169. data/app/models/decidim/messaging/message.rb +1 -2
  170. data/app/models/decidim/messaging/participation.rb +0 -2
  171. data/app/models/decidim/messaging/receipt.rb +0 -2
  172. data/app/models/decidim/notification.rb +5 -2
  173. data/app/models/decidim/oauth_application.rb +12 -1
  174. data/app/models/decidim/organization.rb +7 -7
  175. data/app/models/decidim/participatory_space_private_user.rb +4 -2
  176. data/app/models/decidim/permission_action.rb +1 -0
  177. data/app/models/decidim/reminder.rb +10 -0
  178. data/app/models/decidim/reminder_delivery.rb +7 -0
  179. data/app/models/decidim/reminder_record.rb +29 -0
  180. data/app/models/decidim/report.rb +2 -2
  181. data/app/models/decidim/scope.rb +3 -4
  182. data/app/models/decidim/scope_type.rb +5 -0
  183. data/app/models/decidim/share_token.rb +0 -2
  184. data/app/models/decidim/short_link.rb +162 -0
  185. data/app/models/decidim/user.rb +34 -6
  186. data/app/models/decidim/user_base_entity.rb +1 -2
  187. data/app/models/decidim/user_group.rb +3 -3
  188. data/app/models/decidim/user_moderation.rb +0 -2
  189. data/app/models/decidim/user_report.rb +2 -2
  190. data/app/packs/entrypoints/decidim_core.js +2 -2
  191. data/app/packs/entrypoints/decidim_sw.js +1 -0
  192. data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_invitations.svg +1 -0
  193. data/app/packs/src/decidim/autocomplete.js +298 -0
  194. data/app/packs/src/decidim/cookie_consent/consent_manager.js +133 -0
  195. data/app/packs/src/decidim/cookie_consent/cookie_consent.js +103 -0
  196. data/app/packs/src/decidim/datalist_select.js +36 -0
  197. data/app/packs/src/decidim/direct_uploads/upload_field.js +117 -0
  198. data/app/packs/src/decidim/direct_uploads/upload_modal.js +264 -0
  199. data/app/packs/src/decidim/direct_uploads/upload_utility.js +49 -0
  200. data/app/packs/src/decidim/direct_uploads/uploader.js +89 -0
  201. data/app/packs/src/decidim/editor/linebreak_module.js +8 -0
  202. data/app/packs/src/decidim/editor.js +2 -9
  203. data/app/packs/src/decidim/external_domain_warning.js +1 -1
  204. data/app/packs/src/decidim/external_link.js +14 -3
  205. data/app/packs/src/decidim/external_link.test.js +64 -0
  206. data/app/packs/src/decidim/geocoding.js +10 -35
  207. data/app/packs/src/decidim/identity_selector_dialog.js +1 -1
  208. data/app/packs/src/decidim/impersonation.js +3 -3
  209. data/app/packs/src/decidim/input_character_counter.js +177 -7
  210. data/app/packs/src/decidim/input_multiple_mentions.js +87 -187
  211. data/app/packs/src/decidim/map/icon.js +2 -1
  212. data/app/packs/src/decidim/map/svg-icon.js +248 -0
  213. data/app/packs/src/decidim/security/selfxss_warning.js +5 -1
  214. data/app/packs/src/decidim/session_timeouter.js +15 -15
  215. data/app/packs/src/decidim/sw/a2hs.js +28 -0
  216. data/app/packs/src/decidim/sw/index.js +3 -0
  217. data/app/packs/src/decidim/sw/loader.js +18 -0
  218. data/app/packs/src/decidim/sw/push-permissions.js +87 -0
  219. data/app/packs/src/decidim/sw/sw.js +80 -0
  220. data/app/packs/src/decidim/vizzs/areachart.js +33 -28
  221. data/app/packs/src/decidim/vizzs/linechart.js +23 -18
  222. data/app/packs/src/decidim/vizzs/rowchart.js +15 -11
  223. data/app/packs/stylesheets/decidim/email.scss +66 -0
  224. data/app/packs/stylesheets/decidim/layouts/_user.scss +8 -0
  225. data/app/packs/stylesheets/decidim/modules/_autocomplete.scss +99 -0
  226. data/app/packs/stylesheets/decidim/modules/_cards.scss +0 -2
  227. data/app/packs/stylesheets/decidim/modules/_comments.scss +0 -2
  228. data/app/packs/stylesheets/decidim/modules/_cookie-consent.scss +115 -0
  229. data/app/packs/stylesheets/decidim/modules/_footer.scss +4 -0
  230. data/app/packs/stylesheets/decidim/modules/_forms.scss +0 -5
  231. data/app/packs/stylesheets/decidim/modules/_input-multiple-mentions.scss +29 -2
  232. data/app/packs/stylesheets/decidim/modules/_modules.scss +3 -1
  233. data/app/packs/stylesheets/decidim/modules/_reveal.scss +15 -0
  234. data/app/packs/stylesheets/decidim/modules/_upload_modal.scss +143 -0
  235. data/app/packs/stylesheets/decidim/utils/_fontface.scss +3 -0
  236. data/app/permissions/decidim/permissions.rb +4 -8
  237. data/app/presenters/decidim/admin_log/area_type_presenter.rb +34 -0
  238. data/app/presenters/decidim/admin_log/attachment_collection_presenter.rb +35 -0
  239. data/app/presenters/decidim/admin_log/attachment_presenter.rb +27 -0
  240. data/app/presenters/decidim/admin_log/category_presenter.rb +36 -0
  241. data/app/presenters/decidim/admin_log/component_presenter.rb +35 -3
  242. data/app/presenters/decidim/admin_log/contextual_help_section_presenter.rb +33 -0
  243. data/app/presenters/decidim/admin_log/organization_presenter.rb +9 -4
  244. data/app/presenters/decidim/admin_log/scope_type_presenter.rb +34 -0
  245. data/app/presenters/decidim/home_stats_presenter.rb +8 -13
  246. data/app/presenters/decidim/log/base_presenter.rb +1 -1
  247. data/app/presenters/decidim/menu_item_presenter.rb +1 -1
  248. data/app/presenters/decidim/metric_charts_presenter.rb +7 -1
  249. data/app/presenters/decidim/nil_presenter.rb +3 -1
  250. data/app/presenters/decidim/notification_to_mailer_presenter.rb +39 -0
  251. data/app/presenters/decidim/notifications_digest_presenter.rb +42 -0
  252. data/app/presenters/decidim/official_author_presenter.rb +4 -0
  253. data/app/presenters/decidim/organization_presenter.rb +22 -0
  254. data/app/presenters/decidim/push_notification_presenter.rb +24 -0
  255. data/app/presenters/decidim/stats_presenter.rb +9 -8
  256. data/app/presenters/decidim/user_presenter.rb +4 -12
  257. data/app/presenters/decidim/validation_errors_presenter.rb +1 -1
  258. data/app/queries/decidim/messaging/user_conversations.rb +1 -1
  259. data/app/queries/decidim/metric_manage.rb +1 -1
  260. data/app/queries/decidim/own_activities.rb +11 -0
  261. data/app/queries/decidim/participatory_processes_with_user_role.rb +1 -1
  262. data/app/{services/decidim/activity_search.rb → queries/decidim/public_activities.rb} +35 -78
  263. data/app/queries/decidim/public_components.rb +1 -1
  264. data/app/queries/decidim/similar_emendations.rb +1 -1
  265. data/app/queries/decidim/stats_users_count.rb +1 -1
  266. data/app/queries/decidim/user_groups/accepted_memberships.rb +1 -1
  267. data/app/queries/decidim/user_groups/accepted_user_groups.rb +1 -1
  268. data/app/queries/decidim/user_groups/accepted_users.rb +1 -1
  269. data/app/queries/decidim/user_groups/admin_memberships.rb +1 -1
  270. data/app/queries/decidim/user_groups/invited_memberships.rb +1 -1
  271. data/app/queries/decidim/user_groups/manageable_user_groups.rb +1 -1
  272. data/app/queries/decidim/user_groups/member_memberships.rb +1 -1
  273. data/app/services/decidim/{data_portability_exporter.rb → download_your_data_exporter.rb} +6 -6
  274. data/app/services/decidim/email_notification_generator.rb +2 -2
  275. data/app/services/decidim/engine_resolver.rb +66 -0
  276. data/app/services/decidim/events_manager.rb +1 -1
  277. data/app/services/decidim/iframe_disabler.rb +31 -0
  278. data/app/services/decidim/notification_generator_for_recipient.rb +1 -1
  279. data/app/services/decidim/notifications_digest_sending_decider.rb +18 -0
  280. data/app/services/decidim/notifications_subscriptions_persistor.rb +37 -0
  281. data/app/services/decidim/open_data_exporter.rb +1 -1
  282. data/app/services/decidim/resource_search.rb +17 -164
  283. data/app/services/decidim/send_push_notification.rb +59 -0
  284. data/app/services/decidim/traceability.rb +1 -1
  285. data/app/uploaders/decidim/application_uploader.rb +2 -12
  286. data/app/uploaders/decidim/cw/attachment_uploader.rb +1 -1
  287. data/app/uploaders/decidim/cw/{data_portability_uploader.rb → download_your_data_uploader.rb} +3 -3
  288. data/app/uploaders/decidim/cw/image_uploader.rb +2 -2
  289. data/app/uploaders/decidim/organization_favicon_uploader.rb +3 -2
  290. data/app/validators/etiquette_validator.rb +3 -7
  291. data/app/validators/passthru_validator.rb +29 -21
  292. data/app/validators/password_validator.rb +25 -4
  293. data/app/validators/uploader_image_dimensions_validator.rb +1 -1
  294. data/app/views/decidim/account/_account_notification.js.erb +20 -0
  295. data/app/views/decidim/account/_password_fields.html.erb +2 -2
  296. data/app/views/decidim/account/cancel_email_change.js.erb +6 -0
  297. data/app/views/decidim/account/resend_confirmation_instructions.erb +1 -0
  298. data/app/views/decidim/account/show.html.erb +19 -6
  299. data/app/views/decidim/application/{_attachments.html.erb → _attachments.erb} +2 -2
  300. data/app/views/decidim/application/_collection.html.erb +1 -1
  301. data/app/views/decidim/application/{_documents.html.erb → _documents.erb} +2 -2
  302. data/app/views/decidim/devise/confirmations/new.html.erb +1 -1
  303. data/app/views/decidim/devise/invitations/edit.html.erb +3 -4
  304. data/app/views/decidim/devise/omniauth_registrations/new.html.erb +3 -3
  305. data/app/views/decidim/devise/passwords/edit.html.erb +7 -5
  306. data/app/views/decidim/devise/passwords/new.html.erb +1 -1
  307. data/app/views/decidim/devise/registrations/edit.html.erb +41 -0
  308. data/app/views/decidim/devise/registrations/new.html.erb +5 -5
  309. data/app/views/decidim/devise/sessions/new.html.erb +2 -2
  310. data/app/views/decidim/{data_portability → download_your_data}/show.html.erb +2 -2
  311. data/app/views/decidim/export_mailer/download_your_data_export.html.erb +7 -0
  312. data/app/views/decidim/last_activities/index.html.erb +1 -1
  313. data/app/views/decidim/manifests/show.json.erb +31 -0
  314. data/app/views/decidim/messaging/conversations/_add_conversation_users.html.erb +5 -3
  315. data/app/views/decidim/messaging/conversations/_reply.html.erb +1 -1
  316. data/app/views/decidim/messaging/conversations/_start.html.erb +1 -3
  317. data/app/views/decidim/messaging/conversations/create.js.erb +1 -0
  318. data/app/views/decidim/notification_mailer/event_received.html.erb +1 -1
  319. data/app/views/decidim/notifications_digest_mailer/_email_content.html.erb +11 -0
  320. data/app/views/decidim/notifications_digest_mailer/digest_mail.erb +27 -0
  321. data/app/views/decidim/notifications_settings/show.html.erb +79 -52
  322. data/app/views/decidim/offline/show.html.erb +9 -0
  323. data/app/views/decidim/pages/_standalone.html.erb +1 -1
  324. data/app/views/decidim/reported_mailer/hide.html.erb +1 -1
  325. data/app/views/decidim/reported_mailer/report.html.erb +1 -1
  326. data/app/views/decidim/scopes/picker.html.erb +1 -1
  327. data/app/views/decidim/searches/_filters.html.erb +2 -2
  328. data/app/views/decidim/shared/participatory_space_filters/_filters.html.erb +3 -3
  329. data/app/views/decidim/user_interests/show.html.erb +13 -11
  330. data/app/views/decidim/user_report_mailer/notify.html.erb +10 -3
  331. data/app/views/devise/mailer/confirmation_instructions.html.erb +3 -1
  332. data/app/views/layouts/decidim/_application.html.erb +6 -3
  333. data/app/views/layouts/decidim/_cookie_warning.html.erb +8 -8
  334. data/app/views/layouts/decidim/_decidim_javascript.html.erb +12 -0
  335. data/app/views/layouts/decidim/_head.html.erb +4 -2
  336. data/app/views/layouts/decidim/_js_configuration.html.erb +5 -1
  337. data/app/views/layouts/decidim/_main_footer.html.erb +1 -0
  338. data/app/views/layouts/decidim/_offline_banner.html.erb +11 -0
  339. data/app/views/layouts/decidim/widget.html.erb +2 -2
  340. data/config/assets.rb +1 -0
  341. data/config/locales/am-ET.yml +1 -0
  342. data/config/locales/ar.yml +72 -36
  343. data/config/locales/bg.yml +38 -31
  344. data/config/locales/ca.yml +211 -40
  345. data/config/locales/cs.yml +218 -45
  346. data/config/locales/da.yml +1 -0
  347. data/config/locales/de.yml +49 -99
  348. data/config/locales/el.yml +37 -30
  349. data/config/locales/en.yml +205 -34
  350. data/config/locales/eo.yml +4 -6
  351. data/config/locales/es-MX.yml +208 -37
  352. data/config/locales/es-PY.yml +208 -37
  353. data/config/locales/es.yml +213 -42
  354. data/config/locales/et.yml +1 -0
  355. data/config/locales/eu.yml +41 -41
  356. data/config/locales/fi-plain.yml +206 -35
  357. data/config/locales/fi.yml +206 -35
  358. data/config/locales/fr-CA.yml +194 -37
  359. data/config/locales/fr.yml +201 -44
  360. data/config/locales/ga-IE.yml +10 -8
  361. data/config/locales/gl.yml +71 -30
  362. data/config/locales/hr.yml +1 -0
  363. data/config/locales/hu.yml +86 -206
  364. data/config/locales/id-ID.yml +39 -29
  365. data/config/locales/is-IS.yml +7 -17
  366. data/config/locales/it.yml +47 -41
  367. data/config/locales/ja.yml +197 -38
  368. data/config/locales/ko.yml +1 -0
  369. data/config/locales/lb.yml +38 -32
  370. data/config/locales/lt.yml +1 -1780
  371. data/config/locales/lv.yml +37 -28
  372. data/config/locales/mt.yml +1 -0
  373. data/config/locales/nl.yml +50 -36
  374. data/config/locales/no.yml +47 -36
  375. data/config/locales/om-ET.yml +1 -0
  376. data/config/locales/pl.yml +89 -35
  377. data/config/locales/pt-BR.yml +42 -35
  378. data/config/locales/pt.yml +39 -33
  379. data/config/locales/ro-RO.yml +42 -36
  380. data/config/locales/ru.yml +19 -26
  381. data/config/locales/si-LK.yml +1 -0
  382. data/config/locales/sk.yml +40 -30
  383. data/config/locales/sl.yml +1 -0
  384. data/config/locales/so-SO.yml +1 -0
  385. data/config/locales/sr-CS.yml +1 -0
  386. data/config/locales/sv.yml +90 -34
  387. data/config/locales/sw-KE.yml +1 -0
  388. data/config/locales/ti-ER.yml +1 -0
  389. data/config/locales/tr-TR.yml +39 -31
  390. data/config/locales/uk.yml +17 -27
  391. data/config/locales/val-ES.yml +1 -0
  392. data/config/locales/vi.yml +1 -0
  393. data/config/locales/zh-CN.yml +39 -30
  394. data/config/locales/zh-TW.yml +1 -0
  395. data/config/routes.rb +19 -22
  396. data/db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb +1 -0
  397. data/db/migrate/20181030090144_destroy_deleted_users_follows.rb +1 -0
  398. data/db/migrate/20190412131728_fix_user_names.rb +4 -4
  399. data/db/migrate/20210831181634_add_service_name_to_active_storage_blobs.active_storage.rb +22 -0
  400. data/db/migrate/20210831181635_create_active_storage_variant_records.active_storage.rb +14 -0
  401. data/db/migrate/20211208155453_create_decidim_reminders.rb +11 -0
  402. data/db/migrate/20211209121025_create_decidim_reminder_records.rb +11 -0
  403. data/db/migrate/20211209121040_create_decidim_reminder_deliveries.rb +10 -0
  404. data/db/migrate/20220118121921_change_required_description_categories.rb +7 -0
  405. data/db/migrate/20220127113419_add_notification_settings_to_users.rb +7 -0
  406. data/db/migrate/20220203121137_add_notifications_sending_frequency_to_users.rb +7 -0
  407. data/db/migrate/20220215172439_add_digest_sent_at_to_users.rb +7 -0
  408. data/db/migrate/20220323195258_add_index_to_decidim_users_notifications_sending_frequency.rb +7 -0
  409. data/db/migrate/20220427142214_drop_emails_on_notifications_flag_from_user.rb +15 -0
  410. data/db/migrate/20220518094535_add_previous_passwords_to_users.rb +20 -0
  411. data/db/migrate/20220524195530_create_decidim_short_links.rb +23 -0
  412. data/db/seeds.rb +17 -18
  413. data/lib/decidim/acts_as_tree.rb +47 -0
  414. data/lib/decidim/api/input_sorts/component_input_sort.rb +2 -1
  415. data/lib/decidim/api/interfaces/authorable_interface.rb +6 -5
  416. data/lib/decidim/asset_router.rb +80 -0
  417. data/lib/decidim/attachment_attributes.rb +8 -8
  418. data/lib/decidim/attribute_object/form.rb +174 -0
  419. data/lib/decidim/attribute_object/model.rb +148 -0
  420. data/lib/decidim/attribute_object/nested_validator.rb +22 -0
  421. data/lib/decidim/attribute_object/type_map.rb +14 -0
  422. data/lib/decidim/attribute_object/type_resolver.rb +91 -0
  423. data/lib/decidim/attribute_object.rb +26 -0
  424. data/lib/decidim/attributes/array.rb +62 -0
  425. data/lib/decidim/attributes/blob.rb +20 -0
  426. data/lib/decidim/attributes/clean_string.rb +12 -6
  427. data/lib/decidim/attributes/hash.rb +36 -0
  428. data/lib/decidim/attributes/integer.rb +17 -0
  429. data/lib/decidim/attributes/localized_date.rb +8 -14
  430. data/lib/decidim/attributes/model.rb +24 -0
  431. data/lib/decidim/attributes/object.rb +28 -0
  432. data/lib/decidim/attributes/symbol.rb +23 -0
  433. data/lib/decidim/attributes/time_with_zone.rb +7 -17
  434. data/lib/decidim/attributes.rb +29 -0
  435. data/lib/decidim/authorable.rb +21 -6
  436. data/lib/decidim/authorization_form_builder.rb +9 -11
  437. data/lib/decidim/carrier_wave_migrator_service.rb +15 -15
  438. data/lib/decidim/coauthorable.rb +22 -4
  439. data/lib/decidim/command.rb +44 -0
  440. data/lib/decidim/common_passwords.rb +1 -1
  441. data/lib/decidim/component_manifest.rb +5 -5
  442. data/lib/decidim/component_validator.rb +2 -2
  443. data/lib/decidim/content_block_manifest.rb +1 -1
  444. data/lib/decidim/content_parsers/hashtag_parser.rb +2 -2
  445. data/lib/decidim/content_parsers/resource_parser.rb +1 -1
  446. data/lib/decidim/content_parsers/user_group_parser.rb +1 -1
  447. data/lib/decidim/content_parsers/user_parser.rb +4 -4
  448. data/lib/decidim/content_renderers/hashtag_renderer.rb +1 -1
  449. data/lib/decidim/content_renderers/link_renderer.rb +2 -2
  450. data/lib/decidim/content_renderers/user_group_renderer.rb +1 -1
  451. data/lib/decidim/content_renderers/user_renderer.rb +1 -1
  452. data/lib/decidim/controller_helpers.rb +41 -0
  453. data/lib/decidim/core/engine.rb +35 -19
  454. data/lib/decidim/core/test/factories.rb +48 -8
  455. data/lib/decidim/core/test/shared_examples/admin_resource_gallery_examples.rb +16 -4
  456. data/lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb +1 -1
  457. data/lib/decidim/core/test/shared_examples/authorable_interface_examples.rb +15 -2
  458. data/lib/decidim/core/test/shared_examples/coauthorable_interface_examples.rb +2 -2
  459. data/lib/decidim/core/test/shared_examples/comments_examples.rb +203 -0
  460. data/lib/decidim/core/test/shared_examples/localised_email.rb +1 -1
  461. data/lib/decidim/core/test/shared_examples/logo_email.rb +1 -1
  462. data/lib/decidim/core/test/shared_examples/map_examples.rb +2 -2
  463. data/lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb +0 -6
  464. data/lib/decidim/core/test/shared_examples/resource_search_examples.rb +120 -40
  465. data/lib/decidim/core/test/shared_examples/resourceable.rb +0 -6
  466. data/lib/decidim/core/test/shared_examples/searchable_participatory_space_examples.rb +1 -1
  467. data/lib/decidim/core/test/shared_examples/searchable_resources_shared_context.rb +1 -1
  468. data/lib/decidim/core/test/shared_examples/system_endorse_resource_examples.rb +3 -3
  469. data/lib/decidim/core/test/shared_examples/translated_event_examples.rb +2 -2
  470. data/lib/decidim/core/test/shared_examples/with_endorsable_permissions_examples.rb +1 -1
  471. data/lib/decidim/core/test.rb +0 -3
  472. data/lib/decidim/core/version.rb +1 -1
  473. data/lib/decidim/core.rb +108 -14
  474. data/lib/decidim/{data_portability.rb → download_your_data.rb} +3 -3
  475. data/lib/decidim/{data_portability_serializers/data_portability_conversation_serializer.rb → download_your_data_serializers/download_your_data_conversation_serializer.rb} +2 -2
  476. data/lib/decidim/{data_portability_serializers/data_portability_follow_serializer.rb → download_your_data_serializers/download_your_data_follow_serializer.rb} +2 -2
  477. data/lib/decidim/{data_portability_serializers/data_portability_identity_serializer.rb → download_your_data_serializers/download_your_data_identity_serializer.rb} +2 -2
  478. data/lib/decidim/{data_portability_serializers/data_portability_notification_serializer.rb → download_your_data_serializers/download_your_data_notification_serializer.rb} +2 -2
  479. data/lib/decidim/{data_portability_serializers/data_portability_participatory_space_private_user_serializer.rb → download_your_data_serializers/download_your_data_participatory_space_private_user_serializer.rb} +2 -2
  480. data/lib/decidim/{data_portability_serializers/data_portability_report_serializer.rb → download_your_data_serializers/download_your_data_report_serializer.rb} +2 -2
  481. data/lib/decidim/{data_portability_serializers/data_portability_user_group_serializer.rb → download_your_data_serializers/download_your_data_user_group_serializer.rb} +2 -2
  482. data/lib/decidim/{data_portability_serializers/data_portability_user_serializer.rb → download_your_data_serializers/download_your_data_user_serializer.rb} +3 -3
  483. data/lib/decidim/download_your_data_serializers.rb +23 -0
  484. data/lib/decidim/engine_router.rb +7 -1
  485. data/lib/decidim/env.rb +56 -0
  486. data/lib/decidim/event_recorder.rb +25 -0
  487. data/lib/decidim/events/base_event.rb +10 -14
  488. data/lib/decidim/events/simple_event.rb +6 -5
  489. data/lib/decidim/exporters/export_data.rb +1 -1
  490. data/lib/decidim/exporters/export_manifest.rb +2 -1
  491. data/lib/decidim/file_validator_humanizer.rb +24 -1
  492. data/lib/decidim/filterable_resource.rb +55 -0
  493. data/lib/decidim/fingerprint_calculator.rb +2 -4
  494. data/lib/decidim/form_builder.rb +159 -138
  495. data/lib/decidim/gamification/badge.rb +2 -3
  496. data/lib/decidim/gamification/badge_scorer.rb +1 -0
  497. data/lib/decidim/has_area.rb +27 -0
  498. data/lib/decidim/has_attachments.rb +2 -2
  499. data/lib/decidim/has_category.rb +36 -0
  500. data/lib/decidim/has_resource_permission.rb +2 -0
  501. data/lib/decidim/importers/import_manifest.rb +3 -21
  502. data/lib/decidim/jsonb_attributes.rb +6 -4
  503. data/lib/decidim/manifest_messages.rb +23 -0
  504. data/lib/decidim/map/autocomplete.rb +6 -4
  505. data/lib/decidim/map/frontend.rb +2 -2
  506. data/lib/decidim/map/provider/dynamic_map/here.rb +1 -46
  507. data/lib/decidim/map/provider/geocoding/here.rb +5 -5
  508. data/lib/decidim/map/provider/here.rb +3 -0
  509. data/lib/decidim/map/provider/osm.rb +3 -0
  510. data/lib/decidim/map.rb +4 -4
  511. data/lib/decidim/menu.rb +1 -1
  512. data/lib/decidim/metric_manifest.rb +2 -2
  513. data/lib/decidim/nicknamizable.rb +1 -1
  514. data/lib/decidim/notification_setting_manifest.rb +19 -0
  515. data/lib/decidim/organization_settings.rb +8 -7
  516. data/lib/decidim/participatory_space_context_manifest.rb +2 -2
  517. data/lib/decidim/participatory_space_manifest.rb +2 -2
  518. data/lib/decidim/processes_file_locally.rb +31 -0
  519. data/lib/decidim/query.rb +84 -0
  520. data/lib/decidim/record_encryptor.rb +29 -8
  521. data/lib/decidim/reminder_manifest.rb +75 -0
  522. data/lib/decidim/reminder_registry.rb +67 -0
  523. data/lib/decidim/resource_manifest.rb +1 -1
  524. data/lib/decidim/resourceable.rb +15 -5
  525. data/lib/decidim/scopable.rb +15 -0
  526. data/lib/decidim/settings_manifest.rb +4 -4
  527. data/lib/decidim/spring.rb +16 -0
  528. data/lib/decidim/translatable_attributes.rb +13 -16
  529. data/lib/decidim/url_option_resolver.rb +50 -0
  530. data/lib/decidim/view_hooks.rb +1 -1
  531. data/lib/decidim/view_model.rb +5 -1
  532. data/lib/decidim/webpacker/thread_safe_compiler.rb +30 -0
  533. data/lib/decidim/webpacker/webpack/custom.js +15 -3
  534. data/lib/decidim/webpacker/webpacker.yml +1 -1
  535. data/lib/decidim/webpacker.rb +2 -0
  536. data/lib/devise/models/decidim_validatable.rb +1 -1
  537. data/lib/tasks/decidim_active_storage_migration_tasks.rake +1 -3
  538. data/lib/tasks/{decidim_data_portability_tasks.rake → decidim_download_your_data_tasks.rake} +9 -9
  539. data/lib/tasks/decidim_mailers_tasks.rake +23 -0
  540. data/lib/tasks/decidim_metrics_tasks.rake +1 -1
  541. data/lib/tasks/decidim_pwa_tasks.rake +18 -0
  542. data/lib/tasks/decidim_reminders_tasks.rake +17 -0
  543. data/lib/tasks/decidim_tasks.rake +6 -1
  544. data/lib/tasks/decidim_webpacker_tasks.rake +1 -1
  545. data/lib/tasks/upgrade/decidim_fix_nickname_uniqueness.rake +51 -0
  546. metadata +186 -91
  547. data/app/controllers/decidim/cookie_policy_controller.rb +0 -24
  548. data/app/helpers/decidim/cookies_helper.rb +0 -11
  549. data/app/packs/src/decidim/editor/clipboard_override.js +0 -143
  550. data/app/packs/src/decidim/editor/clipboard_utilities.js +0 -119
  551. data/app/packs/src/decidim/vizzs/renders.js +0 -9
  552. data/app/packs/src/decidim/vizzs.js +0 -1
  553. data/app/packs/stylesheets/decidim/modules/_cookie-bar.scss +0 -26
  554. data/app/services/decidim/home_activity_search.rb +0 -80
  555. data/app/services/decidim/participatory_space_search.rb +0 -54
  556. data/app/views/decidim/cookie_policy/accept.js.erb +0 -3
  557. data/app/views/decidim/export_mailer/data_portability_export.html.erb +0 -7
  558. data/config/locales/gn-PY.yml +0 -1
  559. data/config/locales/lo-LA.yml +0 -1
  560. data/config/locales/oc-FR.yml +0 -1
  561. data/lib/decidim/core/test/shared_examples/mcell_examples.rb +0 -17
  562. data/lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb +0 -60
  563. data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +0 -40
  564. data/lib/decidim/data_portability_serializers.rb +0 -23
  565. data/lib/decidim/middleware/rails_cookies.rb +0 -23
  566. /data/app/packs/src/decidim/vizzs/{metrics.js → index.js} +0 -0
  567. /data/app/views/decidim/application/{_document.html.erb → _document.erb} +0 -0
  568. /data/app/views/decidim/application/{_photos.html.erb → _photos.erb} +0 -0
  569. /data/app/views/decidim/{data_portability → download_your_data}/export.html.erb +0 -0
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This class acts as a registry for reminders. Each reminder needs a name,
5
+ # and a generator class, that will be used for generating the actual sendable reminders.
6
+ # Reminder times could be used to define intervals between reminders, so that user
7
+ # isn't reminded too often. In addition, you can register form and command classes
8
+ # for additional features, such as order reminders can be sent manually from the admin panel.
9
+ # Notice that if you implement admin panel functionality, you should add 118n messages too.
10
+ #
11
+ # In order to register a reminder, you can follow this example:
12
+ #
13
+ # Decidim.reminders_registry.register(:orders) do |reminder_registry|
14
+ # reminder_registry.generator_class_name = "Decidim::Budgets::OrderReminderGenerator"
15
+ # reminder_registry.form_class_name = "Decidim::Budgets::Admin::OrderReminderForm"
16
+ # reminder_registry.command_class_name = "Decidim::Budgets::Admin::CreateOrderReminders"
17
+ #
18
+ # reminder_registry.settings do |settings|
19
+ # settings.attribute :reminder_times, type: :array, default: [2.hours, 1.week, 2.weeks]
20
+ # end
21
+ #
22
+ # reminder_registry.messages do |msg|
23
+ # msg.set(:title) { |count: 0| I18n.t("decidim.budgets.admin.reminders.orders.title", count: count) }
24
+ # msg.set(:description) { I18n.t("decidim.budgets.admin.reminders.orders.description") }
25
+ # end
26
+ # end
27
+ #
28
+ # Reminders need to be registered in the `engine.rb` file of each module.
29
+ class ReminderRegistry
30
+ def register(reminder_name)
31
+ reminder_name = reminder_name.to_s
32
+ if reminder_exists?(reminder_name)
33
+ raise(
34
+ ReminderAlreadyRegistered,
35
+ "There's a reminder already registered with the name `:#{reminder_name}`, must be unique"
36
+ )
37
+ end
38
+
39
+ reminder_manifest = ::Decidim::ReminderManifest.new(name: reminder_name)
40
+ yield(reminder_manifest)
41
+ reminder_manifest.validate!
42
+
43
+ reminder_manifests << reminder_manifest
44
+ end
45
+
46
+ def for(reminder_name, list = nil)
47
+ list ||= all
48
+ list.find { |manifest| manifest.name == reminder_name.to_s }
49
+ end
50
+
51
+ def all
52
+ reminder_manifests
53
+ end
54
+
55
+ class ReminderAlreadyRegistered < StandardError; end
56
+
57
+ private
58
+
59
+ def reminder_exists?(reminder_name)
60
+ self.for(reminder_name).present?
61
+ end
62
+
63
+ def reminder_manifests
64
+ @reminder_manifests ||= []
65
+ end
66
+ end
67
+ end
@@ -15,7 +15,7 @@ module Decidim
15
15
  #
16
16
  class ResourceManifest
17
17
  include ActiveModel::Model
18
- include Virtus.model
18
+ include Decidim::AttributeObject::Model
19
19
 
20
20
  # The name of the resource we are exposing.
21
21
  attribute :name, String
@@ -18,6 +18,17 @@ module Decidim
18
18
  # An association with the permissions settings for the resource
19
19
  has_one :resource_permission, as: :resource, class_name: "Decidim::ResourcePermission"
20
20
 
21
+ scope :related_to, lambda { |related_to_key|
22
+ from = joins(:resource_links_from).where(
23
+ decidim_resource_links: { to_type: related_to_key.camelcase }
24
+ )
25
+ to = joins(:resource_links_to).where(
26
+ decidim_resource_links: { from_type: related_to_key.camelcase }
27
+ )
28
+
29
+ where(id: from).or(where(id: to))
30
+ }
31
+
21
32
  # Finds all the linked resources to or from this model for a given resource
22
33
  # name and link name.
23
34
  #
@@ -25,8 +36,8 @@ module Decidim
25
36
  # link_name - The String name of the link between this model and the target resource.
26
37
  #
27
38
  # Returns an ActiveRecord::Relation.
28
- def linked_resources(resource_name, link_name, component_published: true)
29
- scope = sibling_scope(resource_name, component_published: component_published)
39
+ def linked_resources(resource_name, link_name)
40
+ scope = sibling_scope(resource_name)
30
41
 
31
42
  from = scope
32
43
  .joins(:resource_links_from)
@@ -45,15 +56,14 @@ module Decidim
45
56
  # resource_name - The String name of the resource manifest exposed by a component.
46
57
  #
47
58
  # Returns an ActiveRecord::Relation.
48
- def sibling_scope(resource_name, component_published: true)
59
+ def sibling_scope(resource_name)
49
60
  manifest = Decidim.find_resource_manifest(resource_name)
50
61
  return self.class.none unless manifest
51
62
 
52
63
  scope = manifest.resource_scope(component)
53
64
  scope = scope.where("#{self.class.table_name}.id != ?", id) if manifest.model_class == self.class
54
65
  scope = scope.not_hidden if manifest.model_class.respond_to?(:not_hidden)
55
- scope = scope.includes(:component).where.not(decidim_components: { published_at: nil }) if component_published
56
- scope
66
+ scope.includes(:component).where.not(decidim_components: { published_at: nil })
57
67
  end
58
68
 
59
69
  # Links the given resources to this model, replaces any previous links with the same name.
@@ -26,6 +26,21 @@ module Decidim
26
26
  delegate :scopes, to: :organization
27
27
 
28
28
  validate :scope_belongs_to_organization
29
+
30
+ scope :with_scope, ->(scope_id) { includes(:scope).references(:decidim_scopes).where("? = ANY(decidim_scopes.part_of)", scope_id) }
31
+
32
+ scope :with_any_scope, lambda { |*original_scope_ids|
33
+ scope_ids = original_scope_ids.flatten
34
+ return self if scope_ids.include?("all")
35
+
36
+ clean_scope_ids = scope_ids
37
+
38
+ conditions = []
39
+ conditions << "#{table_name}.decidim_scope_id IS NULL" if clean_scope_ids.delete("global")
40
+ conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any?
41
+
42
+ includes(:scope).references(:decidim_scopes).where(Arel.sql(conditions.join(" OR ")).to_s, *clean_scope_ids.map(&:to_i))
43
+ }
29
44
  end
30
45
 
31
46
  # Whether the resource has scopes enabled or not.
@@ -38,14 +38,14 @@ module Decidim
38
38
  manifest = self
39
39
 
40
40
  @schema = Class.new do
41
- include Virtus.model
41
+ include Decidim::AttributeObject::Model
42
42
  include ActiveModel::Validations
43
43
  include TranslatableAttributes
44
44
 
45
45
  cattr_accessor :manifest
46
46
  attr_reader :default_locale
47
47
 
48
- # Overwrites Virtus::InstanceMethods::Constructor#initialize to allow
48
+ # Overwrites Decidim::AttributeObject::Model#initialize to allow
49
49
  # passing a default_locale needed to validate translatable attributes.
50
50
  # See TranslatablePresenceValidator#default_locale_for(record).
51
51
  def initialize(attributes = nil, default_locale = nil)
@@ -85,7 +85,7 @@ module Decidim
85
85
  # to encapsulate behavior related to each individual settings field. Shouldn't
86
86
  # be used from the outside.
87
87
  class Attribute
88
- include Virtus.model
88
+ include Decidim::AttributeObject::Model
89
89
  include ActiveModel::Validations
90
90
 
91
91
  TYPES = {
@@ -97,7 +97,7 @@ module Decidim
97
97
  enum: { klass: String, default: nil },
98
98
  select: { klass: String, default: nil },
99
99
  scope: { klass: Integer, default: nil },
100
- time: { klass: Decidim::Attributes::TimeWithZone, default: nil }
100
+ time: { klass: DateTime, default: nil }
101
101
  }.freeze
102
102
 
103
103
  attribute :type, Symbol, default: :boolean
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # A special Spring watcher for Decidim to ignore specific paths from the
5
+ # watching causing excessive use of inodes, issues with CPU usage and with
6
+ # startup/stop. This should be loaded at the application's config/spring.rb
7
+ # file.
8
+ module SpringWatcher
9
+ def start
10
+ super
11
+ listener.ignore(/^(node_modules|storage|tmp)/)
12
+ end
13
+ end
14
+ end
15
+
16
+ Spring::Watcher::Listen.prepend Decidim::SpringWatcher
@@ -4,13 +4,13 @@ require "active_support/concern"
4
4
 
5
5
  module Decidim
6
6
  # A set of convenience methods to deal with I18n attributes and validations
7
- # in a way that's compatible with Virtus and ActiveModel, thus making it easy
8
- # to integrate into Rails' forms and similar workflows.
7
+ # in a way that's compatible with AttributeObject and ActiveModel, thus making
8
+ # it easy to integrate into Rails' forms and similar workflows.
9
9
  module TranslatableAttributes
10
10
  extend ActiveSupport::Concern
11
11
 
12
12
  class_methods do
13
- # Public: Mirrors Virtus' `attribute` interface to define attributes in
13
+ # Public: Mirrors the `attribute` interface to define attributes in
14
14
  # multiple locales.
15
15
  #
16
16
  # name - The attribute's name
@@ -34,29 +34,26 @@ module Decidim
34
34
  # end
35
35
  #
36
36
  # Returns nothing.
37
- def translatable_attribute(name, type, *options)
38
- attribute name, Hash, default: {}
37
+ def translatable_attribute(name, type, **options)
38
+ attribute(name, { String => Object }, default: {})
39
39
 
40
40
  locales.each do |locale|
41
41
  attribute_name = "#{name}_#{locale}".gsub("-", "__")
42
- attribute attribute_name, type, *options
42
+ attribute attribute_name, type, **options
43
43
 
44
44
  define_method attribute_name do
45
45
  field = public_send(name) || {}
46
- value =
47
- if field.is_a?(Hash)
48
- field[locale.to_s] || field[locale.to_sym]
49
- else
50
- # The value may not be a hash in case the attribute type was
51
- # changed and the old value is still stored against the record.
52
- field
53
- end
54
- attribute_set[attribute_name].coerce(value)
46
+ value = field[locale.to_s] || field[locale.to_sym]
47
+ value_type = self.class.attribute_types[attribute_name.to_s]
48
+ value_type ? value_type.cast(value) : value
55
49
  end
56
50
 
57
51
  define_method "#{attribute_name}=" do |value|
58
52
  field = public_send(name) || {}
59
- public_send("#{name}=", field.merge(locale => super(value)))
53
+ final = super(value)
54
+ return unless final # Do not set the `nil` values for the parent hash
55
+
56
+ public_send("#{name}=", field.merge(locale => final))
60
57
  end
61
58
 
62
59
  yield(attribute_name, locale) if block_given?
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # A class for resolving the default URL options.
5
+ class UrlOptionResolver
6
+ def options
7
+ {}.tap do |opts|
8
+ opts[:host] = host if host
9
+ opts[:port] = port unless default_port?
10
+ opts[:protocol] = protocol if protocol == "https"
11
+ end
12
+ end
13
+
14
+ def protocol
15
+ return "https" if Rails.application.config.force_ssl || port == 443
16
+
17
+ "http"
18
+ end
19
+
20
+ def host
21
+ @host ||= begin
22
+ default_host = nil
23
+ default_host = "localhost" if Rails.env.development? || Rails.env.test?
24
+
25
+ ENV.fetch("HOSTNAME", default_host)
26
+ end
27
+ end
28
+
29
+ def port
30
+ @port ||= begin
31
+ default_port =
32
+ if Rails.env.development?
33
+ 3000
34
+ elsif Rails.env.test?
35
+ Capybara.server_port
36
+ elsif Rails.application.config.force_ssl
37
+ 443
38
+ else
39
+ 80
40
+ end
41
+
42
+ ENV.fetch("PORT", default_port).to_i
43
+ end
44
+ end
45
+
46
+ def default_port?
47
+ [443, 80].include?(port)
48
+ end
49
+ end
50
+ end
@@ -77,7 +77,7 @@ module Decidim
77
77
  def render(name, view_context)
78
78
  hooks[name].map do |hook|
79
79
  hook.render(view_context)
80
- end.join("").html_safe
80
+ end.join.html_safe
81
81
  end
82
82
 
83
83
  private
@@ -19,7 +19,7 @@ module Decidim
19
19
 
20
20
  delegate :current_organization, to: :controller
21
21
 
22
- cache :show, if: :perform_caching? do
22
+ cache :show, if: :perform_caching?, expires_in: :cache_expiry_time do
23
23
  cache_hash
24
24
  end
25
25
 
@@ -60,6 +60,10 @@ module Decidim
60
60
  nil
61
61
  end
62
62
 
63
+ def cache_expiry_time
64
+ nil
65
+ end
66
+
63
67
  def decidim
64
68
  Decidim::Core::Engine.routes.url_helpers
65
69
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This fixes a thread safety issue with the Webpacker compiler explained here:
4
+ # https://github.com/rails/webpacker/issues/2801
5
+ #
6
+ # The fix is partly from the issue and partly from this commit at Shakapacker:
7
+ # https://github.com/shakacode/shakapacker/commit/f2dc437ecd9914f394780d4c3150fc4a70d40f9d
8
+
9
+ require "webpacker/compiler"
10
+
11
+ module Decidim
12
+ module Webpacker
13
+ module ThreadSafeCompiler
14
+ private
15
+
16
+ def watched_files_digest
17
+ warn "Webpacker::Compiler.watched_paths has been deprecated. Set additional_paths in webpacker.yml instead." unless watched_paths.empty?
18
+ root_path = Pathname.new(File.expand_path(config.root_path))
19
+ expanded_paths = [*default_watched_paths, *watched_paths].map do |path|
20
+ root_path.join(path)
21
+ end
22
+ files = Dir[*expanded_paths].reject { |f| File.directory?(f) }
23
+ file_ids = files.sort.map { |f| "#{File.basename(f)}/#{Digest::SHA1.file(f).hexdigest}" }
24
+ Digest::SHA1.hexdigest(file_ids.join("/"))
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ Webpacker::Compiler.prepend(Decidim::Webpacker::ThreadSafeCompiler)
@@ -1,7 +1,6 @@
1
1
  /* eslint-disable */
2
-
3
- const path = require("path");
4
2
  const { config } = require("@rails/webpacker");
3
+ const { InjectManifest } = require("workbox-webpack-plugin");
5
4
 
6
5
  module.exports = {
7
6
  module: {
@@ -93,5 +92,18 @@ module.exports = {
93
92
  optimization: {
94
93
  runtimeChunk: false
95
94
  },
96
- entry: config.entrypoints
95
+ entry: config.entrypoints,
96
+ plugins: [
97
+ new InjectManifest({
98
+ swSrc: "src/decidim/sw/sw.js",
99
+
100
+ /**
101
+ * NOTE:
102
+ * @rails/webpacker outputs to '/packs',
103
+ * in order to make the SW run properly
104
+ * they must be put at the project's root folder '/'
105
+ */
106
+ swDest: "../sw.js"
107
+ })
108
+ ]
97
109
  }
@@ -33,7 +33,7 @@ development:
33
33
  hmr: false
34
34
  client:
35
35
  # Should we show a full-screen overlay in the browser when there are compiler errors or warnings?
36
- overlay: true
36
+ overlay: false
37
37
  # May also be a string
38
38
  # webSocketURL:
39
39
  # hostname: "0.0.0.0"
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "decidim/webpacker/thread_safe_compiler"
4
+
3
5
  module Decidim
4
6
  module Webpacker
5
7
  autoload :Configuration, "decidim/webpacker/configuration"
@@ -37,7 +37,7 @@ module Devise
37
37
  end
38
38
  end
39
39
 
40
- def self.assert_validations_api!(base) #:nodoc:
40
+ def self.assert_validations_api!(base) # :nodoc:
41
41
  unavailable_validations = VALIDATIONS.reject { |v| base.respond_to?(v) }
42
42
 
43
43
  unless unavailable_validations.empty?
@@ -21,9 +21,7 @@ namespace :decidim do
21
21
  path = Rails.root.join("tmp/attachment_mappings.csv")
22
22
  dirname = File.dirname(path)
23
23
  FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
24
- File.open(path, "wb") do |file|
25
- file.write(Decidim::Exporters::CSV.new(routes_mappings).export.read)
26
- end
24
+ File.binwrite(path, Decidim::Exporters::CSV.new(routes_mappings).export.read)
27
25
  end
28
26
 
29
27
  desc "Checks attachments migrated from Carrierwave to ActiveStorage"
@@ -55,7 +55,7 @@ namespace :decidim do
55
55
  end
56
56
  end
57
57
 
58
- desc "Check and notify users to update her newsletter notifications settings"
58
+ desc "Check and notify users to update their newsletter notifications settings"
59
59
  task check_users_newsletter_opt_in: :environment do
60
60
  print %(
61
61
  > This will send an email to all the users that have marked the newsletter by default. This should only be run if you were using Decidim before v0.11
@@ -70,22 +70,22 @@ namespace :decidim do
70
70
  end
71
71
  end
72
72
 
73
- desc "Deletes all data portability files previous to `Decidim.data_portability_expiry_time` from now."
74
- task delete_data_portability_files: :environment do
75
- puts "DELETE DATA PORTABILITY FILES: -------------- START"
73
+ desc "Deletes all download your data files previous to `Decidim.download_your_data_expiry_time` from now."
74
+ task delete_download_your_data_files: :environment do
75
+ puts "DELETE DOWNLOAD YOUR DATA FILES: -------------- START"
76
76
  attachments = ActiveStorage::Attachment.joins(:blob).where(
77
- name: "data_portability_file",
77
+ name: "download_your_data_file",
78
78
  record_type: "Decidim::UserBaseEntity"
79
79
  ).where(
80
- "active_storage_blobs.created_at < ?", Decidim.data_portability_expiry_time.ago
80
+ "active_storage_blobs.created_at < ?", Decidim.download_your_data_expiry_time.ago
81
81
  )
82
82
  attachments.each do |attachment|
83
- delete_data_portability_file attachment
83
+ delete_download_your_data_file attachment
84
84
  end
85
- puts "DELETE DATA PORTABILITY FILES: --------------- END"
85
+ puts "DELETE DOWNLOAD YOUR DATA FILES: --------------- END"
86
86
  end
87
87
 
88
- def delete_data_portability_file(attachment)
88
+ def delete_download_your_data_file(attachment)
89
89
  puts "------"
90
90
  puts "!! deleting: #{attachment.filename}"
91
91
  attachment.purge
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :decidim do
4
+ namespace :mailers do
5
+ desc "Task to send the notification digest email with the daily report"
6
+ task notifications_digest_daily: :environment do
7
+ notifications_digest(:daily)
8
+ end
9
+
10
+ desc "Task to send the notification digest email with the weekly report"
11
+ task notifications_digest_weekly: :environment do
12
+ notifications_digest(:weekly)
13
+ end
14
+ end
15
+
16
+ def notifications_digest(frequency)
17
+ target_users = Decidim::User.where(notifications_sending_frequency: frequency)
18
+ time = Time.now.utc
19
+ target_users.find_each do |user|
20
+ Decidim::EmailNotificationsDigestGeneratorJob.perform_later(user.id, frequency, time: time)
21
+ end
22
+ end
23
+ end
@@ -4,7 +4,7 @@ namespace :decidim do
4
4
  namespace :metrics do
5
5
  # All ------
6
6
  #
7
- # Get all metrics entities and execute his own rake task.
7
+ # Get all metrics entities and execute its own rake task.
8
8
  # It admits a date-string parameter, in a 'YYYY-MM-DD' format from
9
9
  # today to all past dates
10
10
  desc "Execute all metrics calculation methods"
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "webpush"
4
+
5
+ namespace :decidim do
6
+ namespace :pwa do
7
+ desc "Generates VAPID keys for push notifications"
8
+ task :generate_vapid_keys do
9
+ vapid_key = Webpush.generate_key
10
+
11
+ puts("VAPID keys correctly generated.")
12
+ puts("*******************************")
13
+ puts("You have to set the following env vars:\n\n")
14
+ puts("VAPID_PUBLIC_KEY=#{vapid_key.public_key}")
15
+ puts("VAPID_PRIVATE_KEY=#{vapid_key.private_key}")
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :decidim do
4
+ namespace :reminders do
5
+ task :all, [] => :environment do
6
+ Decidim.reminders_registry.all.each do |reminder_manifest|
7
+ call_reminder_job(reminder_manifest)
8
+ end
9
+ end
10
+ end
11
+
12
+ def call_reminder_job(reminder_manifest)
13
+ Decidim::ReminderGeneratorJob.perform_later(
14
+ reminder_manifest.generator_class_name
15
+ )
16
+ end
17
+ end
@@ -2,7 +2,12 @@
2
2
 
3
3
  namespace :decidim do
4
4
  desc "Install migrations from Decidim to the app."
5
- task upgrade: [:choose_target_plugins, :"railties:install:migrations", :"decidim:webpacker:upgrade"]
5
+ task upgrade: [
6
+ :choose_target_plugins,
7
+ :"railties:install:migrations",
8
+ :"decidim:webpacker:upgrade",
9
+ :"decidim_api:generate_docs"
10
+ ]
6
11
 
7
12
  desc "Setup environment so that only decidim migrations are installed."
8
13
  task :choose_target_plugins do
@@ -89,7 +89,7 @@ namespace :decidim do
89
89
  gem_path = Pathname(decidim_gemspec.full_gem_path)
90
90
  else
91
91
  gem_path = decidim_gemspec.source.path
92
- gem_path = Pathname(ENV["BUNDLE_GEMFILE"]).dirname.join(gem_path) if gem_path.relative?
92
+ gem_path = Pathname(ENV.fetch("BUNDLE_GEMFILE", nil)).dirname.join(gem_path) if gem_path.relative?
93
93
  end
94
94
 
95
95
  gem_path
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :decidim do
4
+ namespace :upgrade do
5
+ desc "Modify nicknames with random numbers when exists similar ones case insensitively"
6
+ task fix_nickname_uniqueness: :environment do
7
+ logger = Logger.new($stdout)
8
+ logger.info("Updating conflicting user nicknames...")
9
+
10
+ # list of users already changed in the process
11
+ has_changed = []
12
+
13
+ Decidim::User.not_deleted.find_each do |user|
14
+ next if has_changed.include? user.id
15
+
16
+ Decidim::User.where(organization: user.organization)
17
+ .where("nickname ILIKE ?", user.nickname.downcase)
18
+ .where.not(id: has_changed + [user.id])
19
+ .not_deleted
20
+ .order(:created_at)
21
+ .each do |similar_user|
22
+ # change her nickname to the lowercased one with numbers if needed
23
+ begin
24
+ update_user_nickname(similar_user, Decidim::UserBaseEntity.nicknamize(similar_user.nickname, organization: similar_user.organization))
25
+ rescue ActiveRecord::RecordInvalid => e
26
+ logger.warn("User ID (#{similar_user.id}) : #{e}")
27
+ end
28
+ has_changed.append(similar_user.id)
29
+ end
30
+ end
31
+ logger.info("Process terminated, #{has_changed.count} users nickname have been updated.")
32
+ end
33
+
34
+ private
35
+
36
+ def send_notification_to(user)
37
+ Decidim::EventsManager.publish(
38
+ event: "decidim.events.nickname_event",
39
+ event_class: Decidim::ChangeNicknameEvent,
40
+ affected_users: [user],
41
+ resource: user
42
+ )
43
+ end
44
+
45
+ def update_user_nickname(user, new_nickname)
46
+ user.update!(nickname: new_nickname)
47
+ send_notification_to(user)
48
+ user
49
+ end
50
+ end
51
+ end