decidim-admin 0.28.5 → 0.29.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -0
  3. data/app/cells/decidim/admin/content_block_cell.rb +0 -1
  4. data/app/cells/decidim/admin/results_per_page/show.erb +2 -2
  5. data/app/cells/decidim/admin/results_per_page_cell.rb +0 -2
  6. data/app/commands/decidim/admin/block_user.rb +0 -1
  7. data/app/commands/decidim/admin/create_area.rb +4 -32
  8. data/app/commands/decidim/admin/create_area_type.rb +4 -33
  9. data/app/commands/decidim/admin/create_attachment.rb +5 -4
  10. data/app/commands/decidim/admin/create_attachment_collection.rb +3 -3
  11. data/app/commands/decidim/admin/create_category.rb +4 -37
  12. data/app/commands/decidim/admin/create_component.rb +7 -40
  13. data/app/commands/decidim/admin/create_newsletter.rb +11 -29
  14. data/app/commands/decidim/admin/create_participatory_space_private_user.rb +4 -4
  15. data/app/commands/decidim/admin/create_scope.rb +15 -32
  16. data/app/commands/decidim/admin/create_scope_type.rb +3 -32
  17. data/app/commands/decidim/admin/create_static_page.rb +6 -47
  18. data/app/commands/decidim/admin/create_static_page_topic.rb +4 -26
  19. data/app/commands/decidim/admin/deliver_newsletter.rb +4 -5
  20. data/app/commands/decidim/admin/destroy_area.rb +2 -25
  21. data/app/commands/decidim/admin/destroy_category.rb +4 -29
  22. data/app/commands/decidim/admin/destroy_component.rb +5 -43
  23. data/app/commands/decidim/admin/destroy_newsletter.rb +2 -30
  24. data/app/commands/decidim/admin/destroy_participatory_space_private_user.rb +5 -32
  25. data/app/commands/decidim/admin/destroy_scope.rb +6 -33
  26. data/app/commands/decidim/admin/officialize_user.rb +1 -1
  27. data/app/commands/decidim/admin/participatory_space/create_admin.rb +4 -4
  28. data/app/commands/decidim/admin/process_participatory_space_private_user_import_csv.rb +5 -4
  29. data/app/commands/decidim/admin/promote_managed_user.rb +4 -5
  30. data/app/commands/decidim/admin/unofficialize_user.rb +1 -1
  31. data/app/commands/decidim/admin/update_area.rb +2 -41
  32. data/app/commands/decidim/admin/update_area_type.rb +2 -42
  33. data/app/commands/decidim/admin/update_attachment.rb +10 -7
  34. data/app/commands/decidim/admin/update_attachment_collection.rb +3 -3
  35. data/app/commands/decidim/admin/update_category.rb +2 -45
  36. data/app/commands/decidim/admin/update_component.rb +4 -5
  37. data/app/commands/decidim/admin/update_component_permissions.rb +3 -3
  38. data/app/commands/decidim/admin/{update_external_domain_whitelist.rb → update_external_domain_allowlist.rb} +6 -5
  39. data/app/commands/decidim/admin/update_help_sections.rb +6 -3
  40. data/app/commands/decidim/admin/update_newsletter.rb +8 -8
  41. data/app/commands/decidim/admin/update_organization.rb +9 -53
  42. data/app/commands/decidim/admin/update_organization_appearance.rb +10 -81
  43. data/app/commands/decidim/admin/update_scope.rb +7 -40
  44. data/app/commands/decidim/admin/update_scope_type.rb +2 -42
  45. data/app/commands/decidim/admin/update_static_page.rb +5 -46
  46. data/app/commands/decidim/admin/update_static_page_topic.rb +2 -43
  47. data/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
  48. data/app/controllers/concerns/decidim/admin/content_blocks/landing_page.rb +2 -2
  49. data/app/controllers/concerns/decidim/admin/filterable.rb +79 -4
  50. data/app/controllers/concerns/decidim/admin/global_moderation_context.rb +1 -1
  51. data/app/controllers/concerns/decidim/admin/needs_admin_tos_accepted.rb +0 -7
  52. data/app/controllers/concerns/decidim/admin/paginable.rb +20 -0
  53. data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +1 -1
  54. data/app/controllers/decidim/admin/application_controller.rb +2 -1
  55. data/app/controllers/decidim/admin/area_types_controller.rb +8 -9
  56. data/app/controllers/decidim/admin/areas_controller.rb +1 -1
  57. data/app/controllers/decidim/admin/authorization_workflows_controller.rb +1 -1
  58. data/app/controllers/decidim/admin/block_user_controller.rb +1 -1
  59. data/app/controllers/decidim/admin/categories_controller.rb +2 -2
  60. data/app/controllers/decidim/admin/component_permissions_controller.rb +1 -1
  61. data/app/controllers/decidim/admin/components_controller.rb +2 -2
  62. data/app/controllers/decidim/admin/concerns/has_attachment_collections.rb +2 -2
  63. data/app/controllers/decidim/admin/concerns/has_attachments.rb +2 -2
  64. data/app/controllers/decidim/admin/concerns/has_private_users.rb +1 -1
  65. data/app/controllers/decidim/admin/concerns/has_private_users_csv_import.rb +1 -1
  66. data/app/controllers/decidim/admin/conflicts_controller.rb +6 -14
  67. data/app/controllers/decidim/admin/help_sections_controller.rb +1 -1
  68. data/app/controllers/decidim/admin/impersonations_controller.rb +0 -1
  69. data/app/controllers/decidim/admin/managed_users/promotions_controller.rb +1 -1
  70. data/app/controllers/decidim/admin/moderations/reports_controller.rb +4 -4
  71. data/app/controllers/decidim/admin/moderations_controller.rb +7 -7
  72. data/app/controllers/decidim/admin/newsletter_templates_controller.rb +1 -1
  73. data/app/controllers/decidim/admin/newsletters_controller.rb +6 -7
  74. data/app/controllers/decidim/admin/organization_appearance_controller.rb +1 -1
  75. data/app/controllers/decidim/admin/organization_controller.rb +1 -1
  76. data/app/controllers/decidim/admin/{organization_external_domain_whitelist_controller.rb → organization_external_domain_allowlist_controller.rb} +7 -7
  77. data/app/controllers/decidim/admin/scope_types_controller.rb +7 -8
  78. data/app/controllers/decidim/admin/scopes_controller.rb +1 -1
  79. data/app/controllers/decidim/admin/share_tokens_controller.rb +1 -1
  80. data/app/controllers/decidim/admin/static_page_topics_controller.rb +2 -2
  81. data/app/controllers/decidim/admin/static_pages_controller.rb +2 -2
  82. data/app/forms/decidim/admin/attachment_form.rb +7 -1
  83. data/app/forms/decidim/admin/help_section_form.rb +1 -1
  84. data/app/forms/decidim/admin/impersonate_user_form.rb +0 -5
  85. data/app/forms/decidim/admin/organization_appearance_form.rb +2 -5
  86. data/app/forms/decidim/admin/{organization_external_domain_whitelist_form.rb → organization_external_domain_allowlist_form.rb} +3 -3
  87. data/app/forms/decidim/admin/organization_form.rb +4 -4
  88. data/app/forms/decidim/admin/static_page_form.rb +1 -2
  89. data/app/forms/decidim/admin/transfer_user_form.rb +0 -15
  90. data/app/helpers/decidim/admin/application_helper.rb +0 -13
  91. data/app/helpers/decidim/admin/filterable_helper.rb +19 -3
  92. data/app/helpers/decidim/admin/moderations/reports_helper.rb +3 -1
  93. data/app/helpers/decidim/admin/newsletters_helper.rb +3 -3
  94. data/app/helpers/decidim/admin/paginable/per_page_helper.rb +22 -0
  95. data/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb +2 -2
  96. data/app/packs/entrypoints/decidim_admin.js +4 -1
  97. data/app/packs/src/decidim/admin/application.js +19 -15
  98. data/app/packs/src/decidim/admin/css_preview.js +39 -0
  99. data/app/packs/src/decidim/admin/form.js +18 -1
  100. data/app/packs/src/decidim/admin/newsletters.js +9 -18
  101. data/app/packs/src/decidim/admin/participatory_space_search.js +1 -1
  102. data/app/packs/src/decidim/admin/proposal_infinite_edit.js +2 -2
  103. data/app/packs/src/decidim/admin/sync_radio_buttons.js +27 -0
  104. data/app/packs/src/decidim/admin/text_copy.js +19 -0
  105. data/app/packs/stylesheets/decidim/admin/_cards.scss +1 -1
  106. data/app/packs/stylesheets/decidim/admin/_datepicker.scss +62 -0
  107. data/app/packs/stylesheets/decidim/admin/_item_edit.scss +1 -1
  108. data/app/packs/stylesheets/decidim/admin/_item_show.scss +8 -0
  109. data/app/packs/stylesheets/decidim/admin/_moderations.scss +0 -8
  110. data/app/packs/stylesheets/decidim/admin/_proposal_status.scss +5 -0
  111. data/app/packs/stylesheets/decidim/admin/application.scss +2 -0
  112. data/app/permissions/decidim/admin/permissions.rb +2 -2
  113. data/app/queries/decidim/admin/newsletter_recipients.rb +5 -9
  114. data/app/queries/decidim/admin/user_filter.rb +4 -4
  115. data/app/queries/decidim/admin/user_groups_evaluation.rb +1 -1
  116. data/app/views/decidim/admin/attachment_collections/index.html.erb +1 -1
  117. data/app/views/decidim/admin/attachments/_form.html.erb +21 -2
  118. data/app/views/decidim/admin/attachments/index.html.erb +2 -2
  119. data/app/views/decidim/admin/authorization_workflows/index.html.erb +26 -8
  120. data/app/views/decidim/admin/block_user/new.html.erb +1 -1
  121. data/app/views/decidim/admin/categories/index.html.erb +2 -2
  122. data/app/views/decidim/admin/components/_form.html.erb +1 -1
  123. data/app/views/decidim/admin/components/index.html.erb +1 -5
  124. data/app/views/decidim/admin/conflicts/edit.html.erb +11 -21
  125. data/app/views/decidim/admin/conflicts/index.html.erb +6 -29
  126. data/app/views/decidim/admin/dashboard/_pending_moderations.html.erb +1 -1
  127. data/app/views/decidim/admin/dashboard/show.html.erb +1 -1
  128. data/app/views/decidim/admin/exports/_dropdown.html.erb +6 -6
  129. data/app/views/decidim/admin/impersonatable_users/index.html.erb +3 -3
  130. data/app/views/decidim/admin/imports/_dropdown.html.erb +5 -7
  131. data/app/views/decidim/admin/imports/new.html.erb +6 -7
  132. data/app/views/decidim/admin/logs/_filters.html.erb +3 -3
  133. data/app/views/decidim/admin/managed_users/promotions/new.html.erb +1 -1
  134. data/app/views/decidim/admin/moderated_users/index.html.erb +4 -4
  135. data/app/views/decidim/admin/moderations/index.html.erb +5 -5
  136. data/app/views/decidim/admin/moderations/reports/index.html.erb +6 -6
  137. data/app/views/decidim/admin/moderations/reports/show.html.erb +4 -4
  138. data/app/views/decidim/admin/newsletter_templates/index.html.erb +3 -2
  139. data/app/views/decidim/admin/newsletter_templates/show.html.erb +7 -7
  140. data/app/views/decidim/admin/newsletters/index.html.erb +1 -1
  141. data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +6 -7
  142. data/app/views/decidim/admin/newsletters/show.html.erb +1 -1
  143. data/app/views/decidim/admin/organization/_form.html.erb +3 -3
  144. data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +0 -3
  145. data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +5 -5
  146. data/app/views/decidim/admin/organization_appearance/form/_minimap.html.erb +3 -3
  147. data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/_external_domain.html.erb +4 -4
  148. data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/_form.html.erb +2 -2
  149. data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/edit.html.erb +2 -2
  150. data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +1 -1
  151. data/app/views/decidim/admin/participatory_space_private_users_csv_imports/new.html.erb +1 -1
  152. data/app/views/decidim/admin/share_tokens/_share_tokens.html.erb +1 -1
  153. data/app/views/decidim/admin/shared/_adjacent_navigation.html.erb +30 -0
  154. data/app/views/decidim/admin/shared/_admin_confirm_modal.html.erb +7 -7
  155. data/app/views/decidim/admin/shared/_filters.html.erb +1 -1
  156. data/app/views/decidim/admin/shared/_gallery.html.erb +1 -1
  157. data/app/views/decidim/admin/shared/landing_page/_content_blocks.html.erb +2 -2
  158. data/app/views/decidim/admin/shared/landing_page_content_blocks/edit.html.erb +1 -1
  159. data/app/views/decidim/admin/static_page_topics/index.html.erb +1 -1
  160. data/app/views/decidim/admin/static_pages/_form.html.erb +0 -4
  161. data/app/views/decidim/admin/users_statistics/_users_count.html.erb +2 -2
  162. data/app/views/layouts/decidim/admin/_admin_timeout_modal.html.erb +2 -2
  163. data/app/views/layouts/decidim/admin/_application.html.erb +4 -4
  164. data/app/views/layouts/decidim/admin/_callouts_full.html.erb +1 -1
  165. data/app/views/layouts/decidim/admin/_js_configuration.html.erb +3 -1
  166. data/app/views/layouts/decidim/admin/_title_bar.html.erb +2 -2
  167. data/app/views/layouts/decidim/admin/_title_bar_responsive.html.erb +2 -2
  168. data/config/locales/ar.yml +1 -54
  169. data/config/locales/bg.yml +15 -12
  170. data/config/locales/ca.yml +18 -15
  171. data/config/locales/cs.yml +15 -17
  172. data/config/locales/de.yml +18 -15
  173. data/config/locales/el.yml +0 -11
  174. data/config/locales/en.yml +15 -12
  175. data/config/locales/es-MX.yml +17 -14
  176. data/config/locales/es-PY.yml +17 -14
  177. data/config/locales/es.yml +19 -16
  178. data/config/locales/eu.yml +145 -154
  179. data/config/locales/fi-plain.yml +18 -15
  180. data/config/locales/fi.yml +39 -36
  181. data/config/locales/fr-CA.yml +15 -12
  182. data/config/locales/fr.yml +13 -10
  183. data/config/locales/ga-IE.yml +0 -3
  184. data/config/locales/gl.yml +2 -6
  185. data/config/locales/hu.yml +9 -10
  186. data/config/locales/id-ID.yml +0 -7
  187. data/config/locales/is-IS.yml +0 -15
  188. data/config/locales/it.yml +3 -10
  189. data/config/locales/ja.yml +20 -17
  190. data/config/locales/kaa.yml +3 -3
  191. data/config/locales/ko.yml +1 -6
  192. data/config/locales/lb.yml +4 -11
  193. data/config/locales/lt.yml +0 -12
  194. data/config/locales/lv.yml +2 -6
  195. data/config/locales/nl.yml +1 -8
  196. data/config/locales/no.yml +1 -8
  197. data/config/locales/pl.yml +15 -10
  198. data/config/locales/pt-BR.yml +8 -12
  199. data/config/locales/pt.yml +0 -11
  200. data/config/locales/ro-RO.yml +5 -22
  201. data/config/locales/ru.yml +1 -6
  202. data/config/locales/sk.yml +2 -6
  203. data/config/locales/sl.yml +2 -0
  204. data/config/locales/sq-AL.yml +3 -3
  205. data/config/locales/sr-CS.yml +3 -6
  206. data/config/locales/sv.yml +209 -357
  207. data/config/locales/th-TH.yml +0 -13
  208. data/config/locales/tr-TR.yml +2 -6
  209. data/config/locales/uk.yml +0 -6
  210. data/config/locales/zh-CN.yml +6 -3
  211. data/config/locales/zh-TW.yml +0 -11
  212. data/config/routes.rb +2 -2
  213. data/decidim-admin.gemspec +2 -2
  214. data/lib/decidim/admin/engine.rb +0 -1
  215. data/lib/decidim/admin/import/creator.rb +1 -1
  216. data/lib/decidim/admin/import/importer_factory.rb +2 -2
  217. data/lib/decidim/admin/menu.rb +4 -4
  218. data/lib/decidim/admin/test/commands/create_attachment_collection_examples.rb +3 -2
  219. data/lib/decidim/admin/test/commands/create_category_examples.rb +4 -2
  220. data/lib/decidim/admin/test/commands/update_attachment_collection_examples.rb +3 -2
  221. data/lib/decidim/admin/test/commands/update_category_examples.rb +3 -2
  222. data/lib/decidim/admin/test/filterable_examples.rb +5 -3
  223. data/lib/decidim/admin/test/filters_participatory_space_user_roles_examples.rb +5 -5
  224. data/lib/decidim/admin/test/invite_participatory_space_admins_shared_examples.rb +1 -1
  225. data/lib/decidim/admin/test/invite_participatory_space_users_shared_context.rb +0 -1
  226. data/lib/decidim/admin/test/manage_attachment_collections_examples.rb +12 -12
  227. data/lib/decidim/admin/test/manage_attachments_examples.rb +52 -28
  228. data/lib/decidim/admin/test/manage_categories_examples.rb +13 -13
  229. data/lib/decidim/admin/test/manage_component_permissions_examples.rb +5 -5
  230. data/lib/decidim/admin/test/manage_hide_content_examples.rb +4 -4
  231. data/lib/decidim/admin/test/manage_moderations_examples.rb +21 -21
  232. data/lib/decidim/admin/test/manage_paginated_collection_examples.rb +5 -5
  233. data/lib/decidim/admin/test/manage_participatory_space_publications_examples.rb +2 -2
  234. data/lib/decidim/admin/version.rb +1 -1
  235. data/lib/decidim/admin.rb +15 -0
  236. metadata +28 -27
  237. data/app/commands/decidim/admin/destroy_share_token.rb +0 -46
  238. data/app/commands/decidim/admin/destroy_static_page.rb +0 -40
  239. data/app/commands/decidim/admin/destroy_static_page_topic.rb +0 -40
  240. data/app/controllers/concerns/decidim/admin/verification_conflicts/filterable.rb +0 -31
  241. data/app/views/layouts/decidim/admin/login.html.erb +0 -19
  242. data/config/locales/bn-BD.yml +0 -1
  243. data/config/locales/bs-BA.yml +0 -528
  244. /data/app/packs/src/decidim/admin/{external_domain_whitelist.js → external_domain_allowlist.js} +0 -0
@@ -9,7 +9,7 @@ module Decidim
9
9
  extend ActiveSupport::Concern
10
10
 
11
11
  included do
12
- include Decidim::Paginable
12
+ include Decidim::Admin::Paginable
13
13
  include Decidim::TranslatableAttributes
14
14
 
15
15
  helper Decidim::Admin::FilterableHelper
@@ -20,12 +20,15 @@ module Decidim
20
20
  :filters,
21
21
  :filters_with_values,
22
22
  :find_dynamic_translation,
23
+ :filter_prefix_key,
23
24
  :query,
24
25
  :query_params,
25
26
  :query_params_with,
26
27
  :query_params_without,
28
+ :blank_query_params,
27
29
  :ransack_params,
28
- :search_field_predicate
30
+ :search_field_predicate,
31
+ :adjacent_items
29
32
 
30
33
  delegate :categories, to: :current_component
31
34
  delegate :scopes, to: :current_organization
@@ -36,10 +39,70 @@ module Decidim
36
39
 
37
40
  private
38
41
 
42
+ def check_admin_session_filters
43
+ if (current_filters = ransack_params).present?
44
+ admin_session_filters = session["admin_filters"] || {}
45
+ return if admin_session_filters[filter_prefix_key] == current_filters
46
+
47
+ current_filters = {} if current_filters[:reset_filters] == "true"
48
+
49
+ admin_session_filters[filter_prefix_key] = current_filters
50
+ session["admin_filters"] = admin_session_filters
51
+
52
+ redirect_to url_for(query_params.merge(q: {})) if current_filters.blank?
53
+ else
54
+ @session_filter_params = {} unless session_filter_params.is_a?(Hash)
55
+ redirect_to url_for(query_params_with(session_filter_params)) if session_filter_params.present?
56
+ end
57
+ end
58
+
39
59
  def filtered_collection
40
60
  paginate(query.result)
41
61
  end
42
62
 
63
+ def session_filtered_collection
64
+ @session_filtered_collection ||= begin
65
+ query = base_query.ransack(session_filter_params, search_context: :admin, auth_object: current_user).result
66
+ # The limit reorders as pagination does
67
+ query.limit(query.count)
68
+ end
69
+ end
70
+
71
+ # This method takes the query used by filter and selects the id of
72
+ # each item of the filtered collection (this extra select id avoids
73
+ # some errors where the SQL of the filtered collection query uses
74
+ # aliases and the id is not available in the result) and uses the lag
75
+ # and lead window functions which returns the previous and next ids in
76
+ # the query
77
+ def adjacent_items(item)
78
+ query =
79
+ <<-SQL.squish
80
+ WITH
81
+ collection AS (#{session_filtered_collection.select(:id).to_sql}),
82
+ successors AS (
83
+ SELECT
84
+ id,
85
+ Lag(id, 1) OVER () prev_item,
86
+ Lead(id, 1) OVER () next_item
87
+ FROM
88
+ collection
89
+ )
90
+ SELECT
91
+ prev_item,
92
+ next_item
93
+ FROM
94
+ successors
95
+ WHERE
96
+ successors.id = #{item.id}
97
+ SQL
98
+
99
+ (ActiveRecord::Base.connection.exec_query(query).first || {}).compact_blank.transform_values { |id| collection.find_by(id:) }
100
+ end
101
+
102
+ def filter_prefix_key
103
+ @filter_prefix_key ||= controller_name.to_sym
104
+ end
105
+
43
106
  def base_query
44
107
  raise NotImplementedError, "A base query is needed to filter admin resources"
45
108
  end
@@ -63,14 +126,26 @@ module Decidim
63
126
  query_params[:q] || {}
64
127
  end
65
128
 
129
+ def session_filter_params
130
+ @session_filter_params ||= (session["admin_filters"] || {}).with_indifferent_access.fetch(filter_prefix_key, {})
131
+ end
132
+
66
133
  # For injecting ransack params while keeping query params in links.
67
134
  def query_params_with(hash)
68
135
  query_params.merge(q: ransack_params.merge(hash))
69
136
  end
70
137
 
71
138
  # For rejecting ransack params while keeping query params in links.
72
- def query_params_without(*filters)
73
- query_params.merge(q: ransack_params.except(*filters))
139
+ def query_params_without(*)
140
+ q = ransack_params.except(*)
141
+
142
+ return blank_query_params if q.blank?
143
+
144
+ query_params.merge(q:)
145
+ end
146
+
147
+ def blank_query_params
148
+ query_params.merge(q: { reset_filters: true })
74
149
  end
75
150
 
76
151
  # Ransack predicate to use in the search_form_for.
@@ -10,7 +10,7 @@ module Decidim
10
10
  included do
11
11
  # Private: Overwrites the method from the parent controller so that the
12
12
  # permission system does not overwrite permissions.
13
- def permission_resource
13
+ def authorization_scope
14
14
  :global_moderation
15
15
  end
16
16
 
@@ -45,7 +45,6 @@ module Decidim
45
45
  return true if participatory_process_user_role?
46
46
  return true if assembly_user_role?
47
47
  return true if conference_user_role?
48
- return true if voting_monitoring_commitee_member?
49
48
 
50
49
  false
51
50
  end
@@ -67,12 +66,6 @@ module Decidim
67
66
 
68
67
  true if Decidim::ConferenceUserRole.exists?(user: current_user)
69
68
  end
70
-
71
- def voting_monitoring_commitee_member?
72
- return false unless Decidim.module_installed?(:elections)
73
-
74
- true if Decidim::Votings::MonitoringCommitteeMember.exists?(user: current_user)
75
- end
76
69
  end
77
70
  end
78
71
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/concern"
4
+
5
+ module Decidim
6
+ module Admin
7
+ module Paginable
8
+ # Common logic to paginate admin resources
9
+ extend ActiveSupport::Concern
10
+
11
+ included do
12
+ include Decidim::Paginable
13
+
14
+ def per_page
15
+ params[:per_page].present? ? params[:per_page].to_i : Decidim::Admin.per_page_range.first
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -33,7 +33,7 @@ module Decidim
33
33
  end
34
34
 
35
35
  # Public: Returns a String or Object that will be passed to `redirect_to` after
36
- # exporing a space. By default it redirects to the root_path.
36
+ # exploring a space. By default it redirects to the root_path.
37
37
  #
38
38
  # It can be redefined at controller level if you need to redirect elsewhere.
39
39
  def after_export_path
@@ -9,6 +9,7 @@ module Decidim
9
9
  include NeedsPasswordChange
10
10
  include NeedsSnippets
11
11
  include NeedsAdminTosAccepted
12
+ include NeedsRtlDirection
12
13
  include FormFactory
13
14
  include LocaleSwitcher
14
15
  include UseOrganizationTimeZone
@@ -17,7 +18,6 @@ module Decidim
17
18
  include Headers::ContentSecurityPolicy
18
19
  include DisableRedirectionToExternalHost
19
20
  include Decidim::Admin::Concerns::HasBreadcrumbItems
20
- include ActiveStorage::SetCurrent
21
21
 
22
22
  helper Decidim::Admin::ApplicationHelper
23
23
  helper Decidim::Admin::AttributesDisplayHelper
@@ -26,6 +26,7 @@ module Decidim
26
26
  helper Decidim::Admin::IconWithTooltipHelper
27
27
  helper Decidim::Admin::MenuHelper
28
28
  helper Decidim::Admin::ScopesHelper
29
+ helper Decidim::Admin::Paginable::PerPageHelper
29
30
  helper Decidim::DecidimFormHelper
30
31
  helper Decidim::ReplaceButtonsHelper
31
32
  helper Decidim::ScopesHelper
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module Admin
5
- # Controller that allows managing areatypes to group areas
5
+ # Controller that allows managing area types to group areas
6
6
 
7
7
  class AreaTypesController < Decidim::Admin::ApplicationController
8
8
  include Decidim::Admin::Concerns::HasTabbedMenu
@@ -26,7 +26,7 @@ module Decidim
26
26
  enforce_permission_to :create, :area_type
27
27
  @form = form(AreaTypeForm).from_params(params)
28
28
 
29
- CreateAreaType.call(@form, current_user) do
29
+ CreateAreaType.call(@form) do
30
30
  on(:ok) do
31
31
  flash[:notice] = I18n.t("area_types.create.success", scope: "decidim.admin")
32
32
  redirect_to area_types_path
@@ -48,7 +48,7 @@ module Decidim
48
48
  enforce_permission_to(:update, :area_type, area_type:)
49
49
  @form = form(AreaTypeForm).from_params(params)
50
50
 
51
- UpdateAreaType.call(area_type, @form, current_user) do
51
+ UpdateAreaType.call(@form, area_type) do
52
52
  on(:ok) do
53
53
  flash[:notice] = I18n.t("area_types.update.success", scope: "decidim.admin")
54
54
  redirect_to area_types_path
@@ -64,13 +64,12 @@ module Decidim
64
64
  def destroy
65
65
  enforce_permission_to(:destroy, :area_type, area_type:)
66
66
 
67
- Decidim.traceability.perform_action!("delete", area_type, current_user) do
68
- area_type.destroy!
67
+ Decidim::Commands::DestroyResource.call(area_type, current_user) do
68
+ on(:ok) do
69
+ flash[:notice] = I18n.t("area_types.destroy.success", scope: "decidim.admin")
70
+ redirect_to area_types_path
71
+ end
69
72
  end
70
-
71
- flash[:notice] = I18n.t("area_types.destroy.success", scope: "decidim.admin")
72
-
73
- redirect_to area_types_path
74
73
  end
75
74
 
76
75
  private
@@ -48,7 +48,7 @@ module Decidim
48
48
  enforce_permission_to(:update, :area, area:)
49
49
  @form = form(AreaForm).from_params(params)
50
50
 
51
- UpdateArea.call(area, @form) do
51
+ UpdateArea.call(@form, area) do
52
52
  on(:ok) do
53
53
  flash[:notice] = I18n.t("areas.update.success", scope: "decidim.admin")
54
54
  redirect_to areas_path
@@ -10,7 +10,7 @@ module Decidim
10
10
  def index
11
11
  enforce_permission_to :index, :authorization_workflow
12
12
 
13
- @workflows = Decidim::Verifications.admin_workflows.select do |manifest|
13
+ @workflows = Decidim::Verifications.workflows.select do |manifest|
14
14
  current_organization.available_authorizations.include?(manifest.name.to_s)
15
15
  end
16
16
 
@@ -22,7 +22,7 @@ module Decidim
22
22
  BlockUser.call(@form) do
23
23
  on(:ok) do
24
24
  flash[:notice] = I18n.t("officializations.block.success", scope: "decidim.admin")
25
- redirect_to moderated_users_path, notice:
25
+ redirect_to moderated_users_path(blocked: true), notice:
26
26
  end
27
27
 
28
28
  on(:invalid) do
@@ -24,7 +24,7 @@ module Decidim
24
24
  enforce_permission_to :create, :category
25
25
  @form = form(CategoryForm).from_params(params, current_participatory_space:)
26
26
 
27
- CreateCategory.call(@form, current_participatory_space, current_user) do
27
+ CreateCategory.call(@form) do
28
28
  on(:ok) do
29
29
  flash[:notice] = I18n.t("categories.create.success", scope: "decidim.admin")
30
30
  redirect_to categories_path(current_participatory_space)
@@ -46,7 +46,7 @@ module Decidim
46
46
  enforce_permission_to :update, :category, category: @category
47
47
  @form = form(CategoryForm).from_params(params, current_participatory_space:)
48
48
 
49
- UpdateCategory.call(@category, @form, current_user) do
49
+ UpdateCategory.call(@form, @category) do
50
50
  on(:ok) do
51
51
  flash[:notice] = I18n.t("categories.update.success", scope: "decidim.admin")
52
52
  redirect_to categories_path(current_participatory_space)
@@ -20,7 +20,7 @@ module Decidim
20
20
  enforce_permission_to(:update, :component, component:)
21
21
  @permissions_form = PermissionsForm.from_params(params)
22
22
 
23
- UpdateComponentPermissions.call(@permissions_form, component, resource, current_user) do
23
+ UpdateComponentPermissions.call(@permissions_form, component, resource) do
24
24
  on(:ok) do
25
25
  flash[:notice] = t("component_permissions.update.success", scope: "decidim.admin")
26
26
  redirect_to return_path
@@ -35,7 +35,7 @@ module Decidim
35
35
 
36
36
  CreateComponent.call(@form) do
37
37
  on(:ok) do
38
- if (landing_page_path = participatory_space_landing_page_path(@component)).present?
38
+ if (landing_page_path = participatory_space_landing_page_path(resource)).present?
39
39
  flash[:notice_html] = I18n.t("components.create.success_landing_page", landing_page_path:, scope: "decidim.admin").html_safe
40
40
  else
41
41
  flash[:notice] = I18n.t("components.create.success", scope: "decidim.admin")
@@ -63,7 +63,7 @@ module Decidim
63
63
  @form = form(@component.form_class).from_params(component_params)
64
64
  enforce_permission_to :update, :component, component: @component
65
65
 
66
- UpdateComponent.call(@form, @component, current_user) do
66
+ UpdateComponent.call(@form, @component) do
67
67
  on(:ok) do |settings_changed, previous_settings, current_settings|
68
68
  handle_component_settings_change(previous_settings, current_settings) if settings_changed
69
69
 
@@ -31,7 +31,7 @@ module Decidim
31
31
  enforce_permission_to :create, :attachment_collection
32
32
  @form = form(AttachmentCollectionForm).from_params(params, collection_for:)
33
33
 
34
- CreateAttachmentCollection.call(@form, collection_for, current_user) do
34
+ CreateAttachmentCollection.call(@form, collection_for) do
35
35
  on(:ok) do
36
36
  flash[:notice] = I18n.t("attachment_collections.create.success", scope: "decidim.admin")
37
37
  redirect_to action: :index
@@ -56,7 +56,7 @@ module Decidim
56
56
  enforce_permission_to :update, :attachment_collection, attachment_collection: @attachment_collection
57
57
  @form = form(AttachmentCollectionForm).from_params(params, collection_for:)
58
58
 
59
- UpdateAttachmentCollection.call(@attachment_collection, @form, current_user) do
59
+ UpdateAttachmentCollection.call(@attachment_collection, @form) do
60
60
  on(:ok) do
61
61
  flash[:notice] = I18n.t("attachment_collections.update.success", scope: "decidim.admin")
62
62
  redirect_to action: :index
@@ -31,7 +31,7 @@ module Decidim
31
31
  enforce_permission_to(:create, :attachment, attached_to:)
32
32
  @form = form(::Decidim::Admin::AttachmentForm).from_params(params, attached_to:)
33
33
 
34
- CreateAttachment.call(@form, attached_to, current_user) do
34
+ CreateAttachment.call(@form, attached_to) do
35
35
  on(:ok) do
36
36
  flash[:notice] = I18n.t("attachments.create.success", scope: "decidim.admin")
37
37
  redirect_to action: :index
@@ -56,7 +56,7 @@ module Decidim
56
56
  enforce_permission_to(:update, :attachment, attachment:)
57
57
  @form = form(::Decidim::Admin::AttachmentForm).from_params(attachment_params, attached_to:)
58
58
 
59
- UpdateAttachment.call(@attachment, @form, current_user) do
59
+ UpdateAttachment.call(@attachment, @form) do
60
60
  on(:ok) do
61
61
  flash[:notice] = I18n.t("attachments.update.success", scope: "decidim.admin")
62
62
  redirect_to action: :index
@@ -33,7 +33,7 @@ module Decidim
33
33
  enforce_permission_to :create, :space_private_user
34
34
  @form = form(ParticipatorySpacePrivateUserForm).from_params(params, privatable_to:)
35
35
 
36
- CreateParticipatorySpacePrivateUser.call(@form, current_user, current_participatory_space) do
36
+ CreateParticipatorySpacePrivateUser.call(@form, current_participatory_space) do
37
37
  on(:ok) do
38
38
  flash[:notice] = I18n.t("participatory_space_private_users.create.success", scope: "decidim.admin")
39
39
  redirect_to action: :index
@@ -26,7 +26,7 @@ module Decidim
26
26
  enforce_permission_to :csv_import, :space_private_user
27
27
  @form = form(ParticipatorySpacePrivateUserCsvImportForm).from_params(params, privatable_to:)
28
28
 
29
- ProcessParticipatorySpacePrivateUserImportCsv.call(@form, current_user, current_participatory_space) do
29
+ ProcessParticipatorySpacePrivateUserImportCsv.call(@form, current_participatory_space) do
30
30
  on(:ok) do
31
31
  flash[:notice] = I18n.t("participatory_space_private_users_csv_imports.create.success", scope: "decidim.admin")
32
32
  redirect_to after_import_path
@@ -3,16 +3,18 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  class ConflictsController < Decidim::Admin::ApplicationController
6
- include Decidim::Admin::VerificationConflicts::Filterable
7
-
8
6
  layout "decidim/admin/users"
9
7
 
10
- helper_method :context_breadcrumb_items, :conflicts
8
+ helper_method :context_breadcrumb_items
11
9
 
12
10
  add_breadcrumb_item_from_menu :impersonate_menu
13
11
 
14
12
  def index
15
13
  enforce_permission_to :index, :impersonatable_user
14
+
15
+ @conflicts = Decidim::Verifications::Conflict.joins(:current_user).where(
16
+ decidim_users: { decidim_organization_id: current_organization.id }
17
+ )
16
18
  end
17
19
 
18
20
  def edit
@@ -47,7 +49,7 @@ module Decidim
47
49
 
48
50
  on(:invalid) do
49
51
  flash.now[:alert] = I18n.t("error", scope: "decidim.admin.conflicts.transfer")
50
- render action: "edit"
52
+ redirect_to decidim.root_path
51
53
  end
52
54
  end
53
55
  end
@@ -64,16 +66,6 @@ module Decidim
64
66
  url: decidim_admin.impersonatable_users_path
65
67
  }
66
68
  end
67
-
68
- def collection
69
- @collection ||= Decidim::Verifications::Conflict.joins(:current_user).where(
70
- decidim_users: { decidim_organization_id: current_organization.id }
71
- )
72
- end
73
-
74
- def conflicts
75
- @conflicts ||= filtered_collection.order(created_at: :desc)
76
- end
77
69
  end
78
70
  end
79
71
  end
@@ -27,7 +27,7 @@ module Decidim
27
27
  params[:help_sections]
28
28
  )
29
29
 
30
- UpdateHelpSections.call(@form, current_organization, current_user) do
30
+ UpdateHelpSections.call(@form, current_organization) do
31
31
  on(:ok) do
32
32
  flash[:notice] = t("help_sections.success", scope: "decidim.admin")
33
33
  redirect_to action: :show
@@ -29,7 +29,6 @@ module Decidim
29
29
 
30
30
  @form = form(ImpersonateUserForm).from_params(
31
31
  user:,
32
- name: params[:impersonate_user][:name],
33
32
  handler_name:,
34
33
  reason: params[:impersonate_user][:reason],
35
34
  authorization: Decidim::AuthorizationHandler.handler_for(
@@ -17,7 +17,7 @@ module Decidim
17
17
  enforce_permission_to(:promote, :managed_user, user:)
18
18
  @form = form(ManagedUserPromotionForm).from_params(params)
19
19
 
20
- PromoteManagedUser.call(@form, user, current_user) do
20
+ PromoteManagedUser.call(@form, user) do
21
21
  on(:ok) do
22
22
  flash[:notice] = I18n.t("managed_users.promotion.success", scope: "decidim.admin")
23
23
  redirect_to impersonatable_users_path
@@ -5,14 +5,14 @@ module Decidim
5
5
  module Moderations
6
6
  # This controller allows admins to manage reports in a moderation.
7
7
  class ReportsController < Decidim::Admin::ApplicationController
8
- helper_method :moderation, :reports, :permission_resource
8
+ helper_method :moderation, :reports, :authorization_scope
9
9
 
10
10
  def index
11
- enforce_permission_to :read, permission_resource
11
+ enforce_permission_to :read, authorization_scope
12
12
  end
13
13
 
14
14
  def show
15
- enforce_permission_to :read, permission_resource
15
+ enforce_permission_to :read, authorization_scope
16
16
  @report = reports.find(params[:id])
17
17
  end
18
18
 
@@ -30,7 +30,7 @@ module Decidim
30
30
  @participatory_space_moderations ||= Decidim::Moderation.where(participatory_space: current_participatory_space)
31
31
  end
32
32
 
33
- def permission_resource
33
+ def authorization_scope
34
34
  :moderation
35
35
  end
36
36
  end
@@ -6,21 +6,21 @@ module Decidim
6
6
  class ModerationsController < Decidim::Admin::ApplicationController
7
7
  include Decidim::Moderations::Admin::Filterable
8
8
 
9
- helper_method :moderations, :allowed_to?, :query, :permission_resource
9
+ helper_method :moderations, :allowed_to?, :query, :authorization_scope
10
10
 
11
11
  before_action :set_moderation_breadcrumb_item
12
12
 
13
13
  def index
14
- enforce_permission_to :read, permission_resource
14
+ enforce_permission_to :read, authorization_scope
15
15
  end
16
16
 
17
17
  def show
18
- enforce_permission_to :read, permission_resource
18
+ enforce_permission_to :read, authorization_scope
19
19
  @moderation = collection.find(params[:id])
20
20
  end
21
21
 
22
22
  def unreport
23
- enforce_permission_to :unreport, permission_resource
23
+ enforce_permission_to :unreport, authorization_scope
24
24
 
25
25
  Admin::UnreportResource.call(reportable, current_user) do
26
26
  on(:ok) do
@@ -36,7 +36,7 @@ module Decidim
36
36
  end
37
37
 
38
38
  def hide
39
- enforce_permission_to :hide, permission_resource
39
+ enforce_permission_to :hide, authorization_scope
40
40
 
41
41
  Admin::HideResource.call(reportable, current_user) do
42
42
  on(:ok) do
@@ -52,7 +52,7 @@ module Decidim
52
52
  end
53
53
 
54
54
  def unhide
55
- enforce_permission_to :unhide, permission_resource
55
+ enforce_permission_to :unhide, authorization_scope
56
56
 
57
57
  Admin::UnhideResource.call(reportable, current_user) do
58
58
  on(:ok) do
@@ -102,7 +102,7 @@ module Decidim
102
102
  # added so that the `GlobalModerationController` can overwrite this method
103
103
  # and define the custom permission resource, so that the permission system
104
104
  # is not overridden.
105
- def permission_resource
105
+ def authorization_scope
106
106
  :moderation
107
107
  end
108
108
 
@@ -15,7 +15,7 @@ module Decidim
15
15
  def show; end
16
16
 
17
17
  def preview
18
- email = NewsletterMailer.newsletter(current_user, fake_newsletter, preview: true)
18
+ email = NewsletterMailer.newsletter(current_user, fake_newsletter, true)
19
19
  Premailer::Rails::Hook.perform(email)
20
20
  render html: email.html_part.body.decoded.html_safe
21
21
  end
@@ -37,7 +37,7 @@ module Decidim
37
37
  def preview
38
38
  enforce_permission_to(:read, :newsletter, newsletter:)
39
39
 
40
- email = NewsletterMailer.newsletter(current_user, newsletter, preview: true)
40
+ email = NewsletterMailer.newsletter(current_user, newsletter, true)
41
41
  Premailer::Rails::Hook.perform(email)
42
42
  render html: email.html_part.body.decoded.html_safe
43
43
  end
@@ -47,7 +47,7 @@ module Decidim
47
47
  @form = form(NewsletterForm).from_params(params)
48
48
  @form.images = images_block_context unless has_images_block_context?
49
49
 
50
- CreateNewsletter.call(@form, content_block, current_user) do
50
+ CreateNewsletter.call(@form, content_block) do
51
51
  on(:ok) do |newsletter|
52
52
  flash.now[:notice] = I18n.t("newsletters.create.success", scope: "decidim.admin")
53
53
  redirect_to action: :show, id: newsletter.id
@@ -71,7 +71,7 @@ module Decidim
71
71
  @form = form(NewsletterForm).from_params(params)
72
72
  @form.images = images_block_context unless has_images_block_context?
73
73
 
74
- UpdateNewsletter.call(newsletter, @form, current_user) do
74
+ UpdateNewsletter.call(newsletter, @form) do
75
75
  on(:ok) do |newsletter|
76
76
  flash[:notice] = I18n.t("newsletters.update.success", scope: "decidim.admin")
77
77
  redirect_to action: :show, id: newsletter.id
@@ -89,7 +89,7 @@ module Decidim
89
89
  enforce_permission_to(:destroy, :newsletter, newsletter:)
90
90
 
91
91
  DestroyNewsletter.call(newsletter, current_user) do
92
- on(:already_sent) do
92
+ on(:invalid) do
93
93
  flash.now[:error] = I18n.t("newsletters.destroy.error_already_sent", scope: "decidim.admin")
94
94
  redirect_to :back
95
95
  end
@@ -108,8 +108,7 @@ module Decidim
108
108
  end
109
109
 
110
110
  def recipients_count
111
- data = params.permit(newsletter: {}).to_h[:newsletter]
112
-
111
+ data = params.permit(data: {}).to_h[:data]
113
112
  @form = form(SelectiveNewsletterForm).from_params(data)
114
113
  render plain: recipients_count_query
115
114
  end
@@ -118,7 +117,7 @@ module Decidim
118
117
  enforce_permission_to(:update, :newsletter, newsletter:)
119
118
  @form = form(SelectiveNewsletterForm).from_params(params)
120
119
 
121
- DeliverNewsletter.call(newsletter, @form, current_user) do
120
+ DeliverNewsletter.call(newsletter, @form) do
122
121
  on(:ok) do
123
122
  flash[:notice] = I18n.t("newsletters.deliver.success", scope: "decidim.admin")
124
123
  redirect_to action: :index
@@ -19,7 +19,7 @@ module Decidim
19
19
  enforce_permission_to :update, :organization, organization: current_organization
20
20
  @form = form(OrganizationAppearanceForm).from_params(params)
21
21
 
22
- UpdateOrganizationAppearance.call(current_organization, @form) do
22
+ UpdateOrganizationAppearance.call(@form, current_organization) do
23
23
  on(:ok) do
24
24
  flash[:notice] = I18n.t("organization.update.success", scope: "decidim.admin")
25
25
  redirect_to edit_organization_appearance_path
@@ -19,7 +19,7 @@ module Decidim
19
19
  @form = form(OrganizationForm).from_params(params)
20
20
  @form.id = current_organization.id
21
21
 
22
- UpdateOrganization.call(current_organization, @form) do
22
+ UpdateOrganization.call(@form, current_organization) do
23
23
  on(:ok) do
24
24
  flash[:notice] = I18n.t("organization.update.success", scope: "decidim.admin")
25
25
  redirect_to edit_organization_path