decidim-core 0.26.2 → 0.27.0.rc2

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 (554) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/cells/decidim/amendable/announcement_cell.rb +3 -8
  4. data/app/cells/decidim/announcement_cell.rb +2 -2
  5. data/app/cells/decidim/author_cell.rb +1 -1
  6. data/app/cells/decidim/content_blocks/cta/show.erb +1 -1
  7. data/app/cells/decidim/content_blocks/cta_cell.rb +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 +2 -2
  10. data/app/cells/decidim/content_blocks/hero_cell.rb +1 -0
  11. data/app/cells/decidim/content_blocks/highlighted_content_banner/show.erb +5 -5
  12. data/app/cells/decidim/content_blocks/highlighted_elements_cell.rb +1 -1
  13. data/app/cells/decidim/content_blocks/how_to_participate/show.erb +1 -1
  14. data/app/cells/decidim/content_blocks/last_activity/show.erb +1 -1
  15. data/app/cells/decidim/content_blocks/last_activity_cell.rb +3 -3
  16. data/app/cells/decidim/content_blocks/stats_cell.rb +5 -4
  17. data/app/cells/decidim/content_blocks/sub_hero/show.erb +1 -1
  18. data/app/cells/decidim/content_blocks/sub_hero_cell.rb +1 -1
  19. data/app/cells/decidim/data_consent/category.erb +64 -0
  20. data/app/cells/decidim/data_consent/dialog.erb +29 -0
  21. data/app/cells/decidim/data_consent/modal.erb +39 -0
  22. data/app/cells/decidim/data_consent/show.erb +3 -0
  23. data/app/cells/decidim/data_consent_cell.rb +21 -0
  24. data/app/cells/decidim/follow_button_cell.rb +5 -7
  25. data/app/cells/decidim/profile_sidebar_cell.rb +1 -1
  26. data/app/cells/decidim/search_results_cell.rb +1 -1
  27. data/app/cells/decidim/tos_page/refuse_btn_modal.erb +1 -1
  28. data/app/cells/decidim/upload_modal/files.erb +52 -0
  29. data/app/cells/decidim/upload_modal/modal.erb +49 -0
  30. data/app/cells/decidim/upload_modal/show.erb +3 -0
  31. data/app/cells/decidim/upload_modal_cell.rb +205 -0
  32. data/app/cells/decidim/user_conversation/reply.erb +1 -1
  33. data/app/cells/decidim/user_conversations/add_conversation_users.erb +5 -3
  34. data/app/cells/decidim/version_cell.rb +2 -13
  35. data/app/cells/decidim/versions_list_cell.rb +2 -13
  36. data/app/cells/decidim/versions_list_item_cell.rb +2 -13
  37. data/app/commands/decidim/accept_group_invitation.rb +1 -1
  38. data/app/commands/decidim/accept_user_group_join_request.rb +1 -1
  39. data/app/commands/decidim/amendable/accept.rb +1 -1
  40. data/app/commands/decidim/amendable/create_draft.rb +1 -1
  41. data/app/commands/decidim/amendable/destroy_draft.rb +1 -1
  42. data/app/commands/decidim/amendable/promote.rb +1 -1
  43. data/app/commands/decidim/amendable/publish_draft.rb +1 -1
  44. data/app/commands/decidim/amendable/reject.rb +1 -1
  45. data/app/commands/decidim/amendable/update_draft.rb +1 -1
  46. data/app/commands/decidim/amendable/withdraw.rb +1 -1
  47. data/app/commands/decidim/attachment_methods.rb +3 -2
  48. data/app/commands/decidim/create_editor_image.rb +1 -1
  49. data/app/commands/decidim/create_follow.rb +1 -1
  50. data/app/commands/decidim/create_omniauth_registration.rb +2 -3
  51. data/app/commands/decidim/create_registration.rb +1 -2
  52. data/app/commands/decidim/create_report.rb +1 -1
  53. data/app/commands/decidim/create_user_group.rb +2 -2
  54. data/app/commands/decidim/create_user_report.rb +5 -3
  55. data/app/commands/decidim/delete_follow.rb +1 -1
  56. data/app/commands/decidim/demote_membership.rb +1 -1
  57. data/app/commands/decidim/destroy_account.rb +1 -1
  58. data/app/commands/decidim/endorse_resource.rb +1 -1
  59. data/app/commands/decidim/gallery_methods.rb +45 -10
  60. data/app/commands/decidim/invite_user.rb +1 -3
  61. data/app/commands/decidim/invite_user_again.rb +1 -1
  62. data/app/commands/decidim/invite_user_to_group.rb +1 -1
  63. data/app/commands/decidim/join_user_group.rb +1 -1
  64. data/app/commands/decidim/leave_user_group.rb +8 -2
  65. data/app/commands/decidim/messaging/reply_to_conversation.rb +2 -2
  66. data/app/commands/decidim/messaging/start_conversation.rb +2 -2
  67. data/app/commands/decidim/multiple_attachments_methods.rb +44 -5
  68. data/app/commands/decidim/promote_membership.rb +1 -1
  69. data/app/commands/decidim/reject_group_invitation.rb +1 -1
  70. data/app/commands/decidim/reject_user_group_join_request.rb +1 -1
  71. data/app/commands/decidim/remove_user_from_group.rb +1 -1
  72. data/app/commands/decidim/resend_confirmation_instructions.rb +18 -0
  73. data/app/commands/decidim/search.rb +10 -9
  74. data/app/commands/decidim/unendorse_resource.rb +1 -1
  75. data/app/commands/decidim/unsubscribe_settings.rb +1 -1
  76. data/app/commands/decidim/update_account.rb +5 -3
  77. data/app/commands/decidim/update_notifications_settings.rb +3 -2
  78. data/app/commands/decidim/update_password.rb +31 -0
  79. data/app/commands/decidim/update_user_group.rb +2 -2
  80. data/app/commands/decidim/update_user_interests.rb +1 -1
  81. data/app/commands/decidim/validate_upload.rb +15 -0
  82. data/app/controllers/concerns/decidim/devise_controllers.rb +0 -1
  83. data/app/controllers/concerns/decidim/filter_resource.rb +23 -24
  84. data/app/controllers/concerns/decidim/force_authentication.rb +1 -2
  85. data/app/controllers/concerns/decidim/http_caching_disabler.rb +1 -1
  86. data/app/controllers/concerns/decidim/needs_password_change.rb +43 -0
  87. data/app/controllers/concerns/decidim/needs_tos_accepted.rb +3 -3
  88. data/app/controllers/concerns/decidim/orderable.rb +1 -1
  89. data/app/controllers/concerns/decidim/participatory_space_context.rb +2 -2
  90. data/app/controllers/concerns/decidim/resource_versions_concern.rb +4 -0
  91. data/app/controllers/decidim/account_controller.rb +45 -0
  92. data/app/controllers/decidim/application_controller.rb +1 -1
  93. data/app/controllers/decidim/devise/invitations_controller.rb +2 -0
  94. data/app/controllers/decidim/devise/passwords_controller.rb +33 -0
  95. data/app/controllers/decidim/devise/registrations_controller.rb +7 -1
  96. data/app/controllers/decidim/devise/sessions_controller.rb +2 -0
  97. data/app/controllers/decidim/{data_portability_controller.rb → download_your_data_controller.rb} +8 -8
  98. data/app/controllers/decidim/groups_controller.rb +5 -0
  99. data/app/controllers/decidim/last_activities_controller.rb +8 -9
  100. data/app/controllers/decidim/manifests_controller.rb +11 -0
  101. data/app/controllers/decidim/newsletters_controller.rb +1 -1
  102. data/app/controllers/decidim/notifications_subscriptions_controller.rb +16 -0
  103. data/app/controllers/decidim/offline_controller.rb +7 -0
  104. data/app/controllers/decidim/profiles_controller.rb +1 -1
  105. data/app/controllers/decidim/searches_controller.rb +4 -3
  106. data/app/controllers/decidim/short_links_controller.rb +35 -0
  107. data/app/controllers/decidim/upload_validations_controller.rb +44 -0
  108. data/app/controllers/decidim/user_activities_controller.rb +32 -16
  109. data/app/controllers/decidim/user_interests_controller.rb +0 -2
  110. data/app/controllers/decidim/user_timeline_controller.rb +6 -8
  111. data/app/events/decidim/change_nickname_event.rb +21 -0
  112. data/app/events/decidim/resource_endorsed_event.rb +2 -1
  113. data/app/forms/decidim/account_form.rb +8 -7
  114. data/app/forms/decidim/form.rb +1 -1
  115. data/app/forms/decidim/messaging/conversation_form.rb +1 -1
  116. data/app/forms/decidim/notifications_settings_form.rb +8 -2
  117. data/app/forms/decidim/password_form.rb +10 -0
  118. data/app/forms/decidim/registration_form.rb +10 -4
  119. data/app/forms/decidim/upload_validation_form.rb +54 -0
  120. data/app/forms/decidim/user_group_form.rb +2 -2
  121. data/app/forms/decidim/user_interest_scope_form.rb +1 -1
  122. data/app/forms/decidim/user_interests_form.rb +1 -1
  123. data/app/forms/translatable_presence_validator.rb +2 -2
  124. data/app/forms/url_validator.rb +1 -1
  125. data/app/helpers/decidim/application_helper.rb +2 -2
  126. data/app/helpers/decidim/attachments_helper.rb +1 -1
  127. data/app/helpers/decidim/cells_paginate_helper.rb +1 -1
  128. data/app/helpers/decidim/datalist_select_helper.rb +40 -0
  129. data/app/helpers/decidim/decidim_form_helper.rb +1 -1
  130. data/app/helpers/decidim/filters_helper.rb +5 -1
  131. data/app/helpers/decidim/followable_helper.rb +1 -1
  132. data/app/helpers/decidim/icon_helper.rb +1 -1
  133. data/app/helpers/decidim/layout_helper.rb +15 -1
  134. data/app/helpers/decidim/map_helper.rb +12 -8
  135. data/app/helpers/decidim/meta_tags_helper.rb +0 -2
  136. data/app/helpers/decidim/notifications_settings_helper.rb +15 -0
  137. data/app/helpers/decidim/passwords_helper.rb +41 -0
  138. data/app/helpers/decidim/sanitize_helper.rb +12 -2
  139. data/app/helpers/decidim/searches_helper.rb +6 -6
  140. data/app/helpers/decidim/short_link_helper.rb +28 -0
  141. data/app/helpers/decidim/translations_helper.rb +2 -2
  142. data/app/jobs/decidim/{data_portability_export_job.rb → download_your_data_export_job.rb} +5 -5
  143. data/app/jobs/decidim/email_notifications_digest_generator_job.rb +21 -0
  144. data/app/jobs/decidim/notification_generator_for_recipient_job.rb +5 -3
  145. data/app/jobs/decidim/reminder_generator_job.rb +12 -0
  146. data/app/jobs/decidim/resend_confirmation_instructions_job.rb +11 -0
  147. data/app/jobs/decidim/user_report_job.rb +2 -2
  148. data/app/mailers/concerns/decidim/multitenant_asset_host.rb +11 -3
  149. data/app/mailers/decidim/application_mailer.rb +1 -1
  150. data/app/mailers/decidim/block_user_mailer.rb +8 -7
  151. data/app/mailers/decidim/export_mailer.rb +2 -2
  152. data/app/mailers/decidim/newsletter_mailer.rb +2 -2
  153. data/app/mailers/decidim/newsletters_opt_in_mailer.rb +7 -5
  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 +14 -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 +2 -1
  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/src/decidim/account_form.js +68 -18
  193. data/app/packs/src/decidim/autocomplete.js +298 -0
  194. data/app/packs/src/decidim/data_consent/consent_manager.js +136 -0
  195. data/app/packs/src/decidim/data_consent/consent_manager.test.js +280 -0
  196. data/app/packs/src/decidim/data_consent/index.js +103 -0
  197. data/app/packs/src/decidim/datalist_select.js +36 -0
  198. data/app/packs/src/decidim/direct_uploads/upload_field.js +117 -0
  199. data/app/packs/src/decidim/direct_uploads/upload_modal.js +264 -0
  200. data/app/packs/src/decidim/direct_uploads/upload_utility.js +49 -0
  201. data/app/packs/src/decidim/direct_uploads/uploader.js +89 -0
  202. data/app/packs/src/decidim/external_domain_warning.js +1 -1
  203. data/app/packs/src/decidim/external_link.js +14 -3
  204. data/app/packs/src/decidim/external_link.test.js +64 -0
  205. data/app/packs/src/decidim/geocoding.js +10 -35
  206. data/app/packs/src/decidim/identity_selector_dialog.js +1 -1
  207. data/app/packs/src/decidim/impersonation.js +3 -3
  208. data/app/packs/src/decidim/input_character_counter.js +215 -22
  209. data/app/packs/src/decidim/input_multiple_mentions.js +87 -187
  210. data/app/packs/src/decidim/map/factory.js +3 -1
  211. data/app/packs/src/decidim/map/icon.js +2 -1
  212. data/app/packs/src/decidim/map/legacy.js +2 -2
  213. data/app/packs/src/decidim/map/svg-icon.js +248 -0
  214. data/app/packs/src/decidim/map.js +2 -2
  215. data/app/packs/src/decidim/security/selfxss_warning.js +5 -1
  216. data/app/packs/src/decidim/session_timeouter.js +15 -15
  217. data/app/packs/src/decidim/sw/a2hs.js +37 -0
  218. data/app/packs/src/decidim/sw/index.js +3 -0
  219. data/app/packs/src/decidim/sw/loader.js +18 -0
  220. data/app/packs/src/decidim/sw/push-permissions.js +87 -0
  221. data/app/packs/src/decidim/sw/sw.js +80 -0
  222. data/app/packs/src/decidim/vizzs/areachart.js +33 -28
  223. data/app/packs/src/decidim/vizzs/{metrics.js → index.js} +0 -0
  224. data/app/packs/src/decidim/vizzs/linechart.js +23 -18
  225. data/app/packs/src/decidim/vizzs/rowchart.js +15 -11
  226. data/app/packs/stylesheets/decidim/email.scss +66 -0
  227. data/app/packs/stylesheets/decidim/layouts/_user.scss +8 -0
  228. data/app/packs/stylesheets/decidim/modules/_autocomplete.scss +99 -0
  229. data/app/packs/stylesheets/decidim/modules/_cards.scss +2 -0
  230. data/app/packs/stylesheets/decidim/modules/_comments.scss +2 -0
  231. data/app/packs/stylesheets/decidim/modules/_data-consent.scss +115 -0
  232. data/app/packs/stylesheets/decidim/modules/_footer.scss +4 -0
  233. data/app/packs/stylesheets/decidim/modules/_forms.scss +5 -0
  234. data/app/packs/stylesheets/decidim/modules/_input-multiple-mentions.scss +29 -2
  235. data/app/packs/stylesheets/decidim/modules/_modules.scss +3 -1
  236. data/app/packs/stylesheets/decidim/modules/_reveal.scss +15 -0
  237. data/app/packs/stylesheets/decidim/modules/_upload_modal.scss +143 -0
  238. data/app/packs/stylesheets/decidim/utils/_fontface.scss +3 -0
  239. data/app/permissions/decidim/permissions.rb +6 -6
  240. data/app/presenters/decidim/admin_log/area_type_presenter.rb +34 -0
  241. data/app/presenters/decidim/admin_log/attachment_collection_presenter.rb +35 -0
  242. data/app/presenters/decidim/admin_log/attachment_presenter.rb +27 -0
  243. data/app/presenters/decidim/admin_log/category_presenter.rb +36 -0
  244. data/app/presenters/decidim/admin_log/component_presenter.rb +35 -3
  245. data/app/presenters/decidim/admin_log/contextual_help_section_presenter.rb +33 -0
  246. data/app/presenters/decidim/admin_log/organization_presenter.rb +9 -4
  247. data/app/presenters/decidim/admin_log/scope_type_presenter.rb +34 -0
  248. data/app/presenters/decidim/home_stats_presenter.rb +4 -2
  249. data/app/presenters/decidim/log/base_presenter.rb +1 -1
  250. data/app/presenters/decidim/menu_item_presenter.rb +1 -1
  251. data/app/presenters/decidim/metric_charts_presenter.rb +7 -1
  252. data/app/presenters/decidim/nil_presenter.rb +3 -1
  253. data/app/presenters/decidim/notification_to_mailer_presenter.rb +39 -0
  254. data/app/presenters/decidim/notifications_digest_presenter.rb +42 -0
  255. data/app/presenters/decidim/official_author_presenter.rb +4 -0
  256. data/app/presenters/decidim/organization_presenter.rb +22 -0
  257. data/app/presenters/decidim/push_notification_presenter.rb +25 -0
  258. data/app/presenters/decidim/stats_presenter.rb +1 -1
  259. data/app/presenters/decidim/user_presenter.rb +4 -1
  260. data/app/presenters/decidim/validation_errors_presenter.rb +1 -1
  261. data/app/queries/decidim/messaging/user_conversations.rb +1 -1
  262. data/app/queries/decidim/metric_manage.rb +1 -1
  263. data/app/queries/decidim/own_activities.rb +11 -0
  264. data/app/queries/decidim/participatory_processes_with_user_role.rb +1 -1
  265. data/app/{services/decidim/activity_search.rb → queries/decidim/public_activities.rb} +35 -77
  266. data/app/queries/decidim/public_components.rb +1 -1
  267. data/app/queries/decidim/similar_emendations.rb +1 -1
  268. data/app/queries/decidim/stats_users_count.rb +1 -1
  269. data/app/queries/decidim/user_groups/accepted_memberships.rb +1 -1
  270. data/app/queries/decidim/user_groups/accepted_user_groups.rb +1 -1
  271. data/app/queries/decidim/user_groups/accepted_users.rb +1 -1
  272. data/app/queries/decidim/user_groups/admin_memberships.rb +1 -1
  273. data/app/queries/decidim/user_groups/invited_memberships.rb +1 -1
  274. data/app/queries/decidim/user_groups/manageable_user_groups.rb +1 -1
  275. data/app/queries/decidim/user_groups/member_memberships.rb +1 -1
  276. data/app/scrubbers/decidim/admin_input_scrubber.rb +25 -0
  277. data/app/scrubbers/decidim/user_input_scrubber.rb +3 -5
  278. data/app/services/decidim/{data_portability_exporter.rb → download_your_data_exporter.rb} +6 -6
  279. data/app/services/decidim/email_notification_generator.rb +2 -2
  280. data/app/services/decidim/engine_resolver.rb +66 -0
  281. data/app/services/decidim/events_manager.rb +1 -1
  282. data/app/services/decidim/iframe_disabler.rb +30 -0
  283. data/app/services/decidim/notification_generator_for_recipient.rb +1 -1
  284. data/app/services/decidim/notifications_digest_sending_decider.rb +22 -0
  285. data/app/services/decidim/notifications_subscriptions_persistor.rb +37 -0
  286. data/app/services/decidim/open_data_exporter.rb +1 -1
  287. data/app/services/decidim/resource_search.rb +17 -164
  288. data/app/services/decidim/send_push_notification.rb +61 -0
  289. data/app/services/decidim/traceability.rb +1 -1
  290. data/app/uploaders/decidim/application_uploader.rb +2 -12
  291. data/app/uploaders/decidim/cw/attachment_uploader.rb +1 -1
  292. data/app/uploaders/decidim/cw/{data_portability_uploader.rb → download_your_data_uploader.rb} +3 -3
  293. data/app/uploaders/decidim/cw/image_uploader.rb +2 -2
  294. data/app/uploaders/decidim/organization_favicon_uploader.rb +3 -2
  295. data/app/validators/passthru_validator.rb +29 -21
  296. data/app/validators/password_validator.rb +25 -4
  297. data/app/validators/uploader_image_dimensions_validator.rb +1 -1
  298. data/app/views/decidim/account/_account_notification.js.erb +20 -0
  299. data/app/views/decidim/account/_password_fields.html.erb +2 -2
  300. data/app/views/decidim/account/cancel_email_change.js.erb +6 -0
  301. data/app/views/decidim/account/resend_confirmation_instructions.erb +1 -0
  302. data/app/views/decidim/account/show.html.erb +19 -6
  303. data/app/views/decidim/application/{_attachments.html.erb → _attachments.erb} +2 -2
  304. data/app/views/decidim/application/_collection.html.erb +1 -1
  305. data/app/views/decidim/application/{_document.html.erb → _document.erb} +0 -0
  306. data/app/views/decidim/application/{_documents.html.erb → _documents.erb} +2 -2
  307. data/app/views/decidim/application/{_photos.html.erb → _photos.erb} +0 -0
  308. data/app/views/decidim/devise/confirmations/new.html.erb +1 -1
  309. data/app/views/decidim/devise/invitations/edit.html.erb +3 -4
  310. data/app/views/decidim/devise/omniauth_registrations/new.html.erb +3 -3
  311. data/app/views/decidim/devise/passwords/edit.html.erb +7 -5
  312. data/app/views/decidim/devise/passwords/new.html.erb +1 -1
  313. data/app/views/decidim/devise/registrations/new.html.erb +5 -5
  314. data/app/views/decidim/devise/sessions/new.html.erb +2 -2
  315. data/app/views/decidim/{data_portability → download_your_data}/export.html.erb +0 -0
  316. data/app/views/decidim/{data_portability → download_your_data}/show.html.erb +2 -2
  317. data/app/views/decidim/export_mailer/download_your_data_export.html.erb +7 -0
  318. data/app/views/decidim/last_activities/index.html.erb +1 -1
  319. data/app/views/decidim/manifests/show.json.erb +31 -0
  320. data/app/views/decidim/messaging/conversations/_add_conversation_users.html.erb +5 -3
  321. data/app/views/decidim/messaging/conversations/_reply.html.erb +1 -1
  322. data/app/views/decidim/messaging/conversations/_start.html.erb +1 -3
  323. data/app/views/decidim/messaging/conversations/create.js.erb +1 -0
  324. data/app/views/decidim/notifications_digest_mailer/_email_content.html.erb +11 -0
  325. data/app/views/decidim/notifications_digest_mailer/digest_mail.erb +27 -0
  326. data/app/views/decidim/notifications_settings/show.html.erb +67 -44
  327. data/app/views/decidim/offline/show.html.erb +9 -0
  328. data/app/views/decidim/pages/_standalone.html.erb +1 -1
  329. data/app/views/decidim/pages/_tabbed.html.erb +1 -1
  330. data/app/views/decidim/reported_mailer/hide.html.erb +1 -1
  331. data/app/views/decidim/reported_mailer/report.html.erb +1 -1
  332. data/app/views/decidim/scopes/picker.html.erb +1 -1
  333. data/app/views/decidim/searches/_filters.html.erb +2 -2
  334. data/app/views/decidim/shared/participatory_space_filters/_filters.html.erb +3 -3
  335. data/app/views/decidim/user_interests/show.html.erb +11 -13
  336. data/app/views/decidim/user_report_mailer/notify.html.erb +10 -3
  337. data/app/views/devise/mailer/confirmation_instructions.html.erb +3 -1
  338. data/app/views/layouts/decidim/_application.html.erb +6 -3
  339. data/app/views/layouts/decidim/_data_consent_warning.html.erb +8 -0
  340. data/app/views/layouts/decidim/_decidim_javascript.html.erb +12 -0
  341. data/app/views/layouts/decidim/_head.html.erb +4 -2
  342. data/app/views/layouts/decidim/_js_configuration.html.erb +5 -1
  343. data/app/views/layouts/decidim/_main_footer.html.erb +1 -0
  344. data/app/views/layouts/decidim/_offline_banner.html.erb +11 -0
  345. data/app/views/layouts/decidim/widget.html.erb +2 -2
  346. data/config/assets.rb +1 -0
  347. data/config/locales/ar.yml +48 -45
  348. data/config/locales/bg.yml +15 -39
  349. data/config/locales/ca.yml +191 -45
  350. data/config/locales/cs.yml +192 -44
  351. data/config/locales/de.yml +227 -44
  352. data/config/locales/el.yml +15 -39
  353. data/config/locales/en.yml +187 -41
  354. data/config/locales/eo.yml +4 -6
  355. data/config/locales/es-MX.yml +190 -44
  356. data/config/locales/es-PY.yml +190 -44
  357. data/config/locales/es.yml +190 -44
  358. data/config/locales/eu.yml +16 -46
  359. data/config/locales/fi-plain.yml +188 -42
  360. data/config/locales/fi.yml +188 -42
  361. data/config/locales/fr-CA.yml +189 -43
  362. data/config/locales/fr.yml +196 -50
  363. data/config/locales/ga-IE.yml +5 -9
  364. data/config/locales/gl.yml +47 -39
  365. data/config/locales/hu.yml +312 -41
  366. data/config/locales/id-ID.yml +15 -38
  367. data/config/locales/is-IS.yml +6 -15
  368. data/config/locales/it.yml +23 -48
  369. data/config/locales/ja.yml +189 -44
  370. data/config/locales/lb.yml +16 -41
  371. data/config/locales/lt.yml +1950 -0
  372. data/config/locales/lv.yml +15 -37
  373. data/config/locales/nl.yml +41 -43
  374. data/config/locales/no.yml +25 -45
  375. data/config/locales/pl.yml +113 -41
  376. data/config/locales/pt-BR.yml +17 -41
  377. data/config/locales/pt.yml +16 -41
  378. data/config/locales/ro-RO.yml +20 -45
  379. data/config/locales/ru.yml +15 -27
  380. data/config/locales/sk.yml +15 -39
  381. data/config/locales/sl.yml +1 -0
  382. data/config/locales/sr-CS.yml +1 -0
  383. data/config/locales/sv.yml +73 -43
  384. data/config/locales/tr-TR.yml +15 -38
  385. data/config/locales/uk.yml +15 -26
  386. data/config/locales/zh-CN.yml +17 -39
  387. data/config/routes.rb +37 -4
  388. data/db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb +1 -0
  389. data/db/migrate/20181030090144_destroy_deleted_users_follows.rb +1 -0
  390. data/db/migrate/20190412131728_fix_user_names.rb +4 -4
  391. data/db/migrate/20210831181634_add_service_name_to_active_storage_blobs.active_storage.rb +22 -0
  392. data/db/migrate/20210831181635_create_active_storage_variant_records.active_storage.rb +14 -0
  393. data/db/migrate/20211208155453_create_decidim_reminders.rb +11 -0
  394. data/db/migrate/20211209121025_create_decidim_reminder_records.rb +11 -0
  395. data/db/migrate/20211209121040_create_decidim_reminder_deliveries.rb +10 -0
  396. data/db/migrate/20220118121921_change_required_description_categories.rb +7 -0
  397. data/db/migrate/20220127113419_add_notification_settings_to_users.rb +7 -0
  398. data/db/migrate/20220203121137_add_notifications_sending_frequency_to_users.rb +7 -0
  399. data/db/migrate/20220215172439_add_digest_sent_at_to_users.rb +7 -0
  400. data/db/migrate/20220323195258_add_index_to_decidim_users_notifications_sending_frequency.rb +7 -0
  401. data/db/migrate/20220427142214_drop_emails_on_notifications_flag_from_user.rb +15 -0
  402. data/db/migrate/20220518094535_add_previous_passwords_to_users.rb +20 -0
  403. data/db/migrate/20220524195530_create_decidim_short_links.rb +23 -0
  404. data/db/seeds.rb +17 -18
  405. data/lib/decidim/acts_as_tree.rb +47 -0
  406. data/lib/decidim/api/input_sorts/component_input_sort.rb +2 -1
  407. data/lib/decidim/api/interfaces/authorable_interface.rb +6 -5
  408. data/lib/decidim/asset_router.rb +80 -0
  409. data/lib/decidim/attachment_attributes.rb +8 -8
  410. data/lib/decidim/attribute_object/form.rb +174 -0
  411. data/lib/decidim/attribute_object/model.rb +148 -0
  412. data/lib/decidim/attribute_object/nested_validator.rb +22 -0
  413. data/lib/decidim/attribute_object/type_map.rb +14 -0
  414. data/lib/decidim/attribute_object/type_resolver.rb +91 -0
  415. data/lib/decidim/attribute_object.rb +26 -0
  416. data/lib/decidim/attributes/array.rb +62 -0
  417. data/lib/decidim/attributes/blob.rb +20 -0
  418. data/lib/decidim/attributes/clean_string.rb +12 -6
  419. data/lib/decidim/attributes/hash.rb +36 -0
  420. data/lib/decidim/attributes/integer.rb +17 -0
  421. data/lib/decidim/attributes/localized_date.rb +9 -7
  422. data/lib/decidim/attributes/model.rb +32 -0
  423. data/lib/decidim/attributes/object.rb +28 -0
  424. data/lib/decidim/attributes/symbol.rb +23 -0
  425. data/lib/decidim/attributes/time_with_zone.rb +9 -7
  426. data/lib/decidim/attributes.rb +29 -0
  427. data/lib/decidim/authorable.rb +21 -6
  428. data/lib/decidim/authorization_form_builder.rb +9 -11
  429. data/lib/decidim/carrier_wave_migrator_service.rb +15 -15
  430. data/lib/decidim/coauthorable.rb +22 -4
  431. data/lib/decidim/command.rb +44 -0
  432. data/lib/decidim/common_passwords.rb +1 -1
  433. data/lib/decidim/component_manifest.rb +5 -5
  434. data/lib/decidim/component_validator.rb +2 -2
  435. data/lib/decidim/content_block_manifest.rb +1 -1
  436. data/lib/decidim/content_parsers/hashtag_parser.rb +2 -2
  437. data/lib/decidim/content_parsers/resource_parser.rb +1 -1
  438. data/lib/decidim/content_parsers/user_group_parser.rb +1 -1
  439. data/lib/decidim/content_parsers/user_parser.rb +4 -4
  440. data/lib/decidim/content_renderers/hashtag_renderer.rb +1 -1
  441. data/lib/decidim/content_renderers/link_renderer.rb +2 -2
  442. data/lib/decidim/content_renderers/user_group_renderer.rb +1 -1
  443. data/lib/decidim/content_renderers/user_renderer.rb +1 -1
  444. data/lib/decidim/controller_helpers.rb +41 -0
  445. data/lib/decidim/core/engine.rb +30 -19
  446. data/lib/decidim/core/test/factories.rb +48 -8
  447. data/lib/decidim/core/test/shared_examples/admin_resource_gallery_examples.rb +16 -4
  448. data/lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb +1 -1
  449. data/lib/decidim/core/test/shared_examples/authorable_interface_examples.rb +15 -2
  450. data/lib/decidim/core/test/shared_examples/coauthorable_interface_examples.rb +2 -2
  451. data/lib/decidim/core/test/shared_examples/comments_examples.rb +203 -0
  452. data/lib/decidim/core/test/shared_examples/localised_email.rb +1 -1
  453. data/lib/decidim/core/test/shared_examples/logo_email.rb +1 -1
  454. data/lib/decidim/core/test/shared_examples/map_examples.rb +2 -2
  455. data/lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb +0 -6
  456. data/lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb +60 -0
  457. data/lib/decidim/core/test/shared_examples/resource_search_examples.rb +120 -40
  458. data/lib/decidim/core/test/shared_examples/resourceable.rb +0 -6
  459. data/lib/decidim/core/test/shared_examples/searchable_participatory_space_examples.rb +1 -1
  460. data/lib/decidim/core/test/shared_examples/searchable_resources_shared_context.rb +1 -1
  461. data/lib/decidim/core/test/shared_examples/system_endorse_resource_examples.rb +3 -3
  462. data/lib/decidim/core/test/shared_examples/translated_event_examples.rb +2 -2
  463. data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +40 -0
  464. data/lib/decidim/core/test/shared_examples/with_endorsable_permissions_examples.rb +1 -1
  465. data/lib/decidim/core/test.rb +2 -0
  466. data/lib/decidim/core/version.rb +1 -1
  467. data/lib/decidim/core.rb +149 -16
  468. data/lib/decidim/dependency_resolver.rb +272 -0
  469. data/lib/decidim/{data_portability.rb → download_your_data.rb} +3 -3
  470. data/lib/decidim/{data_portability_serializers/data_portability_conversation_serializer.rb → download_your_data_serializers/download_your_data_conversation_serializer.rb} +2 -2
  471. data/lib/decidim/{data_portability_serializers/data_portability_follow_serializer.rb → download_your_data_serializers/download_your_data_follow_serializer.rb} +2 -2
  472. data/lib/decidim/{data_portability_serializers/data_portability_identity_serializer.rb → download_your_data_serializers/download_your_data_identity_serializer.rb} +2 -2
  473. data/lib/decidim/{data_portability_serializers/data_portability_notification_serializer.rb → download_your_data_serializers/download_your_data_notification_serializer.rb} +2 -2
  474. 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
  475. data/lib/decidim/{data_portability_serializers/data_portability_report_serializer.rb → download_your_data_serializers/download_your_data_report_serializer.rb} +2 -2
  476. 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
  477. data/lib/decidim/{data_portability_serializers/data_portability_user_serializer.rb → download_your_data_serializers/download_your_data_user_serializer.rb} +3 -3
  478. data/lib/decidim/download_your_data_serializers.rb +23 -0
  479. data/lib/decidim/engine_router.rb +7 -1
  480. data/lib/decidim/env.rb +56 -0
  481. data/lib/decidim/event_recorder.rb +25 -0
  482. data/lib/decidim/events/base_event.rb +10 -14
  483. data/lib/decidim/events/simple_event.rb +13 -4
  484. data/lib/decidim/exporters/export_data.rb +1 -1
  485. data/lib/decidim/exporters/export_manifest.rb +2 -1
  486. data/lib/decidim/file_validator_humanizer.rb +24 -1
  487. data/lib/decidim/filterable_resource.rb +55 -0
  488. data/lib/decidim/fingerprint_calculator.rb +2 -4
  489. data/lib/decidim/form_builder.rb +158 -130
  490. data/lib/decidim/gamification/badge.rb +2 -3
  491. data/lib/decidim/gamification/badge_scorer.rb +1 -0
  492. data/lib/decidim/has_area.rb +27 -0
  493. data/lib/decidim/has_attachments.rb +2 -2
  494. data/lib/decidim/has_category.rb +36 -0
  495. data/lib/decidim/has_resource_permission.rb +0 -2
  496. data/lib/decidim/importers/import_manifest.rb +3 -21
  497. data/lib/decidim/jsonb_attributes.rb +6 -4
  498. data/lib/decidim/manifest_messages.rb +23 -0
  499. data/lib/decidim/map/autocomplete.rb +6 -4
  500. data/lib/decidim/map/frontend.rb +2 -2
  501. data/lib/decidim/map/provider/dynamic_map/here.rb +46 -1
  502. data/lib/decidim/map/provider/geocoding/here.rb +5 -5
  503. data/lib/decidim/map/provider/here.rb +3 -0
  504. data/lib/decidim/map/provider/osm.rb +3 -0
  505. data/lib/decidim/map.rb +4 -4
  506. data/lib/decidim/menu.rb +1 -1
  507. data/lib/decidim/metric_manifest.rb +2 -2
  508. data/lib/decidim/nicknamizable.rb +1 -1
  509. data/lib/decidim/notification_setting_manifest.rb +19 -0
  510. data/lib/decidim/organization_settings.rb +8 -7
  511. data/lib/decidim/participatory_space_context_manifest.rb +2 -2
  512. data/lib/decidim/participatory_space_manifest.rb +2 -2
  513. data/lib/decidim/processes_file_locally.rb +31 -0
  514. data/lib/decidim/query.rb +84 -0
  515. data/lib/decidim/record_encryptor.rb +29 -8
  516. data/lib/decidim/reminder_manifest.rb +75 -0
  517. data/lib/decidim/reminder_registry.rb +67 -0
  518. data/lib/decidim/resource_manifest.rb +1 -1
  519. data/lib/decidim/resourceable.rb +11 -0
  520. data/lib/decidim/scopable.rb +15 -0
  521. data/lib/decidim/settings_manifest.rb +4 -4
  522. data/lib/decidim/spring.rb +16 -0
  523. data/lib/decidim/translatable_attributes.rb +20 -9
  524. data/lib/decidim/url_option_resolver.rb +50 -0
  525. data/lib/decidim/view_hooks.rb +1 -1
  526. data/lib/decidim/view_model.rb +5 -1
  527. data/lib/decidim/webpacker/thread_safe_compiler.rb +30 -0
  528. data/lib/decidim/webpacker/webpack/custom.js +15 -3
  529. data/lib/decidim/webpacker/webpacker.yml +1 -1
  530. data/lib/decidim/webpacker.rb +2 -0
  531. data/lib/devise/models/decidim_validatable.rb +1 -1
  532. data/lib/tasks/decidim_active_storage_migration_tasks.rake +1 -3
  533. data/lib/tasks/{decidim_data_portability_tasks.rake → decidim_download_your_data_tasks.rake} +9 -9
  534. data/lib/tasks/decidim_mailers_tasks.rake +23 -0
  535. data/lib/tasks/decidim_metrics_tasks.rake +1 -1
  536. data/lib/tasks/decidim_pwa_tasks.rake +18 -0
  537. data/lib/tasks/decidim_reminders_tasks.rake +17 -0
  538. data/lib/tasks/decidim_tasks.rake +6 -1
  539. data/lib/tasks/decidim_webpacker_tasks.rake +1 -1
  540. data/lib/tasks/upgrade/decidim_fix_nickname_uniqueness.rake +51 -0
  541. metadata +190 -85
  542. data/app/controllers/decidim/cookie_policy_controller.rb +0 -24
  543. data/app/helpers/decidim/cookies_helper.rb +0 -11
  544. data/app/packs/src/decidim/vizzs/renders.js +0 -9
  545. data/app/packs/src/decidim/vizzs.js +0 -1
  546. data/app/packs/stylesheets/decidim/modules/_cookie-bar.scss +0 -26
  547. data/app/services/decidim/home_activity_search.rb +0 -80
  548. data/app/services/decidim/participatory_space_search.rb +0 -54
  549. data/app/views/decidim/cookie_policy/accept.js.erb +0 -3
  550. data/app/views/decidim/devise/registrations/edit.html.erb +0 -41
  551. data/app/views/decidim/export_mailer/data_portability_export.html.erb +0 -7
  552. data/app/views/layouts/decidim/_cookie_warning.html.erb +0 -8
  553. data/lib/decidim/data_portability_serializers.rb +0 -23
  554. data/lib/decidim/middleware/rails_cookies.rb +0 -23
@@ -33,7 +33,7 @@ module Decidim
33
33
  )
34
34
  end
35
35
 
36
- base_config.merge(api_key: api_key)
36
+ base_config.merge(api_key: api_key, language: language_code)
37
37
  end
38
38
 
39
39
  # A builder for the HERE maps which needs to be configured differently
@@ -44,6 +44,51 @@ module Decidim
44
44
  template.javascript_pack_tag("decidim_map_provider_here", defer: false)
45
45
  end
46
46
  end
47
+
48
+ private
49
+
50
+ def language_code
51
+ primary = I18n.locale.to_s
52
+ secondary = primary.split("-")[0]
53
+ available_language_codes[primary] || available_language_codes[secondary] || ""
54
+ end
55
+
56
+ def available_language_codes
57
+ @available_language_codes ||= {
58
+ "ar" => "ara", # Arabic
59
+ "eu" => "baq", # Basque
60
+ "ca" => "cat", # Catalan
61
+ "zh" => "chi", # Chinese (simplified)
62
+ # "" => "cht", # Chinese (traditional)
63
+ "cs" => "cze", # Czech
64
+ "da" => "dan", # Danish
65
+ "nl" => "dut", # Dutch
66
+ "en" => "eng", # English
67
+ "fi" => "fin", # Finnish
68
+ "fr" => "fre", # French
69
+ "de" => "ger", # German
70
+ "ga" => "gle", # Gaelic
71
+ "el" => "gre", # Greek
72
+ "he" => "heb", # Hebrew
73
+ "hi" => "hin", # Hindi
74
+ "id" => "ind", # Indonesian
75
+ "it" => "ita", # Italian
76
+ "no" => "nor", # Norwegian
77
+ "fa" => "per", # Persian
78
+ "pl" => "pol", # Polish
79
+ "pt" => "por", # Portuguese
80
+ "ru" => "rus", # Russian
81
+ "si" => "sin", # Sinhalese
82
+ "es" => "spa", # Spanish
83
+ "sv" => "swe", # Swedish
84
+ "th" => "tha", # Thai
85
+ "tr" => "tur", # Turkish
86
+ "uk" => "ukr", # Ukrainian
87
+ "ur" => "urd", # Urdu
88
+ "vi" => "vie", # Vietnamese
89
+ "cy" => "wel" # Welsh
90
+ }
91
+ end
47
92
  end
48
93
  end
49
94
  end
@@ -22,15 +22,15 @@ module Decidim
22
22
  # Always prioritize house number results, even if they are not as
23
23
  # close as street level matches.
24
24
  hn_result = results.find do |r|
25
- r.data["MatchLevel"] == "houseNumber"
25
+ r.data["resultType"] == "houseNumber"
26
26
  end
27
27
  return hn_result.address if hn_result
28
28
 
29
- # Some of the matches that have "MatchLevel" == "street" do not even
30
- # contain the street name unless they also have the "Street" key in
31
- # the "MatchQuality" attribute defined.
29
+ # Some of the matches that have "resultType" == "street" do not even
30
+ # contain the street name unless they also have the "streets" key in
31
+ # the "scoring" -> "fieldScore" attribute defined.
32
32
  street_result = results.find do |r|
33
- r.data["MatchQuality"].has_key?("Street")
33
+ r.data["scoring"]["fieldScore"].has_key?("streets")
34
34
  end
35
35
  return street_result.address if street_result
36
36
 
@@ -7,12 +7,15 @@ module Decidim
7
7
  module Autocomplete
8
8
  autoload :Here, "decidim/map/provider/autocomplete/here"
9
9
  end
10
+
10
11
  module Geocoding
11
12
  autoload :Here, "decidim/map/provider/geocoding/here"
12
13
  end
14
+
13
15
  module DynamicMap
14
16
  autoload :Here, "decidim/map/provider/dynamic_map/here"
15
17
  end
18
+
16
19
  module StaticMap
17
20
  autoload :Here, "decidim/map/provider/static_map/here"
18
21
  end
@@ -8,12 +8,15 @@ module Decidim
8
8
  module Autocomplete
9
9
  autoload :Osm, "decidim/map/provider/autocomplete/osm"
10
10
  end
11
+
11
12
  module Geocoding
12
13
  autoload :Osm, "decidim/map/provider/geocoding/osm"
13
14
  end
15
+
14
16
  module DynamicMap
15
17
  autoload :Osm, "decidim/map/provider/dynamic_map/osm"
16
18
  end
19
+
17
20
  module StaticMap
18
21
  autoload :Osm, "decidim/map/provider/static_map/osm"
19
22
  end
data/lib/decidim/map.rb CHANGED
@@ -51,7 +51,7 @@ module Decidim
51
51
 
52
52
  config = utility_configuration(category)
53
53
  options[:config] = config.except(:provider)
54
- klass.new(options)
54
+ klass.new(**options)
55
55
  end
56
56
 
57
57
  # Public: Returns the utility class module namespace for each category of
@@ -75,9 +75,9 @@ module Decidim
75
75
 
76
76
  # Dynamically define the category method.
77
77
  module_eval %{
78
- def self.#{category}(options)
79
- utility(:#{category}, options)
80
- end
78
+ def self.#{category}(options) # def self.dynamic(options)
79
+ utility(:#{category}, options) # utility(:dynamic, options)
80
+ end # end
81
81
  }, __FILE__, __LINE__ - 4
82
82
 
83
83
  mod
data/lib/decidim/menu.rb CHANGED
@@ -102,7 +102,7 @@ module Decidim
102
102
  #
103
103
  def items
104
104
  @items.reject! { |item| @removed_items.include?(item.identifier) }
105
- @ordered_elements.each { |item| move_element(item) }
105
+ @ordered_elements.each { |item| move_element(**item) }
106
106
  @items.select(&:visible?).sort_by(&:position)
107
107
  end
108
108
 
@@ -4,11 +4,11 @@ module Decidim
4
4
  # This class acts as a manifest for metrics.
5
5
  #
6
6
  # This manifest is a simple object that holds and stores currently available
7
- # metrics and his managers, for calculations purpose
7
+ # metrics and its managers, for calculations purpose
8
8
  #
9
9
  class MetricManifest
10
10
  include ActiveModel::Model
11
- include Virtus.model
11
+ include Decidim::AttributeObject::Model
12
12
 
13
13
  attribute :metric_name, String
14
14
  attribute :manager_class, String
@@ -52,7 +52,7 @@ module Decidim
52
52
  candidate = name
53
53
 
54
54
  2.step do |n|
55
- return candidate unless exists?(scope.merge(nickname: candidate))
55
+ return candidate if Decidim::UserBaseEntity.where("nickname ILIKE ?", candidate.downcase).where(scope).empty?
56
56
 
57
57
  candidate = numbered_variation_of(name, n)
58
58
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This class holds the configuration for notification settings at component level.
5
+ #
6
+ # This manifest is a simple object that holds and stores current attributes
7
+ # and their specific validators
8
+ class NotificationSettingManifest
9
+ include ActiveModel::Model
10
+ include Decidim::AttributeObject::Model
11
+
12
+ attribute :name, Symbol
13
+ attribute :settings_area, Symbol
14
+ attribute :default_value, Boolean, default: true
15
+
16
+ validates :default_value, inclusion: { in: [true, false] }
17
+ validates :settings_area, inclusion: { in: [:global, :administrators] }
18
+ end
19
+ end
@@ -106,7 +106,8 @@ module Decidim
106
106
  "allowed_file_extensions" => {
107
107
  "default" => %w(jpg jpeg gif png bmp pdf rtf txt),
108
108
  "admin" => %w(jpg jpeg gif png bmp pdf doc docx xls xlsx ppt pptx ppx rtf txt odt ott odf otg ods ots),
109
- "image" => %w(jpg jpeg gif png bmp ico)
109
+ "image" => %w(jpg jpeg gif png bmp),
110
+ "favicon" => %w(png)
110
111
  },
111
112
  "allowed_content_types" => {
112
113
  "default" => %w(
@@ -129,8 +130,8 @@ module Decidim
129
130
  )
130
131
  },
131
132
  "maximum_file_size" => {
132
- "default" => 10,
133
- "avatar" => 5
133
+ "default" => 10.0,
134
+ "avatar" => 5.0
134
135
  }
135
136
  }
136
137
  }
@@ -148,7 +149,7 @@ module Decidim
148
149
  # all configurations have values even when the organization settings do
149
150
  # not define them.
150
151
  super(
151
- keys_map.map do |config, method|
152
+ keys_map.to_h do |config, method|
152
153
  [
153
154
  config.to_s,
154
155
  generate_config(
@@ -156,7 +157,7 @@ module Decidim
156
157
  self.class.default(config)
157
158
  )
158
159
  ]
159
- end.to_h
160
+ end
160
161
  )
161
162
 
162
163
  keys_map.keys.each do |config|
@@ -190,10 +191,10 @@ module Decidim
190
191
  # @return [OpenStruct] The configuration struct.
191
192
  def generate_config(hash, default = {})
192
193
  OpenStruct.new(
193
- default.deep_merge(hash).map do |key, value|
194
+ default.deep_merge(hash).to_h do |key, value|
194
195
  value = generate_config(value) if value.is_a?(Hash)
195
196
  [key, value]
196
- end.to_h
197
+ end
197
198
  )
198
199
  end
199
200
 
@@ -5,9 +5,9 @@ module Decidim
5
5
  # engine, a layout and a set of helpers (usually used by the layout itself).
6
6
  class ParticipatorySpaceContextManifest
7
7
  include ActiveModel::Model
8
- include Virtus.model
8
+ include Decidim::AttributeObject::Model
9
9
 
10
- attribute :engine, Rails::Engine
10
+ attribute :engine, Rails::Engine, **{}
11
11
  attribute :helper
12
12
  attribute :layout
13
13
  end
@@ -12,7 +12,7 @@ module Decidim
12
12
  # `Decidim.register_participatory_space`.
13
13
  class ParticipatorySpaceManifest
14
14
  include ActiveModel::Model
15
- include Virtus.model
15
+ include Decidim::AttributeObject::Model
16
16
 
17
17
  attribute :name, Symbol
18
18
 
@@ -28,7 +28,7 @@ module Decidim
28
28
  attribute :query_list, String, default: "Decidim::Core::ParticipatorySpaceList"
29
29
 
30
30
  # An array with the name of the classes that will be exported with
31
- # the data portability feature for this component. For example, `Decidim::<MyModule>::<MyClass>``
31
+ # the download your data feature for this component. For example, `Decidim::<MyModule>::<MyClass>``
32
32
  attribute :data_portable_entities, Array, default: []
33
33
 
34
34
  # A String with the component's icon. The icon must be stored in the
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/concern"
4
+
5
+ module Decidim
6
+ # A concern to help when the file needs to be available locally.
7
+ # For example, we need to download file first if it's in AWS S3 bucket
8
+ # or somewhere else than locally in the server.
9
+ module ProcessesFileLocally
10
+ extend ActiveSupport::Concern
11
+
12
+ private
13
+
14
+ def process_file_locally(blob)
15
+ if ActiveStorage::Blob.service.respond_to? :path_for
16
+ yield ActiveStorage::Blob.service.path_for(blob.key)
17
+ else
18
+ begin
19
+ tempfile = Tempfile.new
20
+ tempfile.binmode
21
+ blob.download { |chunk| tempfile.write(chunk) }
22
+ tempfile.flush
23
+ tempfile.rewind
24
+ yield tempfile.path
25
+ ensure
26
+ tempfile.close!
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2016 Andy Pike - The MIT license
4
+ #
5
+ # This file has been copied from https://github.com/andypike/rectify/blob/master/lib/rectify/query.rb
6
+ # We have done this so we can decouple Decidim from any Virtus dependency, which is a dead project
7
+ # Please follow Decidim discussion to understand more https://github.com/decidim/decidim/discussions/7234
8
+ module Decidim
9
+ class UnableToComposeQueriesException < StandardError
10
+ def initialize(query, other)
11
+ super(
12
+ "Unable to composite queries #{query.class.name} and " \
13
+ "#{other.class.name}. You cannot compose queries where #query " \
14
+ "returns an ActiveRecord::Relation in one and an array in the other."
15
+ )
16
+ end
17
+ end
18
+
19
+ class Query
20
+ include Enumerable
21
+
22
+ def self.merge(*queries)
23
+ queries.reduce(Decidim::Query.new([])) { |a, e| a.merge(e) }
24
+ end
25
+
26
+ def initialize(scope = ActiveRecord::NullRelation)
27
+ @scope = scope
28
+ end
29
+
30
+ def query
31
+ @scope
32
+ end
33
+
34
+ def |(other)
35
+ return other if @scope.is_a?(Array) && @scope == []
36
+
37
+ if relation? && other.relation?
38
+ Decidim::Query.new(cached_query.merge(other.cached_query))
39
+ elsif eager? && other.eager?
40
+ Decidim::Query.new(cached_query | other.cached_query)
41
+ else
42
+ raise Decidim::UnableToComposeQueriesException.new(self, other)
43
+ end
44
+ end
45
+
46
+ alias merge |
47
+
48
+ delegate :count, to: :cached_query
49
+
50
+ alias size count
51
+
52
+ delegate :first, to: :cached_query
53
+
54
+ def each(&block)
55
+ cached_query.each(&block)
56
+ end
57
+
58
+ def exists?
59
+ return cached_query.exists? if relation?
60
+
61
+ cached_query.present?
62
+ end
63
+
64
+ def none?
65
+ !exists?
66
+ end
67
+
68
+ delegate :to_a, to: :cached_query
69
+
70
+ alias to_ary to_a
71
+
72
+ def relation?
73
+ cached_query.is_a?(ActiveRecord::Relation)
74
+ end
75
+
76
+ def eager?
77
+ cached_query.is_a?(Array)
78
+ end
79
+
80
+ def cached_query
81
+ @cached_query ||= query
82
+ end
83
+ end
84
+ end
@@ -35,14 +35,12 @@ module Decidim
35
35
  # the `type` is `:hash`, method `decrypt_hash_values` would be called
36
36
  # for decryption and `encrypt_hash_values` would be called for
37
37
  # encryption.
38
- method_suffix = begin
39
- case type
40
- when :hash
41
- "hash_values"
42
- else
43
- "value"
44
- end
45
- end
38
+ method_suffix = case type
39
+ when :hash
40
+ "hash_values"
41
+ else
42
+ "value"
43
+ end
46
44
 
47
45
  # Dynamically defines the getter and setter for the encrypted attribute.
48
46
  # E.g. when called as `encrypt_attribute :name, type: :string`, this
@@ -56,6 +54,19 @@ module Decidim
56
54
  # super(encrypt_value(value))
57
55
  # end
58
56
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
57
+
58
+ # def full_name
59
+ # return @full_name_decrypted if instance_variable_defined?(:@full_name_decrypted)
60
+ #
61
+ # encrypted_value = begin
62
+ # if defined?(super)
63
+ # super
64
+ # elsif instance_variable_defined?(:@full_name)
65
+ # @full_name
66
+ # end
67
+ # end
68
+ # @full_name_decrypted = decrypt_value(encrypted_value)
69
+ # end
59
70
  def #{attribute}
60
71
  return @#{attribute}_decrypted if instance_variable_defined?(:@#{attribute}_decrypted)
61
72
 
@@ -69,6 +80,16 @@ module Decidim
69
80
  @#{attribute}_decrypted = decrypt_#{method_suffix}(encrypted_value)
70
81
  end
71
82
 
83
+ # def full_name=(value)
84
+ # remove_instance_variable(:@full_name_decrypted) if instance_variable_defined?(:@full_name_decrypted)
85
+ # encrypted_value = encrypt_value(value)
86
+ #
87
+ # if defined?(super)
88
+ # super(encrypted_value)
89
+ # else
90
+ # @full_name = encrypted_value
91
+ # end
92
+ # end
72
93
  def #{attribute}=(value)
73
94
  remove_instance_variable(:@#{attribute}_decrypted) if instance_variable_defined?(:@#{attribute}_decrypted)
74
95
  encrypted_value = encrypt_#{method_suffix}(value)
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This class acts as a manifest for reminders.
5
+ #
6
+ # This manifest is a simple object that holds and stores reminder
7
+ # and it's generator class.
8
+ class ReminderManifest
9
+ include ActiveModel::Model
10
+ include Decidim::AttributeObject::Model
11
+
12
+ attribute :generator_class_name, String
13
+ attribute :form_class_name, String
14
+ attribute :command_class_name, String
15
+
16
+ validates :generator_class, presence: true
17
+
18
+ attr_reader :name
19
+
20
+ def initialize(name:)
21
+ super()
22
+ @name = name
23
+ @messages = ReminderManifestMessages.new
24
+ end
25
+
26
+ def generator_class
27
+ generator_class_name.constantize
28
+ end
29
+
30
+ def form_class
31
+ form_class_name.constantize
32
+ end
33
+
34
+ def command_class
35
+ command_class_name.constantize
36
+ end
37
+
38
+ def has_settings?
39
+ settings.attributes.any?
40
+ end
41
+
42
+ def settings(&block)
43
+ @settings ||= SettingsManifest.new
44
+ yield(@settings) if block
45
+ @settings
46
+ end
47
+
48
+ # Fetch the messages object or yield it for the block when a block is
49
+ # given.
50
+ def messages
51
+ if block_given?
52
+ yield @messages
53
+ else
54
+ @messages
55
+ end
56
+ end
57
+
58
+ def message(key, context = nil, **extra, &block)
59
+ extra = context if extra.empty? && context.is_a?(Hash)
60
+
61
+ if block_given?
62
+ messages.set(key, &block)
63
+ else
64
+ messages.render(key, context, **extra)
65
+ end
66
+ end
67
+
68
+ # Returns a boolean indicating whether the message exists with the given key.
69
+ def has_message?(key)
70
+ messages.has?(key)
71
+ end
72
+
73
+ class ReminderManifestMessages < Decidim::ManifestMessages; end
74
+ end
75
+ end
@@ -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
  #
@@ -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.