decidim-core 0.22.0 → 0.23.3

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 (334) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/decidim_core_manifest.js +5 -0
  3. data/app/assets/javascripts/decidim.js.es6 +2 -0
  4. data/app/assets/javascripts/decidim/ajax_modals.js.es6 +3 -3
  5. data/app/assets/javascripts/decidim/confirm.js.es6 +3 -2
  6. data/app/assets/javascripts/decidim/core/bundle.js +1 -1
  7. data/app/assets/javascripts/decidim/core/bundle.js.map +1 -1
  8. data/app/assets/javascripts/decidim/diff_mode_dropdown.js.es6 +18 -4
  9. data/app/assets/javascripts/decidim/editor.js.es6 +4 -4
  10. data/app/assets/javascripts/decidim/geocoding.js.es6 +60 -0
  11. data/app/assets/javascripts/decidim/geocoding/attach_input.js.es6 +106 -0
  12. data/app/assets/javascripts/decidim/geocoding/format_address.js.es6 +29 -0
  13. data/app/assets/javascripts/decidim/geocoding/provider/here.js.es6 +107 -0
  14. data/app/assets/javascripts/decidim/geocoding/provider/photon.js.es6 +77 -0
  15. data/app/assets/javascripts/decidim/map.js.es6 +34 -124
  16. data/app/assets/javascripts/decidim/map/controller.js.es6 +92 -0
  17. data/app/assets/javascripts/decidim/map/controller/markers.js.es6 +65 -0
  18. data/app/assets/javascripts/decidim/map/controller/static.es6 +48 -0
  19. data/app/assets/javascripts/decidim/map/factory.js.es6 +51 -0
  20. data/app/assets/javascripts/decidim/map/icon.js.es6 +31 -0
  21. data/app/assets/javascripts/decidim/map/legacy.js.es6 +87 -0
  22. data/app/assets/javascripts/decidim/map/provider/default.js.es6 +22 -0
  23. data/app/assets/javascripts/decidim/map/provider/here.js.es6 +22 -0
  24. data/app/assets/javascripts/decidim/security/selfxss_warning.js.es6 +19 -0
  25. data/app/assets/stylesheets/decidim/_decidim.scss +2 -0
  26. data/app/assets/stylesheets/decidim/layouts/_home.scss +5 -0
  27. data/app/assets/stylesheets/decidim/modules/_cards.scss +15 -0
  28. data/app/assets/stylesheets/decidim/modules/_forms.scss +14 -0
  29. data/app/assets/stylesheets/decidim/modules/_layout.scss +11 -3
  30. data/app/assets/stylesheets/decidim/modules/_map.scss +35 -0
  31. data/app/assets/stylesheets/decidim/modules/_progress-bar.scss +4 -0
  32. data/app/assets/stylesheets/decidim/modules/_reveal.scss +5 -0
  33. data/app/assets/stylesheets/decidim/modules/_status-labels.scss +2 -1
  34. data/app/cells/decidim/author/flag.erb +1 -1
  35. data/app/cells/decidim/author/profile_inline.erb +2 -2
  36. data/app/cells/decidim/author_cell.rb +5 -2
  37. data/app/cells/decidim/card_cell.rb +21 -7
  38. data/app/cells/decidim/card_m/show.erb +1 -1
  39. data/app/cells/decidim/card_m_cell.rb +6 -4
  40. data/app/cells/decidim/collapsible_authors_cell.rb +1 -1
  41. data/app/cells/decidim/content_blocks/sub_hero/show.erb +3 -1
  42. data/app/cells/decidim/diff/diff_mode_html.erb +5 -5
  43. data/app/cells/decidim/follow_button/show.erb +6 -6
  44. data/app/cells/decidim/follow_button_cell.rb +8 -0
  45. data/app/cells/decidim/progress_bar/show.erb +11 -4
  46. data/app/cells/decidim/progress_bar_cell.rb +20 -1
  47. data/app/cells/decidim/tos_page/announcement.erb +0 -1
  48. data/app/cells/decidim/tos_page/form.erb +17 -0
  49. data/app/cells/decidim/translation_bar/show.erb +6 -0
  50. data/app/cells/decidim/translation_bar_cell.rb +52 -0
  51. data/app/cells/decidim/version_cell.rb +1 -1
  52. data/app/cells/decidim/versions_list_cell.rb +1 -1
  53. data/app/commands/decidim/amendable/accept.rb +9 -3
  54. data/app/commands/decidim/amendable/create_draft.rb +2 -0
  55. data/app/commands/decidim/amendable/update_draft.rb +2 -0
  56. data/app/commands/decidim/attachment_methods.rb +20 -5
  57. data/app/commands/decidim/destroy_account.rb +1 -0
  58. data/app/commands/decidim/gallery_methods.rb +16 -9
  59. data/app/commands/decidim/messaging/reply_to_conversation.rb +1 -1
  60. data/app/commands/decidim/multiple_attachments_methods.rb +56 -0
  61. data/app/controllers/concerns/decidim/devise_controllers.rb +1 -0
  62. data/app/controllers/concerns/decidim/filter_resource.rb +24 -6
  63. data/app/controllers/concerns/decidim/flaggable.rb +20 -0
  64. data/app/controllers/concerns/decidim/force_authentication.rb +1 -0
  65. data/app/controllers/concerns/decidim/impersonate_users.rb +1 -1
  66. data/app/controllers/concerns/decidim/needs_snippets.rb +20 -0
  67. data/app/controllers/concerns/decidim/paginable.rb +5 -1
  68. data/app/controllers/concerns/decidim/withdrawable.rb +20 -0
  69. data/app/controllers/decidim/application_controller.rb +16 -0
  70. data/app/controllers/decidim/components/base_controller.rb +6 -1
  71. data/app/controllers/decidim/cookie_policy_controller.rb +6 -3
  72. data/app/controllers/decidim/messaging/conversations_controller.rb +5 -2
  73. data/app/forms/decidim/account_form.rb +5 -1
  74. data/app/forms/decidim/amendable/create_form.rb +1 -1
  75. data/app/forms/decidim/amendable/form.rb +44 -3
  76. data/app/forms/decidim/attachment_form.rb +6 -1
  77. data/app/forms/decidim/user_group_form.rb +5 -1
  78. data/app/helpers/decidim/cells_helper.rb +3 -15
  79. data/app/helpers/decidim/check_boxes_tree_helper.rb +21 -12
  80. data/app/helpers/decidim/cookies_helper.rb +1 -1
  81. data/app/helpers/decidim/decidim_form_helper.rb +1 -1
  82. data/app/helpers/decidim/filter_params_helper.rb +30 -0
  83. data/app/helpers/decidim/map_helper.rb +86 -23
  84. data/app/helpers/decidim/orders_helper.rb +6 -1
  85. data/app/helpers/decidim/paginate_helper.rb +1 -8
  86. data/app/helpers/decidim/sanitize_helper.rb +8 -0
  87. data/app/helpers/decidim/scopes_helper.rb +5 -5
  88. data/app/helpers/decidim/translations_helper.rb +7 -1
  89. data/app/jobs/decidim/data_portability_export_job.rb +3 -3
  90. data/app/jobs/decidim/machine_translation_fields_job.rb +30 -0
  91. data/app/jobs/decidim/machine_translation_resource_job.rb +113 -0
  92. data/app/jobs/decidim/machine_translation_save_job.rb +33 -0
  93. data/app/jobs/decidim/open_data_job.rb +1 -1
  94. data/app/mailers/decidim/application_mailer.rb +1 -0
  95. data/app/mailers/decidim/reported_mailer.rb +8 -1
  96. data/app/models/decidim/action_log.rb +1 -1
  97. data/app/models/decidim/area.rb +3 -0
  98. data/app/models/decidim/area_type.rb +4 -0
  99. data/app/models/decidim/attachment.rb +30 -2
  100. data/app/models/decidim/attachment_collection.rb +3 -0
  101. data/app/models/decidim/authorization.rb +3 -0
  102. data/app/models/decidim/category.rb +4 -0
  103. data/app/models/decidim/component.rb +7 -0
  104. data/app/models/decidim/content_block.rb +11 -1
  105. data/app/models/decidim/contextual_help_section.rb +4 -0
  106. data/app/models/decidim/follow.rb +3 -1
  107. data/app/models/decidim/messaging/message.rb +1 -1
  108. data/app/models/decidim/moderation.rb +1 -1
  109. data/app/models/decidim/newsletter.rb +3 -0
  110. data/app/models/decidim/oauth_application.rb +2 -0
  111. data/app/models/decidim/organization.rb +54 -10
  112. data/app/models/decidim/scope.rb +4 -1
  113. data/app/models/decidim/scope_type.rb +3 -0
  114. data/app/models/decidim/share_token.rb +49 -0
  115. data/app/models/decidim/static_page.rb +4 -1
  116. data/app/models/decidim/static_page_topic.rb +3 -0
  117. data/app/models/decidim/user.rb +11 -3
  118. data/app/models/decidim/user_base_entity.rb +6 -2
  119. data/app/permissions/decidim/permissions.rb +9 -0
  120. data/app/presenters/decidim/admin_log/component_presenter.rb +2 -2
  121. data/app/presenters/decidim/admin_log/moderation_presenter.rb +2 -2
  122. data/app/presenters/decidim/admin_log/organization_presenter.rb +2 -2
  123. data/app/presenters/decidim/admin_log/user_presenter.rb +2 -2
  124. data/app/presenters/decidim/log/base_presenter.rb +10 -2
  125. data/app/presenters/decidim/log/value_types/default_presenter.rb +1 -1
  126. data/app/presenters/decidim/official_author_presenter.rb +36 -0
  127. data/app/presenters/decidim/resource_locator_presenter.rb +63 -12
  128. data/app/queries/decidim/similar_emendations.rb +4 -4
  129. data/app/scrubbers/decidim/newsletter_scrubber.rb +31 -0
  130. data/app/scrubbers/decidim/user_input_scrubber.rb +1 -1
  131. data/app/serializers/decidim/importers/participatory_space_components_importer.rb +1 -1
  132. data/app/services/decidim/base_diff_renderer.rb +17 -0
  133. data/app/services/decidim/open_data_exporter.rb +2 -0
  134. data/app/services/decidim/resource_search.rb +95 -6
  135. data/app/services/decidim/static_map_generator.rb +10 -26
  136. data/app/services/decidim/tokenizer.rb +38 -0
  137. data/app/services/decidim/traceability.rb +3 -0
  138. data/app/uploaders/decidim/application_uploader.rb +19 -1
  139. data/app/uploaders/decidim/attachment_uploader.rb +23 -17
  140. data/app/uploaders/decidim/banner_image_uploader.rb +1 -1
  141. data/app/uploaders/decidim/hero_image_uploader.rb +1 -1
  142. data/app/uploaders/decidim/homepage_image_uploader.rb +1 -1
  143. data/app/uploaders/decidim/image_uploader.rb +6 -2
  144. data/app/uploaders/decidim/oauth_application_logo_uploader.rb +1 -1
  145. data/app/uploaders/decidim/official_image_footer_uploader.rb +1 -1
  146. data/app/uploaders/decidim/official_image_header_uploader.rb +1 -1
  147. data/app/uploaders/decidim/organization_logo_uploader.rb +1 -1
  148. data/app/uploaders/decidim/record_image_uploader.rb +15 -0
  149. data/app/validators/etiquette_validator.rb +0 -7
  150. data/app/validators/geocoding_validator.rb +9 -4
  151. data/app/validators/passthru_validator.rb +111 -0
  152. data/app/validators/scope_belongs_to_component_validator.rb +16 -0
  153. data/app/validators/uploader_content_type_validator.rb +44 -0
  154. data/app/views/decidim/authorization_modals/_content.html.erb +2 -2
  155. data/app/views/decidim/devise/registrations/new.html.erb +3 -1
  156. data/app/views/decidim/devise/sessions/new.html.erb +3 -1
  157. data/app/views/decidim/messaging/conversations/_error_modal.html.erb +21 -0
  158. data/app/views/decidim/messaging/conversations/error.js.erb +10 -0
  159. data/app/views/decidim/newsletter_mailer/newsletter.html.erb +1 -1
  160. data/app/views/decidim/notification_mailer/event_received.html.erb +2 -2
  161. data/app/views/decidim/pages/_standalone.html.erb +1 -1
  162. data/app/views/decidim/pages/_tabbed.html.erb +1 -1
  163. data/app/views/decidim/reported_mailer/report.html.erb +49 -3
  164. data/app/views/decidim/scopes/_scopes_picker_input.html.erb +15 -14
  165. data/app/views/decidim/searches/_filters.html.erb +1 -0
  166. data/app/views/decidim/shared/_login_modal.html.erb +14 -3
  167. data/app/views/decidim/shared/_static_map.html.erb +1 -1
  168. data/app/views/layouts/decidim/_head.html.erb +2 -0
  169. data/app/views/layouts/decidim/_js_configuration.html.erb +7 -1
  170. data/config/locales/am-ET.yml +1 -0
  171. data/config/locales/ar.yml +3 -4
  172. data/config/locales/bg.yml +1508 -0
  173. data/config/locales/ca.yml +36 -9
  174. data/config/locales/cs.yml +54 -27
  175. data/config/locales/da.yml +1 -0
  176. data/config/locales/de.yml +156 -128
  177. data/config/locales/el.yml +0 -4
  178. data/config/locales/en.yml +30 -3
  179. data/config/locales/eo.yml +92 -0
  180. data/config/locales/es-MX.yml +29 -2
  181. data/config/locales/es-PY.yml +28 -1
  182. data/config/locales/es.yml +44 -17
  183. data/config/locales/et.yml +1 -0
  184. data/config/locales/eu.yml +9 -4
  185. data/config/locales/fi-plain.yml +28 -1
  186. data/config/locales/fi.yml +34 -7
  187. data/config/locales/fr-CA.yml +32 -4
  188. data/config/locales/fr.yml +65 -37
  189. data/config/locales/ga-IE.yml +0 -8
  190. data/config/locales/gl.yml +10 -5
  191. data/config/locales/hr.yml +1 -0
  192. data/config/locales/hu.yml +7 -5
  193. data/config/locales/id-ID.yml +3 -4
  194. data/config/locales/is-IS.yml +3 -9
  195. data/config/locales/is.yml +463 -0
  196. data/config/locales/it.yml +37 -9
  197. data/config/locales/ja-JP.yml +25 -16
  198. data/config/locales/ja.yml +1605 -0
  199. data/config/locales/ko-KR.yml +1 -0
  200. data/config/locales/ko.yml +1 -0
  201. data/config/locales/lt.yml +1 -0
  202. data/config/locales/{lv-LV.yml → lv.yml} +2 -5
  203. data/config/locales/mt.yml +1 -0
  204. data/config/locales/nl.yml +34 -12
  205. data/config/locales/no.yml +150 -8
  206. data/config/locales/om-ET.yml +1 -0
  207. data/config/locales/pl.yml +89 -72
  208. data/config/locales/pt-BR.yml +4 -5
  209. data/config/locales/pt.yml +10 -4
  210. data/config/locales/ro-RO.yml +10 -4
  211. data/config/locales/ru.yml +3 -10
  212. data/config/locales/si-LK.yml +1 -0
  213. data/config/locales/sk.yml +3 -5
  214. data/config/locales/sl.yml +8 -7
  215. data/config/locales/so-SO.yml +1 -0
  216. data/config/locales/sr-CS.yml +0 -9
  217. data/config/locales/sv.yml +19 -8
  218. data/config/locales/sw-KE.yml +1 -0
  219. data/config/locales/ti-ER.yml +1 -0
  220. data/config/locales/tr-TR.yml +588 -247
  221. data/config/locales/uk.yml +3 -11
  222. data/config/locales/vi-VN.yml +1 -0
  223. data/config/locales/vi.yml +1 -0
  224. data/config/locales/zh-CN.yml +1584 -0
  225. data/config/locales/zh-TW.yml +1 -0
  226. data/db/migrate/20200525184143_add_enable_machine_translation_to_decidim_organizations.rb +7 -0
  227. data/db/migrate/20200702073419_create_decidim_share_tokens.rb +16 -0
  228. data/db/migrate/20200707132401_add_comments_max_length_to_decidim_organization.rb +7 -0
  229. data/db/migrate/20200730142511_add_file_upload_settings_to_decidim_organizations.rb +36 -0
  230. data/db/migrate/20200806092109_add_machine_translation_display_priority_to_organizations.rb +17 -0
  231. data/db/migrate/20201004160335_remove_notifications_with_continuity_badge.rb +9 -0
  232. data/db/seeds.rb +12 -6
  233. data/lib/decidim/authorable.rb +22 -1
  234. data/lib/decidim/authorization_form_builder.rb +7 -0
  235. data/lib/decidim/coauthorable.rb +22 -0
  236. data/lib/decidim/component_manifest.rb +1 -1
  237. data/lib/decidim/content_processor.rb +52 -29
  238. data/lib/decidim/content_renderers/base_renderer.rb +1 -1
  239. data/lib/decidim/content_renderers/hashtag_renderer.rb +2 -0
  240. data/lib/decidim/content_renderers/link_renderer.rb +4 -1
  241. data/lib/decidim/content_renderers/user_group_renderer.rb +3 -1
  242. data/lib/decidim/content_renderers/user_renderer.rb +3 -1
  243. data/lib/decidim/core.rb +67 -12
  244. data/lib/decidim/core/engine.rb +65 -21
  245. data/lib/decidim/core/test.rb +8 -0
  246. data/lib/decidim/core/test/factories.rb +34 -8
  247. data/lib/decidim/core/test/shared_examples/admin_log_presenter_examples.rb +34 -0
  248. data/lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb +4 -4
  249. data/lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb +8 -8
  250. data/lib/decidim/core/test/shared_examples/comments_examples.rb +52 -1
  251. data/lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb +31 -0
  252. data/lib/decidim/core/test/shared_examples/embed_resource_examples.rb +49 -0
  253. data/lib/decidim/core/test/shared_examples/follows_examples.rb +3 -3
  254. data/lib/decidim/core/test/shared_examples/manage_component_share_tokens.rb +83 -0
  255. data/lib/decidim/core/test/shared_examples/map_examples.rb +186 -0
  256. data/lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb +55 -0
  257. data/lib/decidim/core/test/shared_examples/resource_search_examples.rb +200 -0
  258. data/lib/decidim/core/test/shared_examples/scopable_resource_examples.rb +43 -0
  259. data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +12 -1
  260. data/lib/decidim/core/test/shared_examples/searchable_participatory_space_examples.rb +2 -2
  261. data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +15 -2
  262. data/lib/decidim/core/test/shared_examples/simple_event.rb +7 -0
  263. data/lib/decidim/core/test/shared_examples/system_endorse_resource_examples.rb +1 -0
  264. data/lib/decidim/core/test/shared_examples/traceable_interface_examples.rb +1 -1
  265. data/lib/decidim/core/test/shared_examples/uncommentable_component_examples.rb +1 -1
  266. data/lib/decidim/core/version.rb +1 -1
  267. data/lib/decidim/diffy_extension.rb +21 -0
  268. data/lib/decidim/events/base_event.rb +29 -11
  269. data/lib/decidim/exporters.rb +7 -0
  270. data/lib/decidim/exporters/csv.rb +15 -1
  271. data/lib/decidim/exporters/excel.rb +1 -1
  272. data/lib/decidim/exporters/export_manifest.rb +29 -0
  273. data/lib/decidim/exporters/pdf.rb +56 -0
  274. data/lib/decidim/file_validator_humanizer.rb +98 -0
  275. data/lib/decidim/form_builder.rb +68 -56
  276. data/lib/decidim/geocodable.rb +79 -0
  277. data/lib/decidim/has_attachments.rb +10 -0
  278. data/lib/decidim/has_private_users.rb +1 -1
  279. data/lib/decidim/has_upload_validations.rb +36 -0
  280. data/lib/decidim/map.rb +214 -0
  281. data/lib/decidim/map/autocomplete.rb +67 -0
  282. data/lib/decidim/map/dynamic_map.rb +89 -0
  283. data/lib/decidim/map/frontend.rb +97 -0
  284. data/lib/decidim/map/geocoding.rb +115 -0
  285. data/lib/decidim/map/provider.rb +12 -0
  286. data/lib/decidim/map/provider/autocomplete/here.rb +20 -0
  287. data/lib/decidim/map/provider/autocomplete/osm.rb +20 -0
  288. data/lib/decidim/map/provider/dynamic_map/here.rb +51 -0
  289. data/lib/decidim/map/provider/dynamic_map/osm.rb +13 -0
  290. data/lib/decidim/map/provider/geocoding/here.rb +58 -0
  291. data/lib/decidim/map/provider/geocoding/osm.rb +30 -0
  292. data/lib/decidim/map/provider/here.rb +21 -0
  293. data/lib/decidim/map/provider/osm.rb +22 -0
  294. data/lib/decidim/map/provider/static_map/here.rb +35 -0
  295. data/lib/decidim/map/provider/static_map/osm.rb +29 -0
  296. data/lib/decidim/map/static_map.rb +133 -0
  297. data/lib/decidim/map/utility.rb +38 -0
  298. data/lib/decidim/newsletter_participant.rb +2 -4
  299. data/lib/decidim/organization_settings.rb +267 -0
  300. data/lib/decidim/paddable.rb +11 -4
  301. data/lib/decidim/resource_manifest.rb +1 -1
  302. data/lib/decidim/scopable.rb +9 -6
  303. data/lib/decidim/scopable_component.rb +29 -1
  304. data/lib/decidim/scopable_participatory_space.rb +19 -0
  305. data/lib/decidim/scopable_resource.rb +21 -0
  306. data/lib/decidim/search_resource_fields_mapper.rb +17 -4
  307. data/lib/decidim/searchable.rb +6 -0
  308. data/lib/decidim/settings_manifest.rb +2 -1
  309. data/lib/decidim/shareable_with_token.rb +27 -0
  310. data/lib/decidim/snippets.rb +30 -0
  311. data/lib/decidim/translatable_attributes.rb +42 -4
  312. data/lib/decidim/translatable_resource.rb +78 -0
  313. data/lib/decidim/view_model.rb +1 -0
  314. data/lib/premailer/adapter/decidim.rb +33 -0
  315. data/lib/tasks/decidim_locales_tasks.rake +35 -0
  316. data/lib/tasks/decidim_tasks.rake +1 -0
  317. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.bg.js +14 -0
  318. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.da.js +14 -0
  319. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.eo.js +17 -0
  320. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.et.js +18 -0
  321. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.fr-CA.js +16 -0
  322. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ga.js +15 -0
  323. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.hr.js +13 -0
  324. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.is.js +14 -0
  325. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ja.js +16 -0
  326. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.lt.js +16 -0
  327. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.lv.js +17 -0
  328. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.mt.js +15 -0
  329. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.sl.js +14 -0
  330. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.sr.js +16 -0
  331. metadata +149 -30
  332. data/app/cells/decidim/tos_page/sticky_form.erb +0 -29
  333. data/app/helpers/decidim/multi_translation_helper.rb +0 -0
  334. data/lib/decidim/hashtaggable.rb +0 -24
@@ -0,0 +1 @@
1
+ zh-TW:
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddEnableMachineTranslationToDecidimOrganizations < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :decidim_organizations, :enable_machine_translations, :boolean, default: false
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimShareTokens < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :decidim_share_tokens do |t|
6
+ t.references :decidim_organization, null: false, index: true
7
+ t.references :decidim_user, null: false, index: true
8
+ t.references :token_for, polymorphic: true, null: false, index: { name: "decidim_share_tokens_token_for" }
9
+ t.string :token, null: false
10
+ t.integer :times_used, default: 0
11
+ t.datetime :created_at
12
+ t.datetime :last_used_at
13
+ t.datetime :expires_at
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddCommentsMaxLengthToDecidimOrganization < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :decidim_organizations, :comments_max_length, :integer, default: 1000
6
+ end
7
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddFileUploadSettingsToDecidimOrganizations < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :decidim_organizations, :file_upload_settings, :jsonb
6
+
7
+ reversible do |dir|
8
+ dir.up do
9
+ Decidim.configure do |config|
10
+ # Even when these configurations have been deleted, they are available
11
+ # in the config object if they are defined by the initializer.
12
+ attachment_size = config.fetch(:maximum_attachment_size, 10.megabytes)
13
+ avatar_size = config.fetch(:maximum_avatar_size, 5.megabytes)
14
+
15
+ # Update all organizations with the default file upload settings.
16
+ Decidim::Organization.all.each do |organization|
17
+ organization.update(
18
+ file_upload_settings: default_settings.merge(
19
+ "maximum_file_size" => {
20
+ "default" => attachment_size / 1.megabyte,
21
+ "avatar" => avatar_size / 1.megabyte
22
+ }
23
+ )
24
+ )
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def default_settings
34
+ Decidim::OrganizationSettings.default(:upload)
35
+ end
36
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddMachineTranslationDisplayPriorityToOrganizations < ActiveRecord::Migration[5.2]
4
+ class Organization < ApplicationRecord
5
+ self.table_name = "decidim_organizations"
6
+ end
7
+
8
+ def change
9
+ add_column :decidim_organizations, :machine_translation_display_priority, :string
10
+
11
+ Organization.reset_column_information
12
+ Organization.update_all(machine_translation_display_priority: :original) # rubocop:disable Rails/SkipsModelValidations
13
+
14
+ change_column_default :decidim_organizations, :machine_translation_display_priority, "original"
15
+ change_column_null :decidim_organizations, :machine_translation_display_priority, false
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RemoveNotificationsWithContinuityBadge < ActiveRecord::Migration[5.2]
4
+ def up
5
+ Decidim::Notification.where("extra->>'badge_name' =?", "continuity").delete_all
6
+ end
7
+
8
+ def down; end
9
+ end
data/db/seeds.rb CHANGED
@@ -16,6 +16,9 @@ if !Rails.env.production? || ENV["SEED"]
16
16
  table.tr("_", "/").classify.safe_constantize
17
17
  end.compact.each(&:reset_column_information)
18
18
 
19
+ smtp_label = Faker::Twitter.unique.screen_name
20
+ smtp_email = Faker::Internet.email
21
+
19
22
  organization = Decidim::Organization.first || Decidim::Organization.create!(
20
23
  name: Faker::Company.name,
21
24
  twitter_handler: Faker::Hipster.word,
@@ -24,7 +27,9 @@ if !Rails.env.production? || ENV["SEED"]
24
27
  youtube_handler: Faker::Hipster.word,
25
28
  github_handler: Faker::Hipster.word,
26
29
  smtp_settings: {
27
- from: Faker::Internet.email,
30
+ from: "#{smtp_label} <#{smtp_email}>",
31
+ from_email: smtp_email,
32
+ from_label: smtp_label,
28
33
  user_name: Faker::Twitter.unique.screen_name,
29
34
  encrypted_password: Decidim::AttributeEncryptor.encrypt(Faker::Internet.password(8)),
30
35
  address: ENV["DECIDIM_HOST"] || "localhost",
@@ -42,7 +47,8 @@ if !Rails.env.production? || ENV["SEED"]
42
47
  tos_version: Time.current,
43
48
  badges_enabled: true,
44
49
  user_groups_enabled: true,
45
- send_welcome_notification: true
50
+ send_welcome_notification: true,
51
+ file_upload_settings: Decidim::OrganizationSettings.default(:upload)
46
52
  )
47
53
 
48
54
  if organization.top_scopes.none?
@@ -172,7 +178,7 @@ if !Rails.env.production? || ENV["SEED"]
172
178
  email: Faker::Internet.email,
173
179
  confirmed_at: Time.current,
174
180
  extended_data: {
175
- document_number: Faker::Number.number(10),
181
+ document_number: Faker::Number.number(10).to_s,
176
182
  phone: Faker::PhoneNumber.phone_number,
177
183
  verified_at: verified_at
178
184
  },
@@ -188,13 +194,13 @@ if !Rails.env.production? || ENV["SEED"]
188
194
  end
189
195
 
190
196
  Decidim::OAuthApplication.create!(
197
+ organization: organization,
191
198
  name: "Test OAuth application",
192
199
  organization_name: "Example organization",
193
200
  organization_url: "http://www.example.org",
194
- organization_logo: File.new(File.join(seeds_root, "homepage_image.jpg")),
201
+ organization_logo: File.new(File.join(seeds_root, "homepage_image.jpg")), # Keep after organization
195
202
  redirect_uri: "https://www.example.org/oauth/decidim",
196
- scopes: "public",
197
- organization: organization
203
+ scopes: "public"
198
204
  )
199
205
 
200
206
  Decidim::System::CreateDefaultContentBlocks.call(organization)
@@ -12,11 +12,25 @@ module Decidim
12
12
  belongs_to :author, polymorphic: true, foreign_key: "decidim_author_id", foreign_type: "decidim_author_type"
13
13
  belongs_to :user_group, foreign_key: "decidim_user_group_id", class_name: "Decidim::UserGroup", optional: true
14
14
 
15
+ scope :official_origin, lambda {
16
+ where(decidim_author_type: "Decidim::Organization")
17
+ }
18
+
19
+ scope :user_group_origin, lambda {
20
+ where(decidim_author_type: "Decidim::UserBaseEntity")
21
+ .where.not(decidim_user_group_id: nil)
22
+ }
23
+
24
+ scope :citizens_origin, lambda {
25
+ where(decidim_author_type: "Decidim::UserBaseEntity")
26
+ .where(decidim_user_group_id: nil)
27
+ }
28
+
15
29
  validates :author, presence: true
16
30
  validate :verified_user_group, :user_group_membership
17
31
  validate :author_belongs_to_organization
18
32
 
19
- # Checks whether the user is author of the given proposal, either directly
33
+ # Checks whether the user is author of the given resource, either directly
20
34
  # authoring it or via a user group.
21
35
  #
22
36
  # user - the user to check for authorship
@@ -32,6 +46,13 @@ module Decidim
32
46
  user_group || author
33
47
  end
34
48
 
49
+ # Public: Checks whether the resource is official or not.
50
+ #
51
+ # Returns a boolean.
52
+ def official?
53
+ decidim_author_type == Decidim::Organization.name
54
+ end
55
+
35
56
  private
36
57
 
37
58
  def verified_user_group
@@ -37,6 +37,7 @@ module Decidim
37
37
 
38
38
  def input_field(name, type)
39
39
  return hidden_field(name) if name.to_s == "handler_name"
40
+ return scopes_selector if name.to_s == "scope_id"
40
41
 
41
42
  case type.name
42
43
  when "Date", "Time"
@@ -46,6 +47,12 @@ module Decidim
46
47
  end
47
48
  end
48
49
 
50
+ def scopes_selector
51
+ return if object.user.blank?
52
+
53
+ collection_select :scope_id, object.user.organization.scopes, :id, ->(scope) { translated_attribute(scope.name) }
54
+ end
55
+
49
56
  def find_input_type(name)
50
57
  found_attribute = object.class.attribute_set.detect do |attribute|
51
58
  attribute.name.to_s == name
@@ -23,6 +23,28 @@ module Decidim
23
23
  scope :from_author, ->(author) { from_all_author_identities(author).where("decidim_coauthorships.decidim_user_group_id": nil) }
24
24
  # retrieves models from the given UserGroup.
25
25
  scope :from_user_group, ->(user_group) { joins(:coauthorships).where("decidim_coauthorships.decidim_user_group_id": user_group.id) }
26
+ scope :official_origin, lambda {
27
+ where.not(coauthorships_count: 0)
28
+ .joins(:coauthorships)
29
+ .where(decidim_coauthorships: { decidim_author_type: "Decidim::Organization" })
30
+ }
31
+ scope :citizens_origin, lambda {
32
+ where.not(coauthorships_count: 0)
33
+ .joins(:coauthorships)
34
+ .where.not(decidim_coauthorships: { decidim_author_type: "Decidim::Organization" })
35
+ .where(decidim_coauthorships: { decidim_user_group_id: nil })
36
+ }
37
+ scope :user_group_origin, lambda {
38
+ where.not(coauthorships_count: 0)
39
+ .joins(:coauthorships)
40
+ .where(decidim_coauthorships: { decidim_author_type: "Decidim::UserBaseEntity" })
41
+ .where.not(decidim_coauthorships: { decidim_user_group_id: nil })
42
+ }
43
+ scope :meeting_origin, lambda {
44
+ where.not(coauthorships_count: 0)
45
+ .joins(:coauthorships)
46
+ .where(decidim_coauthorships: { decidim_author_type: "Decidim::Meetings::Meeting" })
47
+ }
26
48
 
27
49
  validates :coauthorships, presence: true
28
50
 
@@ -108,7 +108,7 @@ module Decidim
108
108
  def run_hooks(event_name, context = nil)
109
109
  return unless hooks[event_name]
110
110
 
111
- hooks[event_name.to_sym].each do |hook|
111
+ hooks[event_name.to_sym].map do |hook|
112
112
  hook.call(context)
113
113
  end
114
114
  end
@@ -51,52 +51,75 @@ module Decidim
51
51
  #
52
52
  # @return [Result] a Result object with the content rewritten and the metadata
53
53
  def self.parse(content, context)
54
- parsed = Decidim.content_processors.each_with_object(rewrite: content, metadata: {}) do |type, result|
55
- parser = parser_klass(type).constantize.new(result[:rewrite], context)
56
- result[:rewrite] = parser.rewrite
57
- result[:metadata][type] = parser.metadata
54
+ Decidim.content_processors.each_with_object(Result.new(content, {})) do |type, result|
55
+ parse_with_processor(type, result, context)
58
56
  end
59
-
60
- Result.new(parsed[:rewrite], parsed[:metadata])
61
57
  end
62
58
 
63
- def self.parse_with_processor(_type, content, context)
64
- parsed = if content.is_a?(Hash)
65
- Decidim.content_processors.each_with_object(rewrite: content, metadata: {}) do |type, result|
66
- next unless type == :hashtag
67
-
68
- result[:rewrite].each do |key, value|
69
- parser = parser_klass(type).constantize.new(value, context)
70
- result[:rewrite][key] = parser.rewrite
71
- result[:metadata][type] = parser.metadata
72
- end
73
- end
59
+ # Public: Calls the specified processors to process the given content with
60
+ # it. For example, to convert hashtags to its Global ID representation.
61
+ #
62
+ # @param type [String] the name of the processor to use.
63
+ # @param content [String] already rewritten content or regular content
64
+ # @param context [Hash] with information to inject to the parsers as context
65
+ #
66
+ # @return [Result] a Result object with the content rewritten and the metadata
67
+ def self.parse_with_processor(type, content, context)
68
+ result = if content.is_a?(Result)
69
+ content
74
70
  else
75
- Decidim.content_processors.each_with_object(rewrite: content, metadata: {}) do |type, result|
76
- next unless type == :hashtag
77
-
78
- parser = parser_klass(type).constantize.new(result[:rewrite], context)
79
- result[:rewrite] = parser.rewrite
80
- result[:metadata][type] = parser.metadata
81
- end
71
+ Result.new(content, {})
82
72
  end
83
- Result.new(parsed[:rewrite], parsed[:metadata])
73
+
74
+ if result.rewrite.is_a?(Hash)
75
+ result.rewrite.each do |key, value|
76
+ child_result = Result.new(value, {})
77
+ child_result = parse_with_processor(type, child_result, context)
78
+
79
+ result.rewrite.update(key => child_result.rewrite)
80
+ result.metadata.update(child_result.metadata)
81
+ end
82
+ else
83
+ parser = parser_klass(type).constantize.new(result.rewrite, context)
84
+ result.rewrite = parser.rewrite
85
+ result.metadata.update(type => parser.metadata)
86
+ end
87
+
88
+ result
84
89
  end
85
90
 
86
91
  # This calls all registered processors one after the other and returns
87
92
  # the processed content ready to display.
88
93
  #
94
+ # @param content [String] with the content to be rendered.
95
+ # @param wrapper_tag [String] with the HTML tag to wrap the content.
96
+ # @param options [Hash] with options to pass to the renderer.
97
+ #
89
98
  # @return [String] the content processed and ready to display (it is expected to include HTML)
90
- def self.render(content, wrapper_tag = "p")
99
+ def self.render(content, wrapper_tag = "p", options = {})
91
100
  simple_format(
92
- Decidim.content_processors.reduce(content) do |result, type|
93
- renderer_klass(type).constantize.new(result).render
94
- end,
101
+ render_without_format(content, options),
95
102
  {},
96
103
  wrapper_tag: wrapper_tag
97
104
  )
98
105
  end
99
106
 
107
+ # This calls all registered processors one after the other and returns
108
+ # the processed content ready to display without wrapping the content in
109
+ # HTML.
110
+ #
111
+ # @param content [String] with the content to be rendered.
112
+ # @param options [Hash] with options to pass to the renderer.
113
+ #
114
+ # @return [String] the content processed and ready to display.
115
+ def self.render_without_format(content, options = {})
116
+ return content if content.blank?
117
+
118
+ Decidim.content_processors.reduce(content) do |result, type|
119
+ renderer_klass(type).constantize.new(result).render(options)
120
+ end
121
+ end
122
+
100
123
  # This method overwrites the views `sanitize` method. This is required to
101
124
  # ensure the content does not include any weird HTML that could harm the end
102
125
  # user.
@@ -29,7 +29,7 @@ module Decidim
29
29
  #
30
30
  # @abstract Subclass is expected to implement it
31
31
  # @return [String] the content processed and ready to display
32
- def render
32
+ def render(_options = nil)
33
33
  content
34
34
  end
35
35
  end
@@ -21,6 +21,8 @@ module Decidim
21
21
  #
22
22
  # @return [String] the content ready to display (contains HTML)
23
23
  def render(links: true, extras: true)
24
+ return content unless content.respond_to?(:gsub)
25
+
24
26
  content.gsub(GLOBAL_ID_REGEX) do |hashtag_gid|
25
27
  id, extra, cased_name = hashtag_gid.scan(GLOBAL_ID_REGEX).flatten
26
28
  hashtag = hashtags[id.to_i]
@@ -16,7 +16,10 @@ module Decidim
16
16
  # @see BaseRenderer Examples of how to use a content renderer
17
17
  class LinkRenderer < BaseRenderer
18
18
  # @return [String] the content ready to display (contains HTML)
19
- def render(options = { target: "_blank", rel: "nofollow noopener" })
19
+ def render(options = {})
20
+ return content unless content.is_a?(String)
21
+
22
+ options = { target: "_blank", rel: "nofollow noopener" }.merge(options)
20
23
  Anchored::Linker.auto_link(content, options)
21
24
  end
22
25
  end
@@ -17,7 +17,9 @@ module Decidim
17
17
  # invalid Decidim::UserGroup are replaced with an empty string.
18
18
  #
19
19
  # @return [String] the content ready to display (contains HTML)
20
- def render
20
+ def render(_options = nil)
21
+ return content unless content.respond_to?(:gsub)
22
+
21
23
  content.gsub(GLOBAL_ID_REGEX) do |user_gid|
22
24
  user = GlobalID::Locator.locate(user_gid)
23
25
  Decidim::UserGroupPresenter.new(user).display_mention
@@ -17,7 +17,9 @@ module Decidim
17
17
  # invalid Decidim::User are replaced with an empty string.
18
18
  #
19
19
  # @return [String] the content ready to display (contains HTML)
20
- def render
20
+ def render(_options = nil)
21
+ return content unless content.respond_to?(:gsub)
22
+
21
23
  content.gsub(GLOBAL_ID_REGEX) do |user_gid|
22
24
  user = GlobalID::Locator.locate(user_gid)
23
25
  Decidim::UserPresenter.new(user).display_mention
data/lib/decidim/core.rb CHANGED
@@ -8,6 +8,7 @@ module Decidim
8
8
  autoload :Deprecations, "decidim/deprecations"
9
9
  autoload :ActsAsAuthor, "decidim/acts_as_author"
10
10
  autoload :TranslatableAttributes, "decidim/translatable_attributes"
11
+ autoload :TranslatableResource, "decidim/translatable_resource"
11
12
  autoload :JsonbAttributes, "decidim/jsonb_attributes"
12
13
  autoload :FormBuilder, "decidim/form_builder"
13
14
  autoload :AuthorizationFormBuilder, "decidim/authorization_form_builder"
@@ -24,7 +25,9 @@ module Decidim
24
25
  autoload :Participable, "decidim/participable"
25
26
  autoload :Publicable, "decidim/publicable"
26
27
  autoload :Scopable, "decidim/scopable"
28
+ autoload :ScopableParticipatorySpace, "decidim/scopable_participatory_space"
27
29
  autoload :ScopableComponent, "decidim/scopable_component"
30
+ autoload :ScopableResource, "decidim/scopable_resource"
28
31
  autoload :ContentParsers, "decidim/content_parsers"
29
32
  autoload :ContentRenderers, "decidim/content_renderers"
30
33
  autoload :ContentProcessor, "decidim/content_processor"
@@ -74,7 +77,6 @@ module Decidim
74
77
  autoload :Amendable, "decidim/amendable"
75
78
  autoload :Gamification, "decidim/gamification"
76
79
  autoload :Hashtag, "decidim/hashtag"
77
- autoload :Hashtaggable, "decidim/hashtaggable"
78
80
  autoload :Paddable, "decidim/paddable"
79
81
  autoload :OpenDataExporter, "decidim/open_data_exporter"
80
82
  autoload :IoEncoder, "decidim/io_encoder"
@@ -83,6 +85,13 @@ module Decidim
83
85
  autoload :Randomable, "decidim/randomable"
84
86
  autoload :Endorsable, "decidim/endorsable"
85
87
  autoload :ActionAuthorization, "decidim/action_authorization"
88
+ autoload :Map, "decidim/map"
89
+ autoload :Geocodable, "decidim/geocodable"
90
+ autoload :Snippets, "decidim/snippets"
91
+ autoload :OrganizationSettings, "decidim/organization_settings"
92
+ autoload :HasUploadValidations, "decidim/has_upload_validations"
93
+ autoload :FileValidatorHumanizer, "decidim/file_validator_humanizer"
94
+ autoload :ShareableWithToken, "decidim/shareable_with_token"
86
95
 
87
96
  include ActiveSupport::Configurable
88
97
  # Loads seeds from all engines.
@@ -140,7 +149,7 @@ module Decidim
140
149
 
141
150
  # Exposes a configuration option: The application available locales.
142
151
  config_accessor :available_locales do
143
- %w(en ar ca de el es es-MX es-PY eu fi-pl fi fr gl hu id it nl no pl pt pt-BR ro ru sk sv tr uk)
152
+ %w(en bg ar ca cs da de el eo es es-MX es-PY et eu fi-pl fi fr fr-CA ga gl hr hu id is it ja lt lv mt nl no pl pt pt-BR ro ru sk sl sr sv tr uk)
144
153
  end
145
154
 
146
155
  # Exposes a configuration option: The application default locale.
@@ -168,6 +177,10 @@ module Decidim
168
177
  # Exposes a configuration option: an object to configure geocoder
169
178
  config_accessor :geocoder
170
179
 
180
+ # Exposes a configuration option: an object to configure the mapping
181
+ # functionality. See Decidim::Map for more information.
182
+ config_accessor :maps
183
+
171
184
  # Exposes a configuration option: a custom method to generate references.
172
185
  # If overwritten, it should handle both component resources and participatory spaces.
173
186
  # Default: Calculates a unique reference for the model in
@@ -214,16 +227,6 @@ module Decidim
214
227
  80
215
228
  end
216
229
 
217
- # Exposes a configuration option: The maximum file size of an attachment.
218
- config_accessor :maximum_attachment_size do
219
- 10.megabytes
220
- end
221
-
222
- # Exposes a configuration option: The maximum file size for user avatar images.
223
- config_accessor :maximum_avatar_size do
224
- 5.megabytes
225
- end
226
-
227
230
  # The number of reports which a resource can receive before hiding it
228
231
  config_accessor :max_reports_before_hiding do
229
232
  3
@@ -259,6 +262,11 @@ module Decidim
259
262
  2.days
260
263
  end
261
264
 
265
+ # Allow machine translations
266
+ config_accessor :enable_machine_translations do
267
+ false
268
+ end
269
+
262
270
  # How long can a user remained logged in before the session expires
263
271
  config_accessor :expire_session_after do
264
272
  1.day
@@ -303,6 +311,12 @@ module Decidim
303
311
  # "MyPDFSignatureService"
304
312
  end
305
313
 
314
+ # The name of the class to translate user content.
315
+ #
316
+ config_accessor :machine_translation_service do
317
+ # "MyTranslationService"
318
+ end
319
+
306
320
  # The Decidim::Exporters::CSV's default column separator
307
321
  config_accessor :default_csv_col_sep do
308
322
  ";"
@@ -331,6 +345,18 @@ module Decidim
331
345
  %w(all participants)
332
346
  end
333
347
 
348
+ # Exposes a configuration option: The maximum length for conversation
349
+ # messages.
350
+ config_accessor :maximum_conversation_message_length do
351
+ 1_000
352
+ end
353
+
354
+ # Defines the name of the cookie used to check if the user allows Decidim to
355
+ # set cookies.
356
+ config_accessor :consent_cookie_name do
357
+ "decidim-cc"
358
+ end
359
+
334
360
  # Public: Registers a global engine. This method is intended to be used
335
361
  # by component engines that also offer unscoped functionality
336
362
  #
@@ -515,4 +541,33 @@ module Decidim
515
541
  def self.metrics_operation
516
542
  @metrics_operation ||= MetricOperation.new
517
543
  end
544
+
545
+ # Public: Returns the correct settings object for the given organization or
546
+ # the default settings object when the organization cannot be determined. The
547
+ # model to be passed to this method can be any model that responds to the
548
+ # `organization` method or the organization itself. If the given model is not
549
+ # an organization or does not respond to the organization method, returns the
550
+ # default organization settings.
551
+ #
552
+ # model - The target model for which to fetch the settings object, either an
553
+ # organization or a model responding to the `organization` method.
554
+ #
555
+ def self.organization_settings(model)
556
+ organization = begin
557
+ if model.is_a?(Decidim::Organization)
558
+ model
559
+ elsif model.respond_to?(:organization)
560
+ model.organization
561
+ end
562
+ end
563
+ return Decidim::OrganizationSettings.defaults unless organization
564
+
565
+ Decidim::OrganizationSettings.for(organization)
566
+ end
567
+
568
+ def self.machine_translation_service_klass
569
+ return unless Decidim.enable_machine_translations
570
+
571
+ Decidim.machine_translation_service.to_s.safe_constantize
572
+ end
518
573
  end