decidim-core 0.23.6 → 0.24.0.rc1

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

Potentially problematic release.


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

Files changed (455) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/assets/images/decidim/icons.svg +1 -1
  4. data/app/assets/javascripts/decidim/core/bundle.js +1 -1
  5. data/app/assets/javascripts/decidim/core/bundle.js.map +1 -1
  6. data/app/assets/javascripts/decidim/editor/history_override.js.es6 +117 -0
  7. data/app/assets/javascripts/decidim/editor/linebreak_module.js.es6 +83 -0
  8. data/app/assets/javascripts/decidim/editor/modified_backspace_offset1.js.es6 +98 -0
  9. data/app/assets/javascripts/decidim/editor/modified_backspace_offset_any.js.es6 +48 -0
  10. data/app/assets/javascripts/decidim/editor/modified_backspace_utils.js.es6 +31 -0
  11. data/app/assets/javascripts/decidim/editor/modified_enter.js.es6 +118 -0
  12. data/app/assets/javascripts/decidim/editor.js.es6 +15 -4
  13. data/app/assets/javascripts/decidim/form_filter.component.js.es6 +25 -0
  14. data/app/assets/javascripts/decidim/geocoding/attach_input.js.es6 +41 -4
  15. data/app/assets/javascripts/decidim/input_character_counter.js.es6 +6 -1
  16. data/app/assets/javascripts/decidim/map/controller/markers.js.es6 +27 -9
  17. data/app/assets/javascripts/decidim/session_timeouter.js.es6 +78 -0
  18. data/app/assets/javascripts/decidim.js.es6 +1 -0
  19. data/app/assets/stylesheets/decidim/_variables.scss +9 -0
  20. data/app/assets/stylesheets/decidim/email.scss +14 -2
  21. data/app/assets/stylesheets/decidim/extras/_external-links.scss +0 -1
  22. data/app/assets/stylesheets/decidim/extras/_process_stats.scss +1 -1
  23. data/app/assets/stylesheets/decidim/extras/_results-per-page.scss +1 -0
  24. data/app/assets/stylesheets/decidim/modules/_author-avatar.scss +2 -2
  25. data/app/assets/stylesheets/decidim/modules/_buttons.scss +2 -2
  26. data/app/assets/stylesheets/decidim/modules/_cards.scss +18 -1
  27. data/app/assets/stylesheets/decidim/modules/_collapsible-list.scss +1 -1
  28. data/app/assets/stylesheets/decidim/modules/_comments.scss +5 -1
  29. data/app/assets/stylesheets/decidim/modules/_conference-speaker.scss +4 -3
  30. data/app/assets/stylesheets/decidim/modules/_data-picker.scss +7 -0
  31. data/app/assets/stylesheets/decidim/modules/_extra.scss +4 -0
  32. data/app/assets/stylesheets/decidim/modules/_forms.scss +4 -0
  33. data/app/assets/stylesheets/decidim/modules/_loading-spinner.scss +34 -0
  34. data/app/assets/stylesheets/decidim/modules/_modules.scss +1 -1
  35. data/app/assets/stylesheets/decidim/modules/_opinion-toggle.scss +1 -1
  36. data/app/assets/stylesheets/decidim/modules/_reveal.scss +6 -0
  37. data/app/assets/stylesheets/decidim/modules/_signup.scss +1 -0
  38. data/app/assets/stylesheets/decidim/modules/{_process-stats.scss → _space-stats.scss} +1 -1
  39. data/app/cells/decidim/activity/show.erb +1 -1
  40. data/app/cells/decidim/activity_cell.rb +11 -14
  41. data/app/cells/decidim/address/details.erb +5 -5
  42. data/app/cells/decidim/address_cell.rb +0 -21
  43. data/app/cells/decidim/announcement/show.erb +4 -4
  44. data/app/cells/decidim/announcement_cell.rb +22 -2
  45. data/app/cells/decidim/author/flag_user.erb +10 -0
  46. data/app/cells/decidim/author/profile_minicard.erb +1 -1
  47. data/app/cells/decidim/author_cell.rb +9 -1
  48. data/app/cells/decidim/card_m/top.erb +1 -1
  49. data/app/cells/decidim/card_m_cell.rb +1 -1
  50. data/app/cells/decidim/content_blocks/cta/show.erb +14 -0
  51. data/app/cells/decidim/content_blocks/cta_cell.rb +35 -0
  52. data/app/cells/decidim/content_blocks/cta_settings_form/show.erb +9 -0
  53. data/app/cells/decidim/content_blocks/cta_settings_form_cell.rb +13 -0
  54. data/app/cells/decidim/content_blocks/hero_cell.rb +14 -0
  55. data/app/cells/decidim/content_blocks/highlighted_elements/elements.erb +0 -0
  56. data/app/cells/decidim/content_blocks/highlighted_elements/heading.erb +0 -0
  57. data/app/cells/decidim/content_blocks/highlighted_elements/show.erb +4 -0
  58. data/app/cells/decidim/content_blocks/highlighted_elements_cell.rb +51 -0
  59. data/app/cells/decidim/content_blocks/highlighted_elements_settings_form/show.erb +3 -0
  60. data/app/cells/decidim/content_blocks/highlighted_elements_settings_form_cell.rb +28 -0
  61. data/app/cells/decidim/content_blocks/last_activity_cell.rb +11 -0
  62. data/app/cells/decidim/content_blocks/metrics_cell.rb +0 -6
  63. data/app/cells/decidim/content_blocks/stats_cell.rb +0 -6
  64. data/app/cells/decidim/date/show.erb +31 -0
  65. data/app/cells/decidim/date_cell.rb +50 -0
  66. data/app/cells/decidim/endorsement_buttons_cell.rb +3 -3
  67. data/app/cells/decidim/flag_modal/flag_user.erb +24 -0
  68. data/app/cells/decidim/flag_modal/show.erb +24 -0
  69. data/app/cells/decidim/flag_modal_cell.rb +25 -0
  70. data/app/cells/decidim/profile/inaccessible.erb +9 -0
  71. data/app/cells/decidim/profile_cell.rb +9 -1
  72. data/app/cells/decidim/profile_sidebar/show.erb +10 -1
  73. data/app/cells/decidim/profile_sidebar_cell.rb +1 -0
  74. data/app/cells/decidim/reported_content/show.erb +5 -0
  75. data/app/cells/decidim/reported_content_cell.rb +44 -0
  76. data/app/cells/decidim/scopes_picker/scope_picker_prompt.erb +3 -0
  77. data/app/cells/decidim/scopes_picker/scope_picker_values.erb +5 -0
  78. data/app/cells/decidim/scopes_picker/show.erb +14 -0
  79. data/app/cells/decidim/scopes_picker_cell.rb +93 -0
  80. data/app/cells/decidim/tos_page/announcement.erb +1 -1
  81. data/app/cells/decidim/tos_page/form.erb +15 -13
  82. data/app/cells/decidim/tos_page_cell.rb +10 -8
  83. data/app/cells/decidim/translation_bar_cell.rb +1 -1
  84. data/app/cells/decidim/user_conversation/conversation_header.erb +1 -1
  85. data/app/cells/decidim/user_conversations_cell.rb +1 -1
  86. data/app/commands/decidim/create_report.rb +11 -1
  87. data/app/commands/decidim/create_user_report.rb +67 -0
  88. data/app/commands/decidim/destroy_account.rb +0 -2
  89. data/app/commands/decidim/gallery_methods.rb +2 -2
  90. data/app/commands/decidim/multiple_attachments_methods.rb +14 -10
  91. data/app/commands/decidim/search.rb +5 -2
  92. data/app/commands/decidim/update_notifications_settings.rb +1 -0
  93. data/app/commands/decidim/update_user_group.rb +1 -0
  94. data/app/controllers/concerns/decidim/devise_controllers.rb +1 -1
  95. data/app/controllers/concerns/decidim/flaggable.rb +5 -1
  96. data/app/controllers/concerns/decidim/force_authentication.rb +11 -3
  97. data/app/controllers/concerns/decidim/locale_switcher.rb +5 -0
  98. data/app/controllers/concerns/decidim/needs_permission.rb +7 -1
  99. data/app/controllers/concerns/decidim/orderable.rb +3 -1
  100. data/app/controllers/concerns/decidim/user_blocked_checker.rb +26 -0
  101. data/app/controllers/decidim/application_controller.rb +22 -0
  102. data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +3 -1
  103. data/app/controllers/decidim/devise/sessions_controller.rb +10 -6
  104. data/app/controllers/decidim/errors_controller.rb +1 -1
  105. data/app/controllers/decidim/locales_controller.rb +1 -1
  106. data/app/controllers/decidim/profiles_controller.rb +6 -0
  107. data/app/controllers/decidim/report_users_controller.rb +42 -0
  108. data/app/controllers/decidim/scopes_controller.rb +19 -10
  109. data/app/controllers/decidim/timeouts_controller.rb +28 -0
  110. data/app/controllers/decidim/user_activities_controller.rb +5 -0
  111. data/app/controllers/decidim/user_timeline_controller.rb +1 -0
  112. data/app/events/decidim/demoted_membership_event.rb +2 -2
  113. data/app/events/decidim/invited_to_group_event.rb +2 -2
  114. data/app/events/decidim/join_request_accepted_event.rb +2 -2
  115. data/app/events/decidim/join_request_created_event.rb +2 -2
  116. data/app/events/decidim/join_request_rejected_event.rb +2 -2
  117. data/app/events/decidim/promoted_to_admin_event.rb +2 -2
  118. data/app/events/decidim/removed_from_group_event.rb +2 -2
  119. data/app/forms/decidim/account_form.rb +2 -2
  120. data/app/forms/decidim/invite_user_form.rb +2 -2
  121. data/app/forms/decidim/messaging/conversation_form.rb +1 -1
  122. data/app/forms/decidim/messaging/message_form.rb +1 -1
  123. data/app/forms/decidim/notifications_settings_form.rb +20 -0
  124. data/app/forms/url_validator.rb +20 -0
  125. data/app/helpers/decidim/action_authorization_helper.rb +2 -0
  126. data/app/helpers/decidim/application_helper.rb +1 -3
  127. data/app/helpers/decidim/cells_helper.rb +6 -0
  128. data/app/helpers/decidim/filters_helper.rb +9 -0
  129. data/app/helpers/decidim/messaging/conversation_helper.rb +11 -1
  130. data/app/helpers/decidim/newsletters_helper.rb +7 -9
  131. data/app/helpers/decidim/scopes_helper.rb +1 -1
  132. data/app/jobs/decidim/block_user_job.rb +11 -0
  133. data/app/jobs/decidim/export_job.rb +2 -2
  134. data/app/jobs/decidim/find_and_update_descendants_job.rb +48 -0
  135. data/app/jobs/decidim/machine_translation_resource_job.rb +3 -0
  136. data/app/jobs/decidim/machine_translation_save_job.rb +29 -0
  137. data/app/jobs/decidim/update_search_indexes_job.rb +11 -0
  138. data/app/jobs/decidim/user_report_job.rb +11 -0
  139. data/app/mailers/decidim/block_user_mailer.rb +21 -0
  140. data/app/mailers/decidim/reported_mailer.rb +33 -3
  141. data/app/mailers/decidim/user_report_mailer.rb +21 -0
  142. data/app/models/decidim/area.rb +0 -1
  143. data/app/models/decidim/area_type.rb +1 -1
  144. data/app/models/decidim/attachment.rb +3 -2
  145. data/app/models/decidim/attachment_collection.rb +1 -1
  146. data/app/models/decidim/authorization.rb +4 -0
  147. data/app/models/decidim/category.rb +6 -1
  148. data/app/models/decidim/impersonation_log.rb +5 -7
  149. data/app/models/decidim/metric.rb +2 -2
  150. data/app/models/decidim/moderation.rb +12 -0
  151. data/app/models/decidim/organization.rb +5 -1
  152. data/app/models/decidim/scope.rb +5 -2
  153. data/app/models/decidim/scope_type.rb +1 -1
  154. data/app/models/decidim/share_token.rb +1 -1
  155. data/app/models/decidim/static_page.rb +11 -1
  156. data/app/models/decidim/static_page_topic.rb +4 -0
  157. data/app/models/decidim/user.rb +13 -8
  158. data/app/models/decidim/user_base_entity.rb +13 -13
  159. data/app/models/decidim/user_block.rb +10 -0
  160. data/app/models/decidim/user_group.rb +1 -4
  161. data/app/models/decidim/user_moderation.rb +22 -0
  162. data/app/models/decidim/user_report.rb +31 -0
  163. data/app/permissions/decidim/permissions.rb +1 -3
  164. data/app/permissions/decidim/report_user_permissions.rb +13 -0
  165. data/app/presenters/decidim/admin_log/impersonation_log_presenter.rb +39 -0
  166. data/app/presenters/decidim/admin_log/organization_presenter.rb +1 -2
  167. data/app/presenters/decidim/admin_log/user_moderation_presenter.rb +63 -0
  168. data/app/presenters/decidim/admin_log/user_presenter.rb +18 -9
  169. data/app/presenters/decidim/home_stats_presenter.rb +3 -3
  170. data/app/presenters/decidim/log/diff_presenter.rb +4 -3
  171. data/app/presenters/decidim/log/resource_presenter.rb +4 -4
  172. data/app/presenters/decidim/log/user_presenter.rb +1 -1
  173. data/app/presenters/decidim/menu_presenter.rb +12 -7
  174. data/app/presenters/decidim/nil_presenter.rb +0 -2
  175. data/app/presenters/decidim/user_presenter.rb +1 -1
  176. data/app/queries/decidim/metrics/blocked_users_metric_manage.rb +26 -0
  177. data/app/queries/decidim/metrics/followers_metric_manage.rb +3 -0
  178. data/app/queries/decidim/metrics/participants_metric_manage.rb +3 -0
  179. data/app/queries/decidim/metrics/reported_users_metric_manage.rb +26 -0
  180. data/app/queries/decidim/metrics/user_reports_metric_manage.rb +26 -0
  181. data/app/queries/decidim/user_groups/accepted_memberships.rb +1 -1
  182. data/app/queries/decidim/user_groups/admin_memberships.rb +1 -1
  183. data/app/queries/decidim/user_groups/member_memberships.rb +1 -1
  184. data/app/services/decidim/activity_search.rb +1 -3
  185. data/app/services/decidim/base_diff_renderer.rb +1 -1
  186. data/app/services/decidim/data_portability_exporter.rb +1 -0
  187. data/app/services/decidim/email_notification_generator.rb +2 -2
  188. data/app/services/decidim/events_manager.rb +1 -1
  189. data/app/services/decidim/open_data_exporter.rb +36 -7
  190. data/app/services/decidim/zip_stream/zip_stream_writer.rb +3 -3
  191. data/app/uploaders/decidim/application_uploader.rb +22 -2
  192. data/app/uploaders/decidim/attachment_uploader.rb +2 -4
  193. data/app/uploaders/decidim/downloader.rb +9 -0
  194. data/app/uploaders/decidim/image_uploader.rb +9 -21
  195. data/app/uploaders/decidim/open_data_uploader.rb +5 -0
  196. data/app/uploaders/decidim/record_image_uploader.rb +2 -2
  197. data/app/validators/etiquette_validator.rb +0 -7
  198. data/app/validators/uploader_content_type_validator.rb +4 -2
  199. data/app/views/decidim/application/_document.html.erb +1 -1
  200. data/app/views/decidim/block_user_mailer/notify.html.erb +7 -0
  201. data/app/views/decidim/devise/confirmations/new.html.erb +1 -1
  202. data/app/views/decidim/devise/registrations/edit.html.erb +1 -1
  203. data/app/views/decidim/devise/unlocks/new.html.erb +1 -1
  204. data/app/views/decidim/messaging/conversations/_conversation.html.erb +1 -1
  205. data/app/views/decidim/messaging/conversations/_messages.html.erb +1 -1
  206. data/app/views/decidim/messaging/conversations/_show.html.erb +4 -4
  207. data/app/views/decidim/notifications_settings/show.html.erb +11 -0
  208. data/app/views/decidim/pages/_standalone.html.erb +3 -1
  209. data/app/views/decidim/reported_mailer/report.html.erb +9 -17
  210. data/app/views/decidim/shared/_check_boxes_tree.html.erb +3 -3
  211. data/app/views/decidim/shared/_component_announcement.html.erb +2 -2
  212. data/app/views/decidim/shared/participatory_space_filters/_filters.html.erb +1 -1
  213. data/app/views/decidim/user_report_mailer/notify.html.erb +7 -0
  214. data/app/views/decidim/widgets/_data_picker.html.erb +1 -1
  215. data/app/views/layouts/decidim/_application.html.erb +1 -0
  216. data/app/views/layouts/decidim/_js_configuration.html.erb +1 -1
  217. data/app/views/layouts/decidim/_main_footer.html.erb +6 -4
  218. data/app/views/layouts/decidim/_timeout_modal.html.erb +21 -0
  219. data/config/initializers/active_support.rb +7 -0
  220. data/config/initializers/devise.rb +1 -1
  221. data/config/initializers/omniauth.rb +1 -1
  222. data/config/locales/ar.yml +1 -7
  223. data/config/locales/bg.yml +1 -13
  224. data/config/locales/ca.yml +46 -17
  225. data/config/locales/cs.yml +118 -53
  226. data/config/locales/de.yml +83 -18
  227. data/config/locales/el.yml +1 -14
  228. data/config/locales/en.yml +79 -14
  229. data/config/locales/eo.yml +0 -1
  230. data/config/locales/es-MX.yml +31 -14
  231. data/config/locales/es-PY.yml +31 -14
  232. data/config/locales/es.yml +34 -17
  233. data/config/locales/eu.yml +4 -10
  234. data/config/locales/fi-plain.yml +80 -16
  235. data/config/locales/fi.yml +85 -21
  236. data/config/locales/fr-CA.yml +79 -14
  237. data/config/locales/fr.yml +76 -11
  238. data/config/locales/gl.yml +1 -15
  239. data/config/locales/hu.yml +1 -12
  240. data/config/locales/id-ID.yml +1 -7
  241. data/config/locales/is-IS.yml +0 -9
  242. data/config/locales/it.yml +72 -19
  243. data/config/locales/ja.yml +1 -14
  244. data/config/locales/lv.yml +1 -12
  245. data/config/locales/nl.yml +38 -13
  246. data/config/locales/no.yml +7 -14
  247. data/config/locales/pl.yml +81 -14
  248. data/config/locales/pt-BR.yml +1 -7
  249. data/config/locales/pt.yml +1 -14
  250. data/config/locales/ro-RO.yml +15 -25
  251. data/config/locales/ru.yml +7 -12
  252. data/config/locales/sk.yml +2 -13
  253. data/config/locales/sr-CS.yml +0 -9
  254. data/config/locales/sv.yml +5 -27
  255. data/config/locales/tr-TR.yml +65 -14
  256. data/config/locales/uk.yml +7 -9
  257. data/config/locales/zh-CN.yml +1 -14
  258. data/config/routes.rb +9 -4
  259. data/db/migrate/20170713131206_add_admin_to_users.rb +1 -1
  260. data/db/migrate/20180206143340_fix_reference_for_all_resources.rb +2 -0
  261. data/db/migrate/20180314085339_rename_maximum_votes_per_proposal_to_threshold_per_proposal.rb +2 -2
  262. data/db/migrate/20200929171508_remove_show_statistics_from_organizations.rb +7 -0
  263. data/db/migrate/20201010124755_create_decidim_user_moderations.rb +12 -0
  264. data/db/migrate/20201010124756_create_decidim_user_reports.rb +16 -0
  265. data/db/migrate/20201010224433_add_suspension_fields_to_decidim_users.rb +8 -0
  266. data/db/migrate/20201011074641_create_decidim_user_suspensions.rb +14 -0
  267. data/db/migrate/20201011081626_add_current_suspension_id_to_decidim_users.rb +7 -0
  268. data/db/migrate/20201013071533_add_reported_content_to_moderations.rb +7 -0
  269. data/db/migrate/20201019074554_add_locale_to_moderation_reports.rb +7 -0
  270. data/db/migrate/20201127114444_encrypt_authorization_metadatas.rb +35 -0
  271. data/db/migrate/20201128130723_add_allow_public_access_to_static_pages.rb +17 -0
  272. data/db/migrate/20201218144706_update_table_block_user_functionality.rb +8 -0
  273. data/db/migrate/20201218145252_rename_decidim_user_fields_for_block_functionality.rb +9 -0
  274. data/db/migrate/20210208134328_add_email_on_moderations_to_users.rb +7 -0
  275. data/db/seeds.rb +14 -13
  276. data/lib/decidim/amendable.rb +3 -2
  277. data/{app/functions/decidim/core → lib/decidim/api/functions}/component_finder_base.rb +1 -1
  278. data/{app/functions/decidim/core → lib/decidim/api/functions}/component_list.rb +4 -4
  279. data/{app/functions/decidim/core → lib/decidim/api/functions}/component_list_base.rb +3 -1
  280. data/lib/decidim/api/functions/needs_api_default_order.rb +24 -0
  281. data/{app/functions/decidim/core → lib/decidim/api/functions}/needs_api_filter_and_order.rb +0 -0
  282. data/{app/functions/decidim/core → lib/decidim/api/functions}/participatory_space_finder_base.rb +2 -2
  283. data/{app/functions/decidim/core → lib/decidim/api/functions}/participatory_space_list_base.rb +3 -1
  284. data/{app/functions/decidim/core → lib/decidim/api/functions}/user_entity_finder.rb +1 -4
  285. data/{app/functions/decidim/core → lib/decidim/api/functions}/user_entity_list.rb +1 -3
  286. data/{app/types/decidim/core → lib/decidim/api/input_filters}/base_input_filter.rb +0 -0
  287. data/{app/types/decidim/core → lib/decidim/api/input_filters}/component_input_filter.rb +20 -22
  288. data/{app/types/decidim/core → lib/decidim/api/input_filters}/has_hastaggable_input_filter.rb +1 -1
  289. data/{app/types/decidim/core → lib/decidim/api/input_filters}/has_localized_input_filter.rb +3 -3
  290. data/{app/types/decidim/core → lib/decidim/api/input_filters}/has_publishable_input_filter.rb +6 -6
  291. data/{app/types/decidim/core → lib/decidim/api/input_filters}/has_timestamp_input_filter.rb +12 -12
  292. data/{app/types/decidim/core → lib/decidim/api/input_filters}/participatory_space_input_filter.rb +0 -1
  293. data/lib/decidim/api/input_filters/user_entity_input_filter.rb +89 -0
  294. data/{app/types/decidim/core → lib/decidim/api/input_sorts}/base_input_sort.rb +3 -2
  295. data/{app/types/decidim/core → lib/decidim/api/input_sorts}/component_input_sort.rb +10 -11
  296. data/{app/types/decidim/core → lib/decidim/api/input_sorts}/has_endorsable_input_sort.rb +2 -4
  297. data/{app/types/decidim/core → lib/decidim/api/input_sorts}/has_localized_input_sort.rb +3 -3
  298. data/{app/types/decidim/core → lib/decidim/api/input_sorts}/has_publishable_input_sort.rb +1 -1
  299. data/lib/decidim/api/input_sorts/has_timestamp_input_sort.rb +12 -0
  300. data/{app/types/decidim/core → lib/decidim/api/input_sorts}/participatory_space_input_sort.rb +1 -1
  301. data/{app/types/decidim/core → lib/decidim/api/input_sorts}/user_entity_input_sort.rb +4 -4
  302. data/lib/decidim/api/{amendable_entity_interface.rb → interfaces/amendable_entity_interface.rb} +5 -5
  303. data/lib/decidim/api/interfaces/amendable_interface.rb +17 -0
  304. data/lib/decidim/api/{attachable_interface.rb → interfaces/attachable_interface.rb} +3 -3
  305. data/lib/decidim/api/interfaces/author_interface.rb +32 -0
  306. data/lib/decidim/api/interfaces/authorable_interface.rb +23 -0
  307. data/lib/decidim/api/{categorizable_interface.rb → interfaces/categorizable_interface.rb} +3 -3
  308. data/lib/decidim/api/interfaces/coauthorable_interface.rb +30 -0
  309. data/lib/decidim/api/interfaces/component_interface.rb +22 -0
  310. data/lib/decidim/api/interfaces/endorsable_interface.rb +19 -0
  311. data/lib/decidim/api/{fingerprint_interface.rb → interfaces/fingerprint_interface.rb} +3 -3
  312. data/lib/decidim/api/interfaces/participatory_space_interface.rb +48 -0
  313. data/lib/decidim/api/interfaces/participatory_space_resourceable_interface.rb +25 -0
  314. data/lib/decidim/api/{scopable_interface.rb → interfaces/scopable_interface.rb} +3 -3
  315. data/lib/decidim/api/interfaces/timestamps_interface.rb +15 -0
  316. data/lib/decidim/api/interfaces/traceable_interface.rb +14 -0
  317. data/lib/decidim/api/scalars/date_time_type.rb +17 -0
  318. data/lib/decidim/api/scalars/date_type.rb +17 -0
  319. data/lib/decidim/api/types/amendment_type.rb +19 -0
  320. data/lib/decidim/api/types/area_api_type.rb +16 -0
  321. data/lib/decidim/api/types/area_type_type.rb +13 -0
  322. data/lib/decidim/api/types/attachment_type.rb +13 -0
  323. data/lib/decidim/api/types/category_type.rb +14 -0
  324. data/{app/types/decidim/core → lib/decidim/api/types}/component_type.rb +2 -4
  325. data/lib/decidim/api/types/coordinates_type.rb +21 -0
  326. data/lib/decidim/api/types/decidim_type.rb +13 -0
  327. data/lib/decidim/api/types/fingerprint_type.rb +12 -0
  328. data/lib/decidim/api/types/hashtag_type.rb +13 -0
  329. data/lib/decidim/api/types/localized_string_type.rb +13 -0
  330. data/lib/decidim/api/types/metric_history_type.rb +18 -0
  331. data/lib/decidim/api/types/metric_type.rb +13 -0
  332. data/lib/decidim/api/types/organization_type.rb +17 -0
  333. data/lib/decidim/api/types/participatory_space_link_type.rb +22 -0
  334. data/lib/decidim/api/types/participatory_space_type.rb +10 -0
  335. data/lib/decidim/api/types/scope_api_type.rb +16 -0
  336. data/lib/decidim/api/types/session_type.rb +22 -0
  337. data/lib/decidim/api/types/statistic_type.rb +20 -0
  338. data/lib/decidim/api/types/trace_version_type.rb +21 -0
  339. data/lib/decidim/api/types/translated_field_type.rb +36 -0
  340. data/lib/decidim/api/types/user_group_type.rb +64 -0
  341. data/lib/decidim/api/types/user_type.rb +67 -0
  342. data/lib/decidim/attachment_attributes.rb +57 -0
  343. data/lib/decidim/attributes/clean_string.rb +37 -0
  344. data/lib/decidim/attributes.rb +1 -0
  345. data/lib/decidim/coauthorable.rb +3 -3
  346. data/lib/decidim/component_manifest.rb +17 -0
  347. data/lib/decidim/content_block_manifest.rb +1 -1
  348. data/lib/decidim/content_parsers/hashtag_parser.rb +3 -6
  349. data/lib/decidim/content_parsers/user_group_parser.rb +2 -5
  350. data/lib/decidim/content_parsers/user_parser.rb +2 -5
  351. data/lib/decidim/content_processor.rb +1 -1
  352. data/lib/decidim/content_renderers/hashtag_renderer.rb +3 -6
  353. data/lib/decidim/core/api.rb +71 -16
  354. data/lib/decidim/core/engine.rb +35 -6
  355. data/lib/decidim/core/test/factories.rb +53 -15
  356. data/lib/decidim/core/test/shared_examples/admin_resource_gallery_examples.rb +1 -1
  357. data/lib/decidim/core/test/shared_examples/amendable/amendment_accepted_event_examples.rb +1 -1
  358. data/lib/decidim/core/test/shared_examples/amendable/amendment_promoted_event_examples.rb +1 -1
  359. data/lib/decidim/core/test/shared_examples/amendable/amendment_rejected_event_examples.rb +1 -1
  360. data/lib/decidim/core/test/shared_examples/categorizable_interface_examples.rb +6 -14
  361. data/lib/decidim/core/test/shared_examples/comments_examples.rb +11 -9
  362. data/lib/decidim/core/test/shared_examples/component_type.rb +1 -1
  363. data/lib/decidim/core/test/shared_examples/controller_render_views.rb +28 -0
  364. data/lib/decidim/core/test/shared_examples/follows_examples.rb +1 -1
  365. data/lib/decidim/core/test/shared_examples/logo_email.rb +1 -1
  366. data/lib/decidim/core/test/shared_examples/map_examples.rb +1 -1
  367. data/lib/decidim/core/test/shared_examples/process_announcements_examples.rb +1 -1
  368. data/lib/decidim/core/test/shared_examples/reportable.rb +8 -0
  369. data/lib/decidim/core/test/shared_examples/rich_text_editor_examples.rb +1 -1
  370. data/lib/decidim/core/test/shared_examples/searchable_participatory_space_examples.rb +2 -3
  371. data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +46 -0
  372. data/lib/decidim/core/test/shared_examples/static_pages_examples.rb +43 -0
  373. data/lib/decidim/core/test.rb +2 -0
  374. data/lib/decidim/core/version.rb +1 -1
  375. data/lib/decidim/core.rb +11 -3
  376. data/lib/decidim/diffy_extension.rb +2 -2
  377. data/lib/decidim/exporters/csv.rb +3 -2
  378. data/lib/decidim/exporters/export_data.rb +1 -1
  379. data/lib/decidim/faker/internet.rb +17 -0
  380. data/lib/decidim/faker/localized.rb +43 -20
  381. data/lib/decidim/file_validator_humanizer.rb +6 -4
  382. data/lib/decidim/form_builder.rb +33 -22
  383. data/lib/decidim/gamification/badge_scorer.rb +3 -2
  384. data/lib/decidim/gamification/base_event.rb +2 -2
  385. data/lib/decidim/geocodable.rb +2 -0
  386. data/lib/decidim/has_category.rb +1 -1
  387. data/lib/decidim/has_private_users.rb +1 -1
  388. data/lib/decidim/importers/import_manifest.rb +36 -0
  389. data/lib/decidim/map/autocomplete.rb +11 -1
  390. data/lib/decidim/metric_operation.rb +5 -6
  391. data/lib/decidim/participatory_space_resourceable.rb +1 -3
  392. data/lib/decidim/query_extensions.rb +90 -69
  393. data/lib/decidim/randomable.rb +6 -1
  394. data/lib/decidim/record_encryptor.rb +131 -0
  395. data/lib/decidim/reportable.rb +26 -0
  396. data/lib/decidim/resource_manifest.rb +3 -0
  397. data/lib/decidim/resourceable.rb +6 -6
  398. data/lib/decidim/scopable.rb +1 -1
  399. data/lib/decidim/search_resource_fields_mapper.rb +1 -1
  400. data/lib/decidim/searchable.rb +9 -0
  401. data/lib/decidim/settings_manifest.rb +2 -1
  402. data/lib/decidim/shareable_with_token.rb +0 -1
  403. data/lib/decidim/translatable_attributes.rb +2 -1
  404. data/lib/decidim/translatable_resource.rb +10 -0
  405. data/lib/decidim/user_reportable.rb +33 -0
  406. data/lib/decidim/view_model.rb +26 -0
  407. data/lib/premailer/adapter/decidim.rb +4 -4
  408. data/lib/tasks/decidim_data_portability_tasks.rake +4 -4
  409. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ko.js +18 -0
  410. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.vi.js +14 -0
  411. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.zh-CN.js +14 -0
  412. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.zh-TW.js +14 -0
  413. metadata +190 -95
  414. data/app/functions/decidim/core/participatory_space_finder.rb +0 -11
  415. data/app/functions/decidim/core/participatory_space_list.rb +0 -11
  416. data/app/helpers/decidim/cache_helper.rb +0 -14
  417. data/app/types/decidim/core/amendment_type.rb +0 -26
  418. data/app/types/decidim/core/area_api_type.rb +0 -16
  419. data/app/types/decidim/core/area_type_type.rb +0 -14
  420. data/app/types/decidim/core/attachment_type.rb +0 -14
  421. data/app/types/decidim/core/category_type.rb +0 -16
  422. data/app/types/decidim/core/coordinates_type.rb +0 -19
  423. data/app/types/decidim/core/date_time_type.rb +0 -12
  424. data/app/types/decidim/core/date_type.rb +0 -13
  425. data/app/types/decidim/core/decidim_type.rb +0 -19
  426. data/app/types/decidim/core/fingerprint_type.rb +0 -15
  427. data/app/types/decidim/core/has_timestamp_input_sort.rb +0 -12
  428. data/app/types/decidim/core/hashtag_type.rb +0 -13
  429. data/app/types/decidim/core/localized_string_type.rb +0 -14
  430. data/app/types/decidim/core/metric_history_type.rb +0 -17
  431. data/app/types/decidim/core/metric_type.rb +0 -14
  432. data/app/types/decidim/core/organization_type.rb +0 -20
  433. data/app/types/decidim/core/participatory_space_link_type.rb +0 -24
  434. data/app/types/decidim/core/participatory_space_type.rb +0 -12
  435. data/app/types/decidim/core/scope_api_type.rb +0 -16
  436. data/app/types/decidim/core/session_type.rb +0 -19
  437. data/app/types/decidim/core/statistic_type.rb +0 -22
  438. data/app/types/decidim/core/trace_version_type.rb +0 -29
  439. data/app/types/decidim/core/translated_field_type.rb +0 -45
  440. data/app/types/decidim/core/user_entity_input_filter.rb +0 -81
  441. data/app/types/decidim/core/user_group_type.rb +0 -51
  442. data/app/types/decidim/core/user_type.rb +0 -52
  443. data/app/views/decidim/shared/_announcement.html.erb +0 -1
  444. data/app/views/decidim/shared/_flag_modal.html.erb +0 -20
  445. data/db/migrate/20210302150803_invalidate_all_sessions_for_deleted_users.rb +0 -11
  446. data/lib/decidim/api/amendable_interface.rb +0 -18
  447. data/lib/decidim/api/author_interface.rb +0 -29
  448. data/lib/decidim/api/authorable_interface.rb +0 -22
  449. data/lib/decidim/api/coauthorable_interface.rb +0 -29
  450. data/lib/decidim/api/component_interface.rb +0 -20
  451. data/lib/decidim/api/endorsable_interface.rb +0 -22
  452. data/lib/decidim/api/participatory_space_interface.rb +0 -47
  453. data/lib/decidim/api/participatory_space_resourceable_interface.rb +0 -21
  454. data/lib/decidim/api/timestamps_interface.rb +0 -21
  455. data/lib/decidim/api/traceable_interface.rb +0 -14
@@ -9,10 +9,7 @@ module Decidim
9
9
  # name
10
10
  # }
11
11
  #
12
- class UserEntityFinder < GraphQL::Function
13
- argument :id, types.ID, "The ID of the participant"
14
- argument :nickname, types.String, "The @nickname of the participant"
15
-
12
+ class UserEntityFinder
16
13
  def call(_obj, args, ctx)
17
14
  filters = {
18
15
  organization: ctx[:current_organization]
@@ -9,10 +9,8 @@ module Decidim
9
9
  # name
10
10
  # }
11
11
  #
12
- class UserEntityList < GraphQL::Function
12
+ class UserEntityList
13
13
  include NeedsApiFilterAndOrder
14
- argument :order, UserEntityInputSort, "Provides several methods to order the results"
15
- argument :filter, UserEntityInputFilter, "Provides several methods to filter the results"
16
14
 
17
15
  def initialize
18
16
  @model_class = Decidim::UserBaseEntity
@@ -10,41 +10,39 @@ module Decidim
10
10
  description "A type used for filtering any component parent objects"
11
11
 
12
12
  argument :type,
13
- type: String,
13
+ type: GraphQL::Types::String,
14
14
  description: "Filters by type of component",
15
15
  required: false,
16
- prepare: ->(value, _ctx) do
17
- { manifest_name: value.downcase }
18
- end
16
+ prepare: lambda { |value, _ctx|
17
+ { manifest_name: value.downcase }
18
+ }
19
19
  argument :name,
20
- type: String,
20
+ type: GraphQL::Types::String,
21
21
  description: "Filters by name of the component, additional locale parameter can be provided to specify in which to search",
22
22
  required: false,
23
- prepare: ->(search, ctx) do
24
- proc do |model_class, locale|
23
+ prepare: lambda { |search, ctx|
24
+ lambda { |model_name, locale|
25
25
  locale = ctx[:current_organization].default_locale if locale.blank?
26
- op = Arel::Nodes::InfixOperation.new("->>", model_class.arel_table[:name], Arel::Nodes.build_quoted(locale))
26
+ op = Arel::Nodes::InfixOperation.new("->>", model_name.arel_table[:name], Arel::Nodes.build_quoted(locale))
27
27
  op.matches("%#{search}%")
28
- end
29
- end
28
+ }
29
+ }
30
+
30
31
  argument :with_geolocation_enabled,
31
- type: Boolean,
32
+ type: GraphQL::Types::Boolean,
32
33
  description: "Returns components with geolocation activated (may be Proposals or Meetings)",
33
34
  required: false,
34
- prepare: ->(active, _ctx) do
35
- proc do |_model_class|
36
- ["(settings->'global'->>'geocoding_enabled')::boolean is ? or manifest_name='meetings'", active]
37
- end
38
- end
35
+ prepare: lambda { |active, _ctx|
36
+ ->(_model_name, _locale) { ["(settings->'global'->>'geocoding_enabled')::boolean is ? or manifest_name='meetings'", active] }
37
+ }
38
+
39
39
  argument :with_comments_enabled,
40
- type: Boolean,
40
+ type: GraphQL::Types::Boolean,
41
41
  description: "Returns components with comments enabled globally (can still be deactivated in the current step if the component has steps)",
42
42
  required: false,
43
- prepare: ->(active, _ctx) do
44
- proc do |_model_class|
45
- ["(settings->'global'->>'comments_enabled')::boolean is ?", active]
46
- end
47
- end
43
+ prepare: lambda { |active, _ctx|
44
+ ->(_model_name, _locale) { ["(settings->'global'->>'comments_enabled')::boolean is ?", active] }
45
+ }
48
46
  end
49
47
  end
50
48
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module HasHastaggableInputFilter
6
6
  def self.included(child_class)
7
7
  child_class.argument :hashtag,
8
- type: String,
8
+ type: GraphQL::Types::String,
9
9
  description: "List result having this hashtag",
10
10
  required: false,
11
11
  prepare: ->(hashtag, _ctx) { "##{hashtag.sub(/^#/, "")}" }
@@ -5,16 +5,16 @@ module Decidim
5
5
  module HasLocalizedInputFilter
6
6
  def self.included(child_class)
7
7
  child_class.argument :locale,
8
- type: String,
8
+ type: GraphQL::Types::String,
9
9
  description: "Specify the locale to use when searching translated fields, otherwise default organization language will be used",
10
10
  required: false,
11
- prepare: ->(locale, ctx) do
11
+ prepare: lambda { |locale, ctx|
12
12
  unless ctx[:current_organization].available_locales.include?(locale)
13
13
  raise GraphQL::ExecutionError, "#{locale} locale is not used in the organization"
14
14
  end
15
15
 
16
16
  locale
17
- end
17
+ }
18
18
  end
19
19
  end
20
20
  end
@@ -5,23 +5,23 @@ module Decidim
5
5
  module HasPublishableInputFilter
6
6
  def self.included(child_class)
7
7
  child_class.argument :published_before,
8
- type: String,
8
+ type: GraphQL::Types::String,
9
9
  description: "List result published **before** (and **excluding**) this date. Expected format `YYYY-MM-DD`",
10
10
  required: false,
11
- prepare: ->(date, _ctx) do
11
+ prepare: lambda { |date, _ctx|
12
12
  proc do |model_class|
13
13
  model_class.arel_table[:published_at].lt(date_to_iso8601(date, :publishedBefore))
14
14
  end
15
- end
15
+ }
16
16
  child_class.argument :published_since,
17
- type: String,
17
+ type: GraphQL::Types::String,
18
18
  description: "List result published after (and **including**) this date. Expected format `YYYY-MM-DD`",
19
19
  required: false,
20
- prepare: ->(date, _ctx) do
20
+ prepare: lambda { |date, _ctx|
21
21
  proc do |model_class|
22
22
  model_class.arel_table[:published_at].gteq(date_to_iso8601(date, :publishedBefore))
23
23
  end
24
- end
24
+ }
25
25
  end
26
26
 
27
27
  def self.date_to_iso8601(date, key)
@@ -5,41 +5,41 @@ module Decidim
5
5
  module HasTimestampInputFilter
6
6
  def self.included(child_class)
7
7
  child_class.argument :created_before,
8
- type: String,
8
+ type: GraphQL::Types::String,
9
9
  description: "List result created **before** (and **excluding**) this date. Expected format `YYYY-MM-DD`",
10
10
  required: false,
11
- prepare: ->(date, _ctx) do
11
+ prepare: lambda { |date, _ctx|
12
12
  proc do |model_class|
13
13
  model_class.arel_table[:created_at].lt(date_to_iso8601(date, :createdBefore))
14
14
  end
15
- end
15
+ }
16
16
  child_class.argument :created_since,
17
- type: String,
17
+ type: GraphQL::Types::String,
18
18
  description: "List result created after (and **including**) this date. Expected format `YYYY-MM-DD`",
19
19
  required: false,
20
- prepare: ->(date, _ctx) do
20
+ prepare: lambda { |date, _ctx|
21
21
  proc do |model_class|
22
22
  model_class.arel_table[:created_at].gteq(date_to_iso8601(date, :createdBefore))
23
23
  end
24
- end
24
+ }
25
25
  child_class.argument :updated_before,
26
- type: String,
26
+ type: GraphQL::Types::String,
27
27
  description: "List result updated **before** (and **excluding**) this date. Expected format `YYYY-MM-DD`",
28
28
  required: false,
29
- prepare: ->(date, _ctx) do
29
+ prepare: lambda { |date, _ctx|
30
30
  proc do |model_class|
31
31
  model_class.arel_table[:updated_at].lt(date_to_iso8601(date, :updatedBefore))
32
32
  end
33
- end
33
+ }
34
34
  child_class.argument :updated_since,
35
- type: String,
35
+ type: GraphQL::Types::String,
36
36
  description: "List result updated after (and **including**) this date. Expected format `YYYY-MM-DD`",
37
37
  required: false,
38
- prepare: ->(date, _ctx) do
38
+ prepare: lambda { |date, _ctx|
39
39
  proc do |model_class|
40
40
  model_class.arel_table[:updated_at].gteq(date_to_iso8601(date, :updatedBefore))
41
41
  end
42
- end
42
+ }
43
43
  end
44
44
 
45
45
  def self.date_to_iso8601(date, key)
@@ -12,7 +12,6 @@ Specific participatory spaces (such as Processes or Assemblies) usually implemen
12
12
 
13
13
  A typical query would look like:
14
14
 
15
-
16
15
  ```
17
16
  {
18
17
  participatoryProcesses(filter:{ publishedBefore: \"2020-01-01\" }) {
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Core
5
+ class UserEntityInputFilter < BaseInputFilter
6
+ graphql_name "UserEntityFilter"
7
+ description "A type used for filtering any user or group
8
+
9
+ A typical query would look like:
10
+
11
+ ```
12
+ {
13
+ users(filter:{wildcard:\"sandy\", excludeIds:[2,10,11]}) {
14
+ id
15
+ ...on User {
16
+ groups {
17
+ name
18
+ }
19
+ }
20
+ ...on UserGroup {
21
+ members {
22
+ name
23
+ }
24
+ }
25
+ }
26
+ }
27
+ ```
28
+ "
29
+
30
+ argument :type,
31
+ type: String,
32
+ description: "Filters by type of entity (User or UserGroup)",
33
+ required: false,
34
+ prepare: lambda { |value, _ctx|
35
+ type = value.downcase.camelcase
36
+ type = "UserGroup" if %w(Group Usergroup).include?(type)
37
+ { type: "Decidim::#{type}" }
38
+ }
39
+ argument :name,
40
+ type: String,
41
+ description: "Filters by name of the user entity. Searches (case insensitive) any fragment of the provided string",
42
+ required: false,
43
+ prepare: lambda { |value, _ctx|
44
+ [
45
+ lambda { |model_class, _locale|
46
+ model_class.arel_table[:name].matches("%#{value}%")
47
+ }
48
+ ]
49
+ }
50
+ argument :nickname,
51
+ type: String,
52
+ description: "Filters by nickname of the user entity. Searches (case insensitive) any fragment of the provided string",
53
+ required: false,
54
+ prepare: lambda { |value, _ctx|
55
+ value = value[1..-1] if value.starts_with? "@"
56
+ [
57
+ lambda { |model_class, _locale|
58
+ model_class.arel_table[:nickname].matches("%#{value}%")
59
+ }
60
+ ]
61
+ }
62
+ argument :wildcard,
63
+ type: String,
64
+ description: "Filters by nickname or name of the user entity. Searches (case insensitive) any fragment of the provided string",
65
+ required: false,
66
+ prepare: lambda { |value, _ctx|
67
+ value = value[1..-1] if value.starts_with? "@"
68
+ [
69
+ lambda { |model_class, _locale|
70
+ op_name = model_class.arel_table[:name].matches("%#{value}%")
71
+ op_nick = model_class.arel_table[:nickname].matches("%#{value}%")
72
+ op_name.or(op_nick)
73
+ }
74
+ ]
75
+ }
76
+ argument :exclude_ids,
77
+ type: [ID],
78
+ description: "Excludes users contained in given ids. Valid values are one or more IDs (passed as an array)",
79
+ required: false,
80
+ prepare: lambda { |value, _ctx|
81
+ [
82
+ lambda { |model_class, _locale|
83
+ model_class.arel_table[:id].not_in(value)
84
+ }
85
+ ]
86
+ }
87
+ end
88
+ end
89
+ end
@@ -6,8 +6,9 @@ module Decidim
6
6
  # Overwrite the prepare method to allow 2 possible values only
7
7
  def prepare
8
8
  arguments.each do |key, value|
9
- next if key == "locale"
10
- raise GraphQL::ExecutionError, "Invalid order value for #{key}, only ASC or DESC are valids" unless valid_order?(value)
9
+ next if key.to_s == "locale"
10
+ next if value.respond_to?(:call)
11
+ raise GraphQL::ExecutionError, "Invalid order value for #{key.inspect}, only ASC or DESC are valids (received #{value.inspect})" unless valid_order?(value)
11
12
  end
12
13
  super
13
14
  end
@@ -8,25 +8,24 @@ module Decidim
8
8
  graphql_name "ComponentSort"
9
9
  description "A type used for sorting any component parent objects"
10
10
 
11
- argument :id, String, "Sort by ID, valid values are ASC or DESC", required: false
12
- argument :weight, String, "Sort by weight (order in the website), valid values are ASC or DESC", required: false
11
+ argument :id, GraphQL::Types::String, "Sort by ID, valid values are ASC or DESC", required: false
12
+ argument :weight, GraphQL::Types::String, "Sort by weight (order in the website), valid values are ASC or DESC", required: false
13
13
  argument :type,
14
- type: String,
14
+ type: GraphQL::Types::String,
15
15
  description: "Sort by type of component, alphabetically, valid values are ASC or DESC",
16
16
  required: false,
17
- prepare: ->(direction, _ctx) do
18
- { manifest_name: direction }
19
- end
17
+ as: :manifest_name
20
18
  argument :name,
21
- type: String,
19
+ type: GraphQL::Types::String,
22
20
  description: "Sort by name of the component, alphabetically, valid values are ASC or DESC",
23
21
  required: false,
24
- prepare: ->(direction, ctx) do
25
- proc do |locale|
22
+ as: :name,
23
+ prepare: lambda { |direction, ctx|
24
+ lambda { |locale|
26
25
  locale = ctx[:current_organization].default_locale if locale.blank?
27
26
  [Arel.sql("name->? #{direction.upcase}"), locale]
28
- end
29
- end
27
+ }
28
+ }
30
29
  end
31
30
  end
32
31
  end
@@ -5,12 +5,10 @@ module Decidim
5
5
  module HasEndorsableInputSort
6
6
  def self.included(child_class)
7
7
  child_class.argument :endorsement_count,
8
- type: String,
8
+ type: GraphQL::Types::String,
9
9
  description: "Sort by number of endorsements, valid values are ASC or DESC",
10
10
  required: false,
11
- prepare: ->(value, _ctx) do
12
- { endorsements_count: value }
13
- end
11
+ as: :endorsements_count
14
12
  end
15
13
  end
16
14
  end
@@ -5,16 +5,16 @@ module Decidim
5
5
  module HasLocalizedInputSort
6
6
  def self.included(child_class)
7
7
  child_class.argument :locale,
8
- type: String,
8
+ type: GraphQL::Types::String,
9
9
  description: "Specify the locale to use when ordering translated fields, otherwise default organization language will be used",
10
10
  required: false,
11
- prepare: ->(locale, ctx) do
11
+ prepare: lambda { |locale, ctx|
12
12
  unless ctx[:current_organization].available_locales.include?(locale)
13
13
  raise GraphQL::ExecutionError, "#{locale} locale is not used in the organization"
14
14
  end
15
15
 
16
16
  locale
17
- end
17
+ }
18
18
  end
19
19
  end
20
20
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Core
5
5
  module HasPublishableInputSort
6
6
  def self.included(child_class)
7
- child_class.argument :published_at, String, "Sort by date of publication, valid values are ASC or DESC", required: false
7
+ child_class.argument :published_at, GraphQL::Types::String, "Sort by date of publication, valid values are ASC or DESC", required: false
8
8
  # child_class.argument :created_at, String, "Sort by date of creation, valid values are ASC or DESC", required: false
9
9
  # child_class.argument :updated_at, String, "Sort by date of last modification, valid values are ASC or DESC", required: false
10
10
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Core
5
+ module HasTimestampInputSort
6
+ def self.included(child_class)
7
+ child_class.argument :created_at, GraphQL::Types::String, "Sort by date of creation, valid values are ASC or DESC", required: false
8
+ child_class.argument :updated_at, GraphQL::Types::String, "Sort by date of last modification, valid values are ASC or DESC", required: false
9
+ end
10
+ end
11
+ end
12
+ end
@@ -8,7 +8,7 @@ module Decidim
8
8
  graphql_name "ParticipatorySpaceSort"
9
9
  description "A type used for sorting any generic participatory space"
10
10
 
11
- argument :id, String, "Sort by ID, valid values are ASC or DESC", required: false
11
+ argument :id, GraphQL::Types::String, "Sort by ID, valid values are ASC or DESC", required: false
12
12
  end
13
13
  end
14
14
  end
@@ -6,17 +6,17 @@ module Decidim
6
6
  graphql_name "UserEntitySort"
7
7
  description "A type used for sorting any component parent objects"
8
8
 
9
- argument :id, String, "Sort by ID, valid values are ASC or DESC", required: false
9
+ argument :id, GraphQL::Types::String, "Sort by ID, valid values are ASC or DESC", required: false
10
10
  argument :type,
11
- type: String,
11
+ type: GraphQL::Types::String,
12
12
  description: "Sort by type of user entity (user or group), alphabetically, valid values are ASC or DESC",
13
13
  required: false
14
14
  argument :name,
15
- type: String,
15
+ type: GraphQL::Types::String,
16
16
  description: "Sort by name of the user entity (user or group), alphabetically, valid values are ASC or DESC",
17
17
  required: false
18
18
  argument :nickname,
19
- type: String,
19
+ type: GraphQL::Types::String,
20
20
  description: "Sort by nickname of the user entity (user or group), alphabetically, valid values are ASC or DESC",
21
21
  required: false
22
22
  end
@@ -4,15 +4,15 @@ module Decidim
4
4
  module Core
5
5
  # This interface should be implemented by any Type that can be used as amendment
6
6
  # The only requirement is to have an ID and the Type name be the class.name + Type
7
- AmendableEntityInterface = GraphQL::InterfaceType.define do
8
- name "AmendableEntityInterface"
7
+ module AmendableEntityInterface
8
+ include Decidim::Api::Types::BaseInterface
9
9
  description "An interface that can be used in objects with amendments"
10
10
 
11
- field :id, !types.ID, "ID of this entity"
11
+ field :id, ID, "ID of this entity", null: false
12
12
 
13
- resolve_type ->(obj, _ctx) {
13
+ def self.resolve_type(obj, _ctx)
14
14
  "#{obj.class.name}Type".constantize
15
- }
15
+ end
16
16
  end
17
17
  end
18
18
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Core
5
+ # This interface represents an amendable object.
6
+ module AmendableInterface
7
+ include Decidim::Api::Types::BaseInterface
8
+ description "An interface that can be used in objects with amendments"
9
+
10
+ field :amendments, [Decidim::Core::AmendmentType, { null: true }], description: "This object's amendments", null: false
11
+
12
+ def amendments
13
+ object.visible_amendments_for(context[:current_user])
14
+ end
15
+ end
16
+ end
17
+ end
@@ -3,11 +3,11 @@
3
3
  module Decidim
4
4
  module Core
5
5
  # This interface represents a attachable object.
6
- AttachableInterface = GraphQL::InterfaceType.define do
7
- name "AttachableInterface"
6
+ module AttachableInterface
7
+ include Decidim::Api::Types::BaseInterface
8
8
  description "An interface that can be used in objects with attachments"
9
9
 
10
- field :attachments, !types[Decidim::Core::AttachmentType], "This object's attachments"
10
+ field :attachments, [Decidim::Core::AttachmentType, { null: true }], "This object's attachments", null: false
11
11
  end
12
12
  end
13
13
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Core
5
+ # This interface represents an author who owns a resource.
6
+ module AuthorInterface
7
+ include Decidim::Api::Types::BaseInterface
8
+ graphql_name "Author"
9
+ description "An author"
10
+
11
+ field :id, ID, "The author ID", null: false
12
+ field :name, String, "The author's name", null: false
13
+ field :nickname, String, "The author's nickname", null: false
14
+
15
+ field :avatar_url, String, "The author's avatar url", null: false
16
+ field :profile_path, String, "The author's profile path", null: false
17
+ field :badge, String, "The author's badge icon", null: false
18
+ field :organization_name, String, "The authors's organization name", null: false
19
+
20
+ def organization_name
21
+ object.organization.name
22
+ end
23
+
24
+ field :deleted, Boolean, "Whether the author's account has been deleted or not", null: false
25
+
26
+ def self.resolve_type(obj, _ctx)
27
+ return Decidim::Core::UserType if obj.is_a? Decidim::User
28
+ return Decidim::Core::UserGroupType if obj.is_a? Decidim::UserGroup
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Core
5
+ # This interface represents a commentable object.
6
+ module AuthorableInterface
7
+ include Decidim::Api::Types::BaseInterface
8
+ description "An interface that can be used in authorable objects."
9
+
10
+ field :author, Decidim::Core::AuthorInterface, "The resource author", null: true do
11
+ # can be an Authorable or a Coauthorable
12
+ end
13
+
14
+ def author
15
+ if object.respond_to?(:normalized_author)
16
+ object&.normalized_author
17
+ elsif object.respond_to?(:creator_identity)
18
+ object&.creator_identity
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -3,11 +3,11 @@
3
3
  module Decidim
4
4
  module Core
5
5
  # This interface represents a categorizable object.
6
- CategorizableInterface = GraphQL::InterfaceType.define do
7
- name "CategorizableInterface"
6
+ module CategorizableInterface
7
+ include Decidim::Api::Types::BaseInterface
8
8
  description "An interface that can be used in categorizable objects."
9
9
 
10
- field :category, Decidim::Core::CategoryType, "The object's category"
10
+ field :category, Decidim::Core::CategoryType, "The object's category", null: false
11
11
  end
12
12
  end
13
13
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Core
5
+ # This interface represents a coauthorable object.
6
+ module CoauthorableInterface
7
+ include Decidim::Api::Types::BaseInterface
8
+ description "An interface that can be used in coauthorable objects."
9
+
10
+ field :authors_count, Integer,
11
+ method: :coauthorships_count,
12
+ description: "The total amount of co-authors that contributed to the entity. Note that this field may include also non-user authors like meetings or the organization",
13
+ null: true
14
+
15
+ field :author, Decidim::Core::AuthorInterface,
16
+ description: "The resource author. Note that this can be null on official proposals or meeting-proposals",
17
+ null: true
18
+
19
+ def author
20
+ author = object.creator_identity
21
+ author if author.is_a?(Decidim::User) || author.is_a?(Decidim::UserGroup)
22
+ end
23
+
24
+ field :authors, [Decidim::Core::AuthorInterface, { null: true }],
25
+ method: :user_identities,
26
+ description: "The resource co-authors. Include only users or groups of users",
27
+ null: false
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Core
5
+ module ComponentInterface
6
+ include Decidim::Api::Types::BaseInterface
7
+ description "This interface is implemented by all components that belong into a Participatory Space"
8
+
9
+ field :id, ID, "The Component's unique ID", null: false
10
+
11
+ field :name, TranslatedFieldType, "The name of this component.", null: false
12
+
13
+ field :weight, Integer, "The weight of the component", null: false
14
+
15
+ field :participatory_space, ParticipatorySpaceType, "The participatory space in which this component belongs to.", null: false
16
+
17
+ def self.resolve_type(obj, _ctx)
18
+ obj.manifest.query_type.constantize
19
+ end
20
+ end
21
+ end
22
+ end