decidim-core 0.15.2 → 0.16.0

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 (354) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -1
  3. data/app/assets/config/decidim_core_manifest.js +14 -12
  4. data/app/assets/images/decidim/pattern.png +0 -0
  5. data/app/assets/javascripts/decidim.js.es6 +4 -0
  6. data/app/assets/javascripts/decidim/floating_help.js.es6 +40 -0
  7. data/app/assets/javascripts/decidim/input_hashtags.js.es6 +6 -4
  8. data/app/assets/javascripts/decidim/notifications.js.es6 +1 -1
  9. data/app/assets/javascripts/decidim/tooltip_keep_on_hover.js.es6 +18 -0
  10. data/app/assets/javascripts/decidim/vizzs/areachart.js.es6 +52 -10
  11. data/app/assets/javascripts/decidim/vizzs/metrics.js.es6 +68 -22
  12. data/app/assets/javascripts/decidim/vizzs/orgchart.js.es6 +10 -13
  13. data/app/assets/stylesheets/decidim/conference-diploma.css.scss +61 -0
  14. data/app/assets/stylesheets/decidim/layouts/_home.scss +1 -1
  15. data/app/assets/stylesheets/decidim/modules/_buttons.scss +4 -0
  16. data/app/assets/stylesheets/decidim/modules/_cards.scss +17 -1
  17. data/app/assets/stylesheets/decidim/modules/_conference-programme.scss +0 -4
  18. data/app/assets/stylesheets/decidim/modules/_filters.scss +37 -2
  19. data/app/assets/stylesheets/decidim/modules/_floating-helper.scss +106 -0
  20. data/app/assets/stylesheets/decidim/modules/_forms.scss +22 -0
  21. data/app/assets/stylesheets/decidim/modules/_help.scss +4 -0
  22. data/app/assets/stylesheets/decidim/modules/_layout.scss +1 -0
  23. data/app/assets/stylesheets/decidim/modules/_margins.scss +1 -0
  24. data/app/assets/stylesheets/decidim/modules/_modules.scss +1 -1
  25. data/app/assets/stylesheets/decidim/modules/_navbar.scss +5 -1
  26. data/app/assets/stylesheets/decidim/modules/_order-by.scss +11 -1
  27. data/app/assets/stylesheets/decidim/modules/_process-header.scss +36 -38
  28. data/app/assets/stylesheets/decidim/modules/_process-nav.scss +61 -10
  29. data/app/assets/stylesheets/decidim/modules/_process-phase.scss +63 -30
  30. data/app/assets/stylesheets/decidim/modules/_share.scss +4 -0
  31. data/app/assets/stylesheets/decidim/modules/_typography.scss +17 -0
  32. data/app/assets/stylesheets/decidim/{modules → vizzs}/_orgchart.scss +2 -10
  33. data/app/cells/decidim/activities_cell.rb +6 -2
  34. data/app/cells/decidim/activity/show.erb +22 -19
  35. data/app/cells/decidim/activity_cell.rb +35 -5
  36. data/app/cells/decidim/amendable/amend_button_card/show.erb +9 -0
  37. data/app/cells/decidim/amendable/amend_button_card_cell.rb +43 -0
  38. data/app/cells/decidim/amendable/amenders_list/show.erb +18 -0
  39. data/app/cells/decidim/amendable/amenders_list_cell.rb +7 -0
  40. data/app/cells/decidim/amendable/announcement_cell.rb +58 -0
  41. data/app/cells/decidim/amendable/emendation_actions/show.erb +13 -0
  42. data/app/cells/decidim/amendable/emendation_actions_cell.rb +52 -0
  43. data/app/cells/decidim/amendable/promote_button_card/show.erb +9 -0
  44. data/app/cells/decidim/amendable/promote_button_card_cell.rb +47 -0
  45. data/app/cells/decidim/author/profile_inline.erb +23 -4
  46. data/app/cells/decidim/author/profile_minicard.erb +25 -0
  47. data/app/cells/decidim/author/show.erb +0 -1
  48. data/app/cells/decidim/author_cell.rb +6 -0
  49. data/app/cells/decidim/card_cell.rb +2 -4
  50. data/app/cells/decidim/card_m/top.erb +1 -1
  51. data/app/cells/decidim/card_m_cell.rb +3 -0
  52. data/app/cells/decidim/content_blocks/last_activity_cell.rb +1 -1
  53. data/app/cells/decidim/follow_button/show.erb +0 -1
  54. data/app/cells/decidim/follow_button_cell.rb +10 -0
  55. data/app/cells/decidim/following/show.erb +1 -1
  56. data/app/cells/decidim/following_cell.rb +1 -1
  57. data/app/cells/decidim/notifications/show.erb +1 -0
  58. data/app/cells/decidim/pad_iframe/show.erb +14 -0
  59. data/app/cells/decidim/pad_iframe_cell.rb +57 -0
  60. data/app/cells/decidim/profile/user_tabs.erb +8 -6
  61. data/app/cells/decidim/profile_cell.rb +1 -1
  62. data/app/cells/decidim/profile_sidebar/show.erb +58 -42
  63. data/app/cells/decidim/profile_sidebar_cell.rb +6 -0
  64. data/app/cells/decidim/search_results/show.erb +8 -0
  65. data/app/cells/decidim/search_results_cell.rb +38 -0
  66. data/app/cells/decidim/search_results_section/show.erb +24 -0
  67. data/app/cells/decidim/search_results_section_cell.rb +35 -0
  68. data/app/cells/decidim/user_activity/show.erb +15 -0
  69. data/app/cells/decidim/user_activity_cell.rb +17 -0
  70. data/app/cells/decidim/user_profile/header.erb +1 -16
  71. data/app/cells/decidim/user_profile/user_data.erb +16 -0
  72. data/app/cells/decidim/user_profile_cell.rb +4 -0
  73. data/app/cells/decidim/user_timeline/show.erb +15 -0
  74. data/app/cells/decidim/user_timeline_cell.rb +17 -0
  75. data/app/commands/decidim/accept_user_group_join_request.rb +1 -1
  76. data/app/commands/decidim/amendable/accept.rb +84 -0
  77. data/app/commands/decidim/amendable/create.rb +103 -0
  78. data/app/commands/decidim/amendable/promote.rb +79 -0
  79. data/app/commands/decidim/amendable/reject.rb +60 -0
  80. data/app/commands/decidim/amendable/withdraw.rb +46 -0
  81. data/app/commands/decidim/create_omniauth_registration.rb +17 -1
  82. data/app/commands/decidim/create_registration.rb +2 -0
  83. data/app/commands/decidim/demote_membership.rb +1 -1
  84. data/app/commands/decidim/invite_user.rb +1 -1
  85. data/app/commands/decidim/invite_user_to_group.rb +1 -1
  86. data/app/commands/decidim/join_user_group.rb +1 -7
  87. data/app/commands/decidim/messaging/reply_to_conversation.rb +1 -1
  88. data/app/commands/decidim/promote_membership.rb +1 -1
  89. data/app/commands/decidim/reject_user_group_join_request.rb +1 -1
  90. data/app/commands/decidim/remove_user_from_group.rb +1 -1
  91. data/app/commands/decidim/search.rb +65 -16
  92. data/app/commands/decidim/update_account.rb +1 -1
  93. data/app/commands/decidim/update_notifications_settings.rb +2 -1
  94. data/app/commands/decidim/update_user_interests.rb +35 -0
  95. data/app/controllers/concerns/decidim/amendments_controller.rb +104 -0
  96. data/app/controllers/concerns/decidim/participatory_space_context.rb +28 -6
  97. data/app/controllers/concerns/decidim/user_groups.rb +23 -0
  98. data/app/controllers/concerns/decidim/user_profile.rb +2 -4
  99. data/app/controllers/decidim/components/base_controller.rb +1 -0
  100. data/app/controllers/decidim/devise/confirmations_controller.rb +9 -0
  101. data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +2 -1
  102. data/app/controllers/decidim/devise/passwords_controller.rb +6 -0
  103. data/app/controllers/decidim/devise/registrations_controller.rb +5 -0
  104. data/app/controllers/decidim/devise/sessions_controller.rb +12 -0
  105. data/app/controllers/decidim/group_admins_controller.rb +3 -0
  106. data/app/controllers/decidim/group_email_confirmations_controller.rb +32 -0
  107. data/app/controllers/decidim/group_invites_controller.rb +3 -0
  108. data/app/controllers/decidim/group_members_controller.rb +3 -0
  109. data/app/controllers/decidim/groups_controller.rb +3 -0
  110. data/app/controllers/decidim/homepage_controller.rb +10 -0
  111. data/app/controllers/decidim/last_activities_controller.rb +1 -1
  112. data/app/controllers/decidim/messaging/conversations_controller.rb +11 -2
  113. data/app/controllers/decidim/open_data_controller.rb +31 -0
  114. data/app/controllers/decidim/own_user_groups_controller.rb +3 -1
  115. data/app/controllers/decidim/pages_controller.rb +7 -15
  116. data/app/controllers/decidim/profiles_controller.rb +13 -2
  117. data/app/controllers/decidim/searches_controller.rb +11 -2
  118. data/app/controllers/decidim/user_activities_controller.rb +28 -0
  119. data/app/controllers/decidim/user_group_join_requests_controller.rb +3 -0
  120. data/app/controllers/decidim/user_interests_controller.rb +32 -0
  121. data/app/controllers/decidim/user_timeline_controller.rb +40 -0
  122. data/app/events/decidim/amendable/amendment_accepted_event.rb +23 -0
  123. data/app/events/decidim/amendable/amendment_base_event.rb +39 -0
  124. data/app/events/decidim/amendable/amendment_created_event.rb +23 -0
  125. data/app/events/decidim/amendable/amendment_rejected_event.rb +23 -0
  126. data/app/events/decidim/amendable/emendation_promoted_event.rb +23 -0
  127. data/app/events/decidim/welcome_notification_event.rb +58 -0
  128. data/app/forms/decidim/amendable/create_form.rb +54 -0
  129. data/app/forms/decidim/amendable/form.rb +22 -0
  130. data/app/forms/decidim/amendable/promote_form.rb +26 -0
  131. data/app/forms/decidim/amendable/reject_form.rb +14 -0
  132. data/app/forms/decidim/amendable/review_form.rb +35 -0
  133. data/app/forms/decidim/notifications_settings_form.rb +19 -6
  134. data/app/forms/decidim/omniauth_registration_form.rb +2 -1
  135. data/app/forms/decidim/user_group_form.rb +1 -2
  136. data/app/forms/decidim/user_interest_scope_form.rb +25 -0
  137. data/app/forms/decidim/user_interests_form.rb +22 -0
  138. data/app/helpers/decidim/amendments_helper.rb +130 -0
  139. data/app/helpers/decidim/application_helper.rb +19 -2
  140. data/app/helpers/decidim/card_helper.rb +0 -2
  141. data/app/helpers/decidim/cells_paginate_helper.rb +4 -0
  142. data/app/helpers/decidim/contextual_help_helper.rb +10 -0
  143. data/app/helpers/decidim/cta_button_helper.rb +3 -1
  144. data/app/helpers/decidim/decidim_form_helper.rb +1 -1
  145. data/app/helpers/decidim/layout_helper.rb +13 -0
  146. data/app/helpers/decidim/multi_translation_helper.rb +0 -0
  147. data/app/helpers/decidim/omniauth_helper.rb +9 -1
  148. data/app/helpers/decidim/pad_helper.rb +16 -0
  149. data/app/helpers/decidim/participatory_space_helpers.rb +15 -0
  150. data/app/helpers/decidim/searches_helper.rb +50 -6
  151. data/app/helpers/decidim/translations_helper.rb +3 -2
  152. data/app/jobs/decidim/email_notification_generator_job.rb +4 -2
  153. data/app/jobs/decidim/metric_job.rb +1 -1
  154. data/app/jobs/decidim/notification_generator_for_recipient_job.rb +2 -2
  155. data/app/jobs/decidim/notification_generator_job.rb +4 -2
  156. data/app/jobs/decidim/open_data_job.rb +16 -0
  157. data/app/mailers/decidim/messaging/conversation_mailer.rb +5 -2
  158. data/app/mailers/decidim/newsletter_mailer.rb +6 -2
  159. data/app/mailers/decidim/notification_mailer.rb +2 -2
  160. data/app/models/decidim/action_log.rb +7 -0
  161. data/app/models/decidim/amendment.rb +17 -0
  162. data/app/models/decidim/component.rb +8 -0
  163. data/app/models/decidim/contextual_help_section.rb +41 -0
  164. data/app/models/decidim/follow.rb +30 -0
  165. data/app/models/decidim/notification.rb +11 -1
  166. data/app/models/decidim/organization.rb +41 -0
  167. data/app/models/decidim/searchable_resource.rb +3 -0
  168. data/app/models/decidim/static_page.rb +11 -0
  169. data/app/models/decidim/static_page_topic.rb +12 -0
  170. data/app/models/decidim/user.rb +25 -2
  171. data/app/models/decidim/user_base_entity.rb +0 -6
  172. data/app/models/decidim/user_group.rb +29 -3
  173. data/app/permissions/decidim/permissions.rb +12 -0
  174. data/app/presenters/decidim/admin_log/organization_presenter.rb +13 -0
  175. data/app/presenters/decidim/admin_log/user_group_presenter.rb +1 -1
  176. data/app/presenters/decidim/admin_log/user_presenter.rb +1 -1
  177. data/app/presenters/decidim/hashtag_presenter.rb +7 -2
  178. data/app/presenters/decidim/metric_charts_presenter.rb +54 -21
  179. data/app/presenters/decidim/user_presenter.rb +4 -8
  180. data/app/queries/decidim/messaging/user_conversations.rb +1 -1
  181. data/app/queries/decidim/metric_manage.rb +16 -2
  182. data/app/queries/decidim/metric_measure.rb +35 -0
  183. data/app/queries/decidim/metrics/followers_metric_manage.rb +64 -0
  184. data/app/queries/decidim/metrics/participants_metric_manage.rb +72 -0
  185. data/app/queries/decidim/metrics/users_metric_manage.rb +1 -1
  186. data/app/queries/decidim/public_components.rb +32 -0
  187. data/app/resolvers/decidim/core/metric_resolver.rb +43 -11
  188. data/app/services/decidim/action_logger.rb +10 -0
  189. data/app/services/decidim/activity_search.rb +88 -13
  190. data/app/services/decidim/email_notification_generator.rb +23 -8
  191. data/app/services/decidim/events_manager.rb +9 -3
  192. data/app/services/decidim/home_activity_search.rb +80 -0
  193. data/app/services/decidim/log/diff_changeset_calculator.rb +3 -1
  194. data/app/services/decidim/notification_generator.rb +19 -7
  195. data/app/services/decidim/notification_generator_for_recipient.rb +6 -9
  196. data/app/services/decidim/open_data_exporter.rb +55 -0
  197. data/app/uploaders/decidim/open_data_uploader.rb +17 -0
  198. data/app/views/decidim/amendments/_form.html.erb +30 -0
  199. data/app/views/decidim/amendments/_review_form.html.erb +19 -0
  200. data/app/views/decidim/amendments/new.html.erb +29 -0
  201. data/app/views/decidim/amendments/review.html.erb +33 -0
  202. data/app/views/decidim/devise/registrations/new.html.erb +2 -2
  203. data/app/views/decidim/devise/sessions/new.html.erb +42 -29
  204. data/app/views/decidim/devise/shared/_links.html.erb +3 -3
  205. data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +7 -5
  206. data/app/views/decidim/follows/update_button.js.erb +1 -1
  207. data/app/views/decidim/group_members/index.html.erb +1 -1
  208. data/app/views/decidim/groups/_form.html.erb +9 -8
  209. data/app/views/decidim/groups/new.html.erb +3 -0
  210. data/app/views/decidim/{pages/home.html.erb → homepage/show.html.erb} +0 -0
  211. data/app/views/decidim/messaging/conversation_mailer/new_conversation.html.erb +6 -0
  212. data/app/views/decidim/messaging/conversation_mailer/new_message.html.erb +6 -0
  213. data/app/views/decidim/messaging/conversations/_message.html.erb +14 -0
  214. data/app/views/decidim/messaging/conversations/_reply.html.erb +11 -0
  215. data/app/views/decidim/messaging/conversations/_show.html.erb +21 -0
  216. data/app/views/decidim/messaging/conversations/_start.html.erb +12 -0
  217. data/app/views/decidim/messaging/conversations/create.js.erb +1 -1
  218. data/app/views/decidim/messaging/conversations/index.html.erb +51 -1
  219. data/app/views/decidim/messaging/conversations/new.html.erb +5 -1
  220. data/app/views/decidim/messaging/conversations/show.html.erb +9 -1
  221. data/app/views/decidim/messaging/conversations/update.js.erb +1 -1
  222. data/app/views/decidim/notification_mailer/event_received.html.erb +13 -3
  223. data/app/views/decidim/notifications/index.html.erb +5 -1
  224. data/app/views/decidim/notifications_settings/show.html.erb +19 -0
  225. data/app/views/decidim/pages/_standalone.html.erb +21 -0
  226. data/app/views/decidim/pages/_tabbed.html.erb +45 -0
  227. data/app/views/decidim/pages/index.html.erb +68 -29
  228. data/app/views/decidim/pages/show.html.erb +28 -0
  229. data/app/views/decidim/profiles/show.html.erb +1 -1
  230. data/app/views/decidim/searches/_count.html.erb +26 -1
  231. data/app/views/decidim/searches/_filters.html.erb +40 -17
  232. data/app/views/decidim/searches/index.html.erb +5 -16
  233. data/app/views/decidim/searches/index.js.erb +5 -3
  234. data/app/views/decidim/shared/_extended_navigation_bar.html.erb +50 -0
  235. data/app/views/decidim/shared/_floating_help.html.erb +30 -0
  236. data/app/views/decidim/shared/_follow_button.html.erb +1 -1
  237. data/app/views/decidim/shared/_login_modal.html.erb +35 -22
  238. data/app/views/decidim/shared/_results_per_page.html.erb +1 -1
  239. data/app/views/decidim/shared/_share_modal.html.erb +1 -1
  240. data/app/views/decidim/user_activities/index.html.erb +5 -0
  241. data/app/views/decidim/user_interests/_areas.html.erb +14 -0
  242. data/app/views/decidim/user_interests/_scopes.html.erb +15 -0
  243. data/app/views/decidim/user_interests/show.html.erb +12 -0
  244. data/app/views/decidim/user_timeline/index.html.erb +4 -0
  245. data/app/views/layouts/decidim/_user_menu.html.erb +1 -1
  246. data/app/views/layouts/decidim/_wrapper.html.erb +12 -5
  247. data/config/locales/ca.yml +199 -13
  248. data/config/locales/de.yml +200 -13
  249. data/config/locales/en.yml +200 -13
  250. data/config/locales/es-PY.yml +200 -13
  251. data/config/locales/es.yml +200 -13
  252. data/config/locales/eu.yml +200 -13
  253. data/config/locales/fi-pl.yml +200 -13
  254. data/config/locales/fi.yml +200 -13
  255. data/config/locales/fr.yml +200 -13
  256. data/config/locales/gl.yml +200 -13
  257. data/config/locales/hu.yml +200 -13
  258. data/config/locales/id-ID.yml +198 -13
  259. data/config/locales/it.yml +200 -13
  260. data/config/locales/nl.yml +200 -13
  261. data/config/locales/pl.yml +204 -13
  262. data/config/locales/pt-BR.yml +200 -13
  263. data/config/locales/pt.yml +200 -13
  264. data/config/locales/ru.yml +2 -16
  265. data/config/locales/sv.yml +200 -13
  266. data/config/locales/tr-TR.yml +200 -13
  267. data/config/locales/uk.yml +2 -16
  268. data/config/routes.rb +27 -1
  269. data/db/migrate/20171212103803_create_unique_nicknames.rb +1 -1
  270. data/db/migrate/20180221101934_fix_nickname_index.rb +1 -1
  271. data/db/migrate/20180706104107_add_nickname_to_managed_users.rb +1 -1
  272. data/db/migrate/20180720114847_create_decidim_amendments.rb +21 -0
  273. data/db/migrate/20181001124950_move_users_groups_to_users_table.rb +1 -1
  274. data/db/migrate/20181022090732_add_columns_to_pages.rb +20 -0
  275. data/db/migrate/20181023104416_add_static_page_topics.rb +15 -0
  276. data/db/migrate/20181025082245_add_timestamps_to_components.rb +12 -0
  277. data/db/migrate/20181029121244_add_welcome_notification.rb +13 -0
  278. data/db/migrate/20181108131058_add_users_registration_mode_to_organizations.rb +7 -0
  279. data/db/migrate/20181113101935_create_decidim_contextual_help_sections.rb +11 -0
  280. data/db/migrate/20181115102958_add_following_and_followers_counters_to_users.rb +26 -0
  281. data/db/migrate/20181119140636_add_columns_to_static_page_topic.rb +10 -0
  282. data/db/migrate/20181126145142_add_id_documents_fields_to_org.rb +13 -0
  283. data/db/migrate/20181204110723_remove_following_users_count_from_users.rb +17 -0
  284. data/db/migrate/20181211080834_add_scope_to_action_logs.rb +7 -0
  285. data/db/migrate/20181211090933_add_area_to_action_logs.rb +7 -0
  286. data/db/migrate/20181214101250_add_notification_types_to_users.rb +12 -0
  287. data/db/migrate/20181218171503_add_user_groups_switch_to_organizations.rb +8 -0
  288. data/db/seeds.rb +6 -1
  289. data/lib/decidim/amendable.rb +86 -0
  290. data/lib/decidim/api/component_interface.rb +4 -0
  291. data/lib/decidim/api/participatory_space_interface.rb +7 -0
  292. data/lib/decidim/api/scopable_interface.rb +1 -1
  293. data/lib/decidim/coauthorable.rb +16 -7
  294. data/lib/decidim/component_manifest.rb +3 -2
  295. data/lib/decidim/components/export_manifest.rb +13 -2
  296. data/lib/decidim/content_parsers/hashtag_parser.rb +48 -15
  297. data/lib/decidim/content_parsers/user_parser.rb +26 -10
  298. data/lib/decidim/content_renderers/hashtag_renderer.rb +46 -23
  299. data/lib/decidim/core.rb +40 -2
  300. data/lib/decidim/core/engine.rb +46 -12
  301. data/lib/decidim/core/test.rb +11 -0
  302. data/lib/decidim/core/test/factories.rb +44 -15
  303. data/lib/decidim/core/test/shared_examples/amendable/accept_amendment_examples.rb +57 -0
  304. data/lib/decidim/core/test/shared_examples/amendable/amendment_accepted_event_examples.rb +43 -0
  305. data/lib/decidim/core/test/shared_examples/amendable/amendment_created_event_examples.rb +48 -0
  306. data/lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb +45 -0
  307. data/lib/decidim/core/test/shared_examples/amendable/amendment_promoted_event_examples.rb +43 -0
  308. data/lib/decidim/core/test/shared_examples/amendable/amendment_rejected_event_examples.rb +43 -0
  309. data/lib/decidim/core/test/shared_examples/amendable/create_amendment_examples.rb +78 -0
  310. data/lib/decidim/core/test/shared_examples/amendable/promote_amendment_examples.rb +43 -0
  311. data/lib/decidim/core/test/shared_examples/amendable/reject_amendment_examples.rb +41 -0
  312. data/lib/decidim/core/test/shared_examples/amendable/withdraw_amendment_examples.rb +29 -0
  313. data/lib/decidim/core/test/shared_examples/has_contextual_help.rb +30 -0
  314. data/lib/decidim/core/test/shared_examples/resourceable.rb +17 -0
  315. data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +1 -1
  316. data/lib/decidim/core/test/shared_examples/simple_event.rb +24 -2
  317. data/lib/decidim/core/version.rb +1 -1
  318. data/lib/decidim/events/base_event.rb +17 -12
  319. data/lib/decidim/events/simple_event.rb +21 -2
  320. data/lib/decidim/form_builder.rb +8 -0
  321. data/lib/decidim/gamification/badge_scorer.rb +3 -3
  322. data/lib/decidim/has_component.rb +1 -1
  323. data/lib/decidim/hashtag.rb +0 -2
  324. data/lib/decidim/hashtaggable.rb +2 -2
  325. data/lib/decidim/metric_manifest.rb +17 -2
  326. data/lib/decidim/metric_operation.rb +59 -0
  327. data/lib/decidim/metric_operation_manifest.rb +20 -0
  328. data/lib/decidim/metric_registry.rb +57 -19
  329. data/lib/decidim/paddable.rb +82 -0
  330. data/lib/decidim/participable.rb +24 -0
  331. data/lib/decidim/participatory_space_resourceable.rb +12 -0
  332. data/lib/decidim/query_extensions.rb +8 -1
  333. data/lib/decidim/resource_manifest.rb +5 -1
  334. data/lib/decidim/resourceable.rb +12 -0
  335. data/lib/decidim/searchable.rb +13 -4
  336. data/lib/decidim/settings_manifest.rb +2 -1
  337. data/lib/tasks/decidim_data_portability_tasks.rake +86 -0
  338. data/lib/tasks/decidim_open_data_tasks.rake +12 -0
  339. data/lib/tasks/decidim_tasks.rake +1 -83
  340. data/vendor/assets/javascripts/tribute.js +307 -145
  341. metadata +156 -22
  342. data/app/cells/decidim/conversation/show.erb +0 -18
  343. data/app/cells/decidim/conversation_cell.rb +0 -23
  344. data/app/cells/decidim/conversation_header/show.erb +0 -17
  345. data/app/cells/decidim/conversation_header_cell.rb +0 -16
  346. data/app/cells/decidim/conversations/show.erb +0 -45
  347. data/app/cells/decidim/conversations_cell.rb +0 -24
  348. data/app/cells/decidim/message/show.erb +0 -15
  349. data/app/cells/decidim/message_cell.rb +0 -23
  350. data/app/cells/decidim/new_conversation/show.erb +0 -19
  351. data/app/cells/decidim/new_conversation_cell.rb +0 -19
  352. data/app/views/decidim/pages/decidim_page.html.erb +0 -31
  353. data/app/views/decidim/searches/_results.html.erb +0 -5
  354. data/app/views/decidim/shared/_author_reference.html.erb +0 -1
@@ -13,7 +13,7 @@ module Decidim
13
13
  def query
14
14
  return @query if @query
15
15
 
16
- @query = Decidim::User
16
+ @query = Decidim::User.where(organization: @organization)
17
17
  @query = @query.where("confirmed_at <= ?", end_time).not_managed.confirmed
18
18
  @query
19
19
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This query finds the published components for all public participatory
5
+ # spaces in the given organization. Can filter by manifest name.
6
+ class PublicComponents < Rectify::Query
7
+ def self.for(organization, manifest_name: nil)
8
+ new(organization, manifest_name: manifest_name).query
9
+ end
10
+
11
+ def initialize(organization, manifest_name: nil)
12
+ @organization = organization
13
+ @manifest_name = manifest_name
14
+ end
15
+
16
+ def query
17
+ results = Decidim::Component.where(participatory_space: public_spaces).published
18
+ results = results.where(manifest_name: manifest_name) if manifest_name.present?
19
+ results
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :organization, :manifest_name
25
+
26
+ def public_spaces
27
+ Decidim.participatory_space_manifests.flat_map do |manifest|
28
+ manifest.participatory_spaces.call(organization).public_spaces
29
+ end
30
+ end
31
+ end
32
+ end
@@ -6,33 +6,65 @@ module Decidim
6
6
  class MetricResolver
7
7
  attr_reader :name
8
8
 
9
- def initialize(name, organization)
9
+ #
10
+ # - name: name identifier of metric
11
+ # - organization: Decidim::Organization scoping
12
+ # - filters: hash of attr - value to filter results
13
+ #
14
+ def initialize(name, organization, filters = {})
10
15
  @name = name
11
16
  @organization = organization
17
+ @filters = filters
12
18
  @group_by = :day
13
19
  @counter_field = :cumulative
14
20
  end
15
21
 
16
22
  def count
17
- metric_scope.max.try(:last) || 0
23
+ resolve.max.try(:last) || 0
18
24
  end
19
25
 
20
26
  def history
21
- metric_scope
27
+ resolve
22
28
  end
23
29
 
24
30
  private
25
31
 
26
- def metric_scope
27
- Decidim::Metric
28
- .where(metric_type: name, organization: organization)
29
- .group(group_by)
30
- .order("#{group_by} DESC")
31
- .limit(60)
32
- .sum(counter_field)
32
+ def resolve
33
+ return @records if @records
34
+
35
+ scope
36
+ filter
37
+ group
38
+ sum
39
+ @records
40
+ end
41
+
42
+ def scope
43
+ @records = Decidim::Metric
44
+ .where(metric_type: name, organization: organization)
45
+ end
46
+
47
+ # Only key name attributes in Decidim::Metric will be applied
48
+ def filter
49
+ @filters.each do |key, value|
50
+ next unless Decidim::Metric.column_names.include? key.to_s
51
+ @records = @records.where("#{key}": value)
52
+ end
53
+ end
54
+
55
+ def group
56
+ @records = @records
57
+ .group(group_by)
58
+ .order("#{group_by} DESC")
59
+ end
60
+
61
+ def sum
62
+ @records = @records
63
+ .limit(60)
64
+ .sum(counter_field)
33
65
  end
34
66
 
35
- attr_reader :organization, :group_by, :counter_field
67
+ attr_reader :organization, :filters, :group_by, :counter_field
36
68
  end
37
69
  end
38
70
  end
@@ -53,6 +53,8 @@ module Decidim
53
53
  resource_type: resource.class.name,
54
54
  participatory_space: participatory_space,
55
55
  component: component,
56
+ area: area,
57
+ scope: scope,
56
58
  version_id: version_id,
57
59
  extra: extra_data,
58
60
  visibility: visibility
@@ -76,6 +78,14 @@ module Decidim
76
78
  resource.participatory_space if resource.respond_to?(:participatory_space)
77
79
  end
78
80
 
81
+ def area
82
+ resource.try(:area) || participatory_space.try(:area)
83
+ end
84
+
85
+ def scope
86
+ resource.try(:scope) || participatory_space.try(:scope)
87
+ end
88
+
79
89
  def title_for(resource)
80
90
  resource.try(:title) || resource.try(:name) || resource.try(:subject)
81
91
  end
@@ -2,13 +2,35 @@
2
2
 
3
3
  module Decidim
4
4
  # A class to search for recent activity performed in a Decidim Organization.
5
+ # It is intended to be used in the user profile, to retrieve activity and
6
+ # timeline for that user.
7
+ #
8
+ # It will return any action for a given resource, except `create` on resources
9
+ # that implement the `Decidim::Publicable` concern to avoid leaking private
10
+ # data.
11
+ #
12
+ # Possible options:
13
+ #
14
+ # :organization - the `Decidim::Organization` to scope to search. Required.
15
+ # :user - an optional `Decidim::USer` that performed the activites
16
+ # :follows - a collection of `Decidim::Follow` resources. It will return any
17
+ # activity affecting any of these resources, performed by any of them or
18
+ # contained in any of them as spaces.
19
+ # :scopes - a collection of `Decidim::Scope`. It will return any activity that
20
+ # took place in any of those scopes.
5
21
  class ActivitySearch < Searchlight::Search
6
22
  # Needed by Searchlight, this is the base query that will be used to
7
23
  # append other criteria to the search.
8
24
  def base_query
9
- ActionLog
10
- .where(visibility: %w(public-only all))
11
- .where(organization: options.fetch(:organization))
25
+ query = ActionLog
26
+ .where(visibility: %w(public-only all))
27
+ .where(organization: options.fetch(:organization))
28
+
29
+ query = query.where(user: options[:user]) if options[:user]
30
+
31
+ query = filter_follows(query)
32
+
33
+ query
12
34
  end
13
35
 
14
36
  # Overwrites the default Searchlight run method since we want to return
@@ -53,24 +75,77 @@ module Decidim
53
75
  end
54
76
 
55
77
  def scope_for(resource_type)
56
- action = if publicable_resource_types.include?(resource_type)
57
- "publish"
58
- else
59
- "create"
60
- end
61
-
62
- query.where(resource_type: resource_type, action: action)
78
+ if publicable_resource_types.include?(resource_type)
79
+ query.where(resource_type: resource_type).where.not(action: "create")
80
+ else
81
+ query.where(resource_type: resource_type)
82
+ end
63
83
  end
64
84
 
65
85
  def all_resources_scope
66
86
  query
67
87
  .where(
68
- "(action = ? AND resource_type IN (?)) OR (action = ? AND resource_type IN (?))",
69
- "publish",
70
- publicable_resource_types,
88
+ "(action <> ? AND resource_type IN (?)) OR (resource_type IN (?))",
71
89
  "create",
90
+ publicable_resource_types,
72
91
  (resource_types - publicable_resource_types)
73
92
  )
74
93
  end
94
+
95
+ def filter_follows(query)
96
+ follows = options[:follows]
97
+ interesting_scopes = options[:scopes]
98
+ conditions = []
99
+
100
+ if follows.present?
101
+ conditions += follows.group_by(&:decidim_followable_type).map do |type, grouped_follows|
102
+ Decidim::ActionLog.arel_table[:resource_type].eq(type).and(
103
+ Decidim::ActionLog.arel_table[:resource_id].in(grouped_follows.map(&:decidim_followable_id))
104
+ )
105
+ end
106
+
107
+ conditions += followed_users_conditions(follows)
108
+ conditions += followed_spaces_conditions(follows)
109
+ end
110
+
111
+ conditions += interesting_scopes_conditions(interesting_scopes)
112
+
113
+ return query if conditions.empty?
114
+
115
+ chained_conditions = conditions.inject do |previous_condition, condition|
116
+ next condition unless previous_condition
117
+ previous_condition.or(condition)
118
+ end
119
+
120
+ query.where(chained_conditions)
121
+ end
122
+
123
+ def followed_users_conditions(follows)
124
+ followed_users = follows.where(decidim_followable_type: "Decidim::UserBaseEntity")
125
+ return [] if followed_users.empty?
126
+
127
+ [Decidim::ActionLog.arel_table[:decidim_user_id].in(followed_users.map(&:decidim_followable_id))]
128
+ end
129
+
130
+ def followed_spaces_conditions(follows)
131
+ followed_spaces = follows.where(decidim_followable_type: participatory_space_classes)
132
+ return [] if followed_spaces.empty?
133
+
134
+ followed_spaces.group_by(&:decidim_followable_type).map do |type, grouped_follows|
135
+ Decidim::ActionLog.arel_table[:participatory_space_type].eq(type).and(
136
+ Decidim::ActionLog.arel_table[:participatory_space_id].in(grouped_follows.map(&:decidim_followable_id))
137
+ )
138
+ end
139
+ end
140
+
141
+ def interesting_scopes_conditions(interesting_scopes)
142
+ return [] if interesting_scopes.blank?
143
+
144
+ [Decidim::ActionLog.arel_table[:decidim_scope_id].in(interesting_scopes.map(&:id))]
145
+ end
146
+
147
+ def participatory_space_classes
148
+ Decidim.participatory_space_manifests.map(&:model_class_name)
149
+ end
75
150
  end
76
151
  end
@@ -12,14 +12,21 @@ module Decidim
12
12
  # event - A String with the name of the event.
13
13
  # event_class - A class that wraps the event.
14
14
  # resource - an instance of a class implementing the `Decidim::Resource` concern.
15
+ # followers - a collection of Users that receive the notification because
16
+ # they're following it
17
+ # affected_users - a collection of Users that receive the notification because
18
+ # they're affected by it
15
19
  # extra - a Hash with extra information to be included in the notification.
16
- def initialize(event, event_class, resource, recipient_ids, extra)
20
+ # rubocop:disable Metrics/ParameterLists
21
+ def initialize(event, event_class, resource, followers, affected_users, extra)
17
22
  @event = event
18
23
  @event_class = event_class
19
24
  @resource = resource
20
- @recipient_ids = recipient_ids
25
+ @followers = followers
26
+ @affected_users = affected_users
21
27
  @extra = extra
22
28
  end
29
+ # rubocop:enable Metrics/ParameterLists
23
30
 
24
31
  # Schedules a job for each recipient to send the email. Returns `nil`
25
32
  # if the resource is not resource or if it is not present.
@@ -29,23 +36,30 @@ module Decidim
29
36
  return unless resource
30
37
  return unless event_class.types.include?(:email)
31
38
 
32
- recipient_ids.each do |recipient_id|
33
- send_email_to(recipient_id)
39
+ followers.each do |recipient|
40
+ next unless ["all", "followed-only"].include?(recipient.notification_types)
41
+ send_email_to(recipient, user_role: :follower)
42
+ end
43
+
44
+ affected_users.each do |recipient|
45
+ next unless ["all", "own-only"].include?(recipient.notification_types)
46
+ send_email_to(recipient, user_role: :affected_user)
34
47
  end
35
48
  end
36
49
 
37
50
  private
38
51
 
39
- attr_reader :event, :event_class, :resource, :recipient_ids, :extra
52
+ attr_reader :event, :event_class, :resource, :followers, :affected_users, :extra
40
53
 
41
54
  # Private: sends the notification email to the user if they have the
42
55
  # `email_on_notification` flag active.
43
56
  #
44
- # recipient_id - The ID of the user that will receive the email.
57
+ # recipient - The user that will receive the email.
58
+ # user_role - the role the user takes for this notification (either
59
+ # `:follower` or `:affected_user`)
45
60
  #
46
61
  # Returns nothing.
47
- def send_email_to(recipient_id)
48
- recipient = Decidim::User.find_by(id: recipient_id)
62
+ def send_email_to(recipient, user_role:)
49
63
  return unless recipient
50
64
  return unless recipient.email_on_notification?
51
65
 
@@ -55,6 +69,7 @@ module Decidim
55
69
  event_class.name,
56
70
  resource,
57
71
  recipient,
72
+ user_role.to_s,
58
73
  extra
59
74
  )
60
75
  .deliver_later
@@ -14,19 +14,25 @@ module Decidim
14
14
  # the resource and builds the needed information to publish the event to
15
15
  # the different subscribers in the system.
16
16
  # resource - an instance of a class that received the event.
17
- # recipient_ids - an Array of IDs of the users that will receive the event
17
+ # affected_users - a collection of `Decidim::Users` that are affected by the
18
+ # event and will receive a notification about it.
19
+ # followers - a collection of `Decidim::Users` that should be notified about
20
+ # the event, even though it doesn't affect them directly
18
21
  # extra - a Hash with extra information to be included in the notification.
19
22
  #
20
23
  # Returns nothing.
21
- def self.publish(event:, event_class: Decidim::Events::BaseEvent, resource:, recipient_ids:, extra: {})
24
+ # rubocop:disable Metrics/ParameterLists
25
+ def self.publish(event:, event_class: Decidim::Events::BaseEvent, resource:, affected_users: [], followers: [], extra: {})
22
26
  ActiveSupport::Notifications.publish(
23
27
  event,
24
28
  event_class: event_class.name,
25
29
  resource: resource,
26
- recipient_ids: recipient_ids.compact.uniq,
30
+ affected_users: affected_users.uniq.compact,
31
+ followers: followers.uniq.compact,
27
32
  extra: extra
28
33
  )
29
34
  end
35
+ # rubocop:enable Metrics/ParameterLists
30
36
 
31
37
  # Subscribes to the given event, and runs the block every time that event
32
38
  # is received.
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # A class to search for recent activity performed in a Decidim Organization.
5
+ # It will only return the `Decidim::ActionLog` rows that have an action as
6
+ # `created` or `published`.
7
+ #
8
+ # This class is thought to be used in the `LastActivityCell` uniquely.
9
+ class HomeActivitySearch < Searchlight::Search
10
+ # Needed by Searchlight, this is the base query that will be used to
11
+ # append other criteria to the search.
12
+ def base_query
13
+ ActionLog
14
+ .where(visibility: %w(public-only all))
15
+ .where(organization: options.fetch(:organization))
16
+ end
17
+
18
+ # Overwrites the default Searchlight run method since we want to return
19
+ # activities in an specific order but we need to set it at the end of the chain.
20
+ def run
21
+ super.order(created_at: :desc)
22
+ end
23
+
24
+ # Adds a constrain to filter by resource type(s).
25
+ def search_resource_type
26
+ if resource_types.include?(resource_type)
27
+ scope_for(resource_type)
28
+ else
29
+ all_resources_scope
30
+ end
31
+ end
32
+
33
+ # All the resource types that are eligible to be included as an activity.
34
+ def resource_types
35
+ @resource_types ||= %w(
36
+ Decidim::Accountability::Result
37
+ Decidim::Blogs::Post
38
+ Decidim::Comments::Comment
39
+ Decidim::Consultations::Question
40
+ Decidim::Debates::Debate
41
+ Decidim::Meetings::Meeting
42
+ Decidim::Proposals::Proposal
43
+ Decidim::Surveys::Survey
44
+ Decidim::Assembly
45
+ Decidim::Consultation
46
+ Decidim::Initiative
47
+ Decidim::ParticipatoryProcess
48
+ ).select do |klass|
49
+ klass.safe_constantize.present?
50
+ end
51
+ end
52
+
53
+ private
54
+
55
+ def publicable_resource_types
56
+ @publicable_resource_types ||= resource_types.select { |klass| klass.constantize.column_names.include?("published_at") }
57
+ end
58
+
59
+ def scope_for(resource_type)
60
+ action = if publicable_resource_types.include?(resource_type)
61
+ "publish"
62
+ else
63
+ "create"
64
+ end
65
+
66
+ query.where(resource_type: resource_type, action: action)
67
+ end
68
+
69
+ def all_resources_scope
70
+ query
71
+ .where(
72
+ "(action = ? AND resource_type IN (?)) OR (action = ? AND resource_type IN (?))",
73
+ "publish",
74
+ publicable_resource_types,
75
+ "create",
76
+ (resource_types - publicable_resource_types)
77
+ )
78
+ end
79
+ end
80
+ end