decidim-admin 0.28.2 → 0.29.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/admin/content_block_cell.rb +0 -1
  3. data/app/cells/decidim/admin/results_per_page/show.erb +2 -2
  4. data/app/cells/decidim/admin/results_per_page_cell.rb +0 -2
  5. data/app/commands/decidim/admin/create_area.rb +4 -32
  6. data/app/commands/decidim/admin/create_area_type.rb +4 -33
  7. data/app/commands/decidim/admin/create_attachment.rb +5 -4
  8. data/app/commands/decidim/admin/create_attachment_collection.rb +3 -3
  9. data/app/commands/decidim/admin/create_category.rb +4 -37
  10. data/app/commands/decidim/admin/create_component.rb +7 -40
  11. data/app/commands/decidim/admin/create_newsletter.rb +11 -29
  12. data/app/commands/decidim/admin/create_participatory_space_private_user.rb +3 -3
  13. data/app/commands/decidim/admin/create_scope.rb +15 -32
  14. data/app/commands/decidim/admin/create_scope_type.rb +3 -32
  15. data/app/commands/decidim/admin/create_static_page.rb +6 -47
  16. data/app/commands/decidim/admin/create_static_page_topic.rb +4 -26
  17. data/app/commands/decidim/admin/deliver_newsletter.rb +4 -5
  18. data/app/commands/decidim/admin/destroy_area.rb +2 -25
  19. data/app/commands/decidim/admin/destroy_category.rb +4 -29
  20. data/app/commands/decidim/admin/destroy_component.rb +5 -42
  21. data/app/commands/decidim/admin/destroy_newsletter.rb +2 -30
  22. data/app/commands/decidim/admin/destroy_participatory_space_private_user.rb +5 -32
  23. data/app/commands/decidim/admin/destroy_scope.rb +6 -33
  24. data/app/commands/decidim/admin/officialize_user.rb +1 -1
  25. data/app/commands/decidim/admin/participatory_space/create_admin.rb +4 -4
  26. data/app/commands/decidim/admin/process_participatory_space_private_user_import_csv.rb +5 -4
  27. data/app/commands/decidim/admin/promote_managed_user.rb +4 -5
  28. data/app/commands/decidim/admin/unofficialize_user.rb +1 -1
  29. data/app/commands/decidim/admin/update_area.rb +2 -41
  30. data/app/commands/decidim/admin/update_area_type.rb +2 -42
  31. data/app/commands/decidim/admin/update_attachment.rb +10 -7
  32. data/app/commands/decidim/admin/update_attachment_collection.rb +3 -3
  33. data/app/commands/decidim/admin/update_category.rb +2 -45
  34. data/app/commands/decidim/admin/update_component.rb +4 -5
  35. data/app/commands/decidim/admin/update_component_permissions.rb +3 -3
  36. data/app/commands/decidim/admin/{update_external_domain_whitelist.rb → update_external_domain_allowlist.rb} +6 -5
  37. data/app/commands/decidim/admin/update_help_sections.rb +6 -3
  38. data/app/commands/decidim/admin/update_newsletter.rb +8 -8
  39. data/app/commands/decidim/admin/update_organization.rb +9 -53
  40. data/app/commands/decidim/admin/update_organization_appearance.rb +10 -81
  41. data/app/commands/decidim/admin/update_scope.rb +7 -40
  42. data/app/commands/decidim/admin/update_scope_type.rb +2 -42
  43. data/app/commands/decidim/admin/update_static_page.rb +5 -46
  44. data/app/commands/decidim/admin/update_static_page_topic.rb +2 -43
  45. data/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
  46. data/app/controllers/concerns/decidim/admin/content_blocks/landing_page.rb +2 -2
  47. data/app/controllers/concerns/decidim/admin/filterable.rb +78 -3
  48. data/app/controllers/concerns/decidim/admin/global_moderation_context.rb +1 -1
  49. data/app/controllers/concerns/decidim/admin/needs_admin_tos_accepted.rb +0 -7
  50. data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +1 -1
  51. data/app/controllers/decidim/admin/application_controller.rb +1 -0
  52. data/app/controllers/decidim/admin/area_types_controller.rb +8 -9
  53. data/app/controllers/decidim/admin/areas_controller.rb +1 -1
  54. data/app/controllers/decidim/admin/authorization_workflows_controller.rb +1 -1
  55. data/app/controllers/decidim/admin/categories_controller.rb +2 -2
  56. data/app/controllers/decidim/admin/component_permissions_controller.rb +1 -1
  57. data/app/controllers/decidim/admin/components_controller.rb +2 -2
  58. data/app/controllers/decidim/admin/concerns/has_attachment_collections.rb +2 -2
  59. data/app/controllers/decidim/admin/concerns/has_attachments.rb +2 -2
  60. data/app/controllers/decidim/admin/concerns/has_private_users.rb +1 -1
  61. data/app/controllers/decidim/admin/concerns/has_private_users_csv_import.rb +1 -1
  62. data/app/controllers/decidim/admin/help_sections_controller.rb +1 -1
  63. data/app/controllers/decidim/admin/managed_users/promotions_controller.rb +1 -1
  64. data/app/controllers/decidim/admin/moderations/reports_controller.rb +4 -4
  65. data/app/controllers/decidim/admin/moderations_controller.rb +7 -7
  66. data/app/controllers/decidim/admin/newsletter_templates_controller.rb +1 -1
  67. data/app/controllers/decidim/admin/newsletters_controller.rb +5 -5
  68. data/app/controllers/decidim/admin/organization_appearance_controller.rb +1 -1
  69. data/app/controllers/decidim/admin/organization_controller.rb +1 -1
  70. data/app/controllers/decidim/admin/{organization_external_domain_whitelist_controller.rb → organization_external_domain_allowlist_controller.rb} +7 -7
  71. data/app/controllers/decidim/admin/scope_types_controller.rb +7 -8
  72. data/app/controllers/decidim/admin/scopes_controller.rb +1 -1
  73. data/app/controllers/decidim/admin/share_tokens_controller.rb +1 -1
  74. data/app/controllers/decidim/admin/static_page_topics_controller.rb +2 -2
  75. data/app/controllers/decidim/admin/static_pages_controller.rb +2 -2
  76. data/app/forms/decidim/admin/attachment_form.rb +7 -1
  77. data/app/forms/decidim/admin/organization_appearance_form.rb +0 -3
  78. data/app/forms/decidim/admin/{organization_external_domain_whitelist_form.rb → organization_external_domain_allowlist_form.rb} +3 -3
  79. data/app/forms/decidim/admin/organization_form.rb +2 -2
  80. data/app/forms/decidim/admin/static_page_form.rb +0 -1
  81. data/app/helpers/decidim/admin/filterable_helper.rb +19 -3
  82. data/app/helpers/decidim/admin/moderations/reports_helper.rb +3 -1
  83. data/app/helpers/decidim/admin/newsletters_helper.rb +3 -3
  84. data/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb +2 -2
  85. data/app/packs/entrypoints/decidim_admin.js +4 -1
  86. data/app/packs/src/decidim/admin/application.js +19 -15
  87. data/app/packs/src/decidim/admin/css_preview.js +39 -0
  88. data/app/packs/src/decidim/admin/form.js +18 -1
  89. data/app/packs/src/decidim/admin/participatory_space_search.js +1 -1
  90. data/app/packs/src/decidim/admin/proposal_infinite_edit.js +2 -2
  91. data/app/packs/src/decidim/admin/sync_radio_buttons.js +27 -0
  92. data/app/packs/src/decidim/admin/text_copy.js +19 -0
  93. data/app/packs/stylesheets/decidim/admin/_cards.scss +1 -1
  94. data/app/packs/stylesheets/decidim/admin/_datepicker.scss +62 -0
  95. data/app/packs/stylesheets/decidim/admin/_item_edit.scss +1 -1
  96. data/app/packs/stylesheets/decidim/admin/_item_show.scss +8 -0
  97. data/app/packs/stylesheets/decidim/admin/_proposal_status.scss +5 -0
  98. data/app/packs/stylesheets/decidim/admin/application.scss +2 -0
  99. data/app/permissions/decidim/admin/permissions.rb +2 -2
  100. data/app/queries/decidim/admin/user_filter.rb +4 -4
  101. data/app/queries/decidim/admin/user_groups_evaluation.rb +1 -1
  102. data/app/views/decidim/admin/attachment_collections/index.html.erb +1 -1
  103. data/app/views/decidim/admin/attachments/_form.html.erb +21 -2
  104. data/app/views/decidim/admin/attachments/index.html.erb +2 -2
  105. data/app/views/decidim/admin/authorization_workflows/index.html.erb +26 -8
  106. data/app/views/decidim/admin/categories/index.html.erb +2 -2
  107. data/app/views/decidim/admin/components/_form.html.erb +1 -1
  108. data/app/views/decidim/admin/dashboard/_pending_moderations.html.erb +1 -1
  109. data/app/views/decidim/admin/dashboard/show.html.erb +1 -1
  110. data/app/views/decidim/admin/exports/_dropdown.html.erb +1 -1
  111. data/app/views/decidim/admin/impersonatable_users/index.html.erb +3 -3
  112. data/app/views/decidim/admin/imports/_dropdown.html.erb +1 -1
  113. data/app/views/decidim/admin/imports/new.html.erb +2 -2
  114. data/app/views/decidim/admin/logs/_filters.html.erb +3 -3
  115. data/app/views/decidim/admin/managed_users/promotions/new.html.erb +1 -1
  116. data/app/views/decidim/admin/moderated_users/index.html.erb +2 -2
  117. data/app/views/decidim/admin/moderations/index.html.erb +5 -5
  118. data/app/views/decidim/admin/moderations/reports/index.html.erb +6 -6
  119. data/app/views/decidim/admin/moderations/reports/show.html.erb +4 -4
  120. data/app/views/decidim/admin/newsletter_templates/index.html.erb +2 -2
  121. data/app/views/decidim/admin/newsletter_templates/show.html.erb +7 -7
  122. data/app/views/decidim/admin/newsletters/index.html.erb +1 -1
  123. data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +3 -3
  124. data/app/views/decidim/admin/newsletters/show.html.erb +1 -1
  125. data/app/views/decidim/admin/organization/_form.html.erb +3 -3
  126. data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +0 -3
  127. data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +5 -5
  128. data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/_external_domain.html.erb +4 -4
  129. data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/_form.html.erb +2 -2
  130. data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/edit.html.erb +2 -2
  131. data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +1 -1
  132. data/app/views/decidim/admin/participatory_space_private_users_csv_imports/new.html.erb +1 -1
  133. data/app/views/decidim/admin/share_tokens/_share_tokens.html.erb +1 -1
  134. data/app/views/decidim/admin/shared/_adjacent_navigation.html.erb +30 -0
  135. data/app/views/decidim/admin/shared/_admin_confirm_modal.html.erb +7 -7
  136. data/app/views/decidim/admin/shared/_filters.html.erb +1 -1
  137. data/app/views/decidim/admin/shared/_gallery.html.erb +1 -1
  138. data/app/views/decidim/admin/shared/landing_page/_content_blocks.html.erb +2 -2
  139. data/app/views/decidim/admin/static_page_topics/index.html.erb +1 -1
  140. data/app/views/decidim/admin/static_pages/_form.html.erb +0 -4
  141. data/app/views/decidim/admin/users_statistics/_users_count.html.erb +2 -2
  142. data/app/views/layouts/decidim/admin/_admin_timeout_modal.html.erb +2 -2
  143. data/app/views/layouts/decidim/admin/_application.html.erb +4 -4
  144. data/app/views/layouts/decidim/admin/_callouts_full.html.erb +1 -1
  145. data/app/views/layouts/decidim/admin/_js_configuration.html.erb +3 -1
  146. data/app/views/layouts/decidim/admin/_title_bar.html.erb +2 -2
  147. data/app/views/layouts/decidim/admin/_title_bar_responsive.html.erb +2 -2
  148. data/config/locales/ar.yml +0 -7
  149. data/config/locales/bg.yml +15 -10
  150. data/config/locales/ca.yml +16 -11
  151. data/config/locales/cs.yml +15 -10
  152. data/config/locales/de.yml +15 -10
  153. data/config/locales/el.yml +0 -12
  154. data/config/locales/en.yml +16 -11
  155. data/config/locales/es-MX.yml +16 -11
  156. data/config/locales/es-PY.yml +16 -11
  157. data/config/locales/es.yml +16 -11
  158. data/config/locales/eu.yml +16 -11
  159. data/config/locales/fi-plain.yml +14 -9
  160. data/config/locales/fi.yml +14 -9
  161. data/config/locales/fr-CA.yml +14 -9
  162. data/config/locales/fr.yml +13 -8
  163. data/config/locales/ga-IE.yml +0 -3
  164. data/config/locales/gl.yml +0 -5
  165. data/config/locales/hu.yml +9 -10
  166. data/config/locales/id-ID.yml +0 -3
  167. data/config/locales/is-IS.yml +0 -3
  168. data/config/locales/it.yml +0 -8
  169. data/config/locales/ja.yml +16 -11
  170. data/config/locales/kaa.yml +0 -3
  171. data/config/locales/ko.yml +0 -6
  172. data/config/locales/lb.yml +0 -8
  173. data/config/locales/lt.yml +0 -13
  174. data/config/locales/lv.yml +0 -3
  175. data/config/locales/nl.yml +0 -8
  176. data/config/locales/no.yml +0 -8
  177. data/config/locales/pl.yml +14 -9
  178. data/config/locales/pt-BR.yml +8 -10
  179. data/config/locales/pt.yml +0 -8
  180. data/config/locales/ro-RO.yml +0 -12
  181. data/config/locales/ru.yml +0 -3
  182. data/config/locales/sk.yml +0 -3
  183. data/config/locales/sq-AL.yml +0 -3
  184. data/config/locales/sr-CS.yml +0 -3
  185. data/config/locales/sv.yml +0 -8
  186. data/config/locales/th-TH.yml +0 -3
  187. data/config/locales/tr-TR.yml +0 -5
  188. data/config/locales/uk.yml +0 -3
  189. data/config/locales/zh-CN.yml +0 -3
  190. data/config/locales/zh-TW.yml +0 -12
  191. data/config/routes.rb +1 -1
  192. data/decidim-admin.gemspec +1 -1
  193. data/lib/decidim/admin/import/creator.rb +1 -1
  194. data/lib/decidim/admin/import/importer_factory.rb +2 -2
  195. data/lib/decidim/admin/menu.rb +4 -4
  196. data/lib/decidim/admin/test/commands/create_attachment_collection_examples.rb +3 -2
  197. data/lib/decidim/admin/test/commands/create_category_examples.rb +4 -2
  198. data/lib/decidim/admin/test/commands/update_attachment_collection_examples.rb +3 -2
  199. data/lib/decidim/admin/test/commands/update_category_examples.rb +3 -2
  200. data/lib/decidim/admin/test/filterable_examples.rb +5 -3
  201. data/lib/decidim/admin/test/filters_participatory_space_user_roles_examples.rb +5 -5
  202. data/lib/decidim/admin/test/invite_participatory_space_admins_shared_examples.rb +1 -1
  203. data/lib/decidim/admin/test/manage_attachment_collections_examples.rb +12 -12
  204. data/lib/decidim/admin/test/manage_attachments_examples.rb +51 -15
  205. data/lib/decidim/admin/test/manage_categories_examples.rb +13 -13
  206. data/lib/decidim/admin/test/manage_component_permissions_examples.rb +5 -5
  207. data/lib/decidim/admin/test/manage_hide_content_examples.rb +4 -4
  208. data/lib/decidim/admin/test/manage_moderations_examples.rb +21 -21
  209. data/lib/decidim/admin/test/manage_paginated_collection_examples.rb +3 -3
  210. data/lib/decidim/admin/test/manage_participatory_space_publications_examples.rb +2 -2
  211. data/lib/decidim/admin/version.rb +1 -1
  212. metadata +24 -22
  213. data/app/commands/decidim/admin/destroy_share_token.rb +0 -46
  214. data/app/commands/decidim/admin/destroy_static_page.rb +0 -40
  215. data/app/commands/decidim/admin/destroy_static_page_topic.rb +0 -40
  216. data/app/views/layouts/decidim/admin/login.html.erb +0 -19
  217. /data/app/packs/src/decidim/admin/{external_domain_whitelist.js → external_domain_allowlist.js} +0 -0
@@ -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
@@ -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
@@ -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
 
@@ -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
@@ -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
@@ -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
@@ -117,7 +117,7 @@ module Decidim
117
117
  enforce_permission_to(:update, :newsletter, newsletter:)
118
118
  @form = form(SelectiveNewsletterForm).from_params(params)
119
119
 
120
- DeliverNewsletter.call(newsletter, @form, current_user) do
120
+ DeliverNewsletter.call(newsletter, @form) do
121
121
  on(:ok) do
122
122
  flash[:notice] = I18n.t("newsletters.deliver.success", scope: "decidim.admin")
123
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module Admin
5
- class OrganizationExternalDomainWhitelistController < Decidim::Admin::ApplicationController
5
+ class OrganizationExternalDomainAllowlistController < Decidim::Admin::ApplicationController
6
6
  layout "decidim/admin/settings"
7
7
 
8
8
  add_breadcrumb_item_from_menu :admin_settings_menu
@@ -11,20 +11,20 @@ module Decidim
11
11
 
12
12
  def edit
13
13
  enforce_permission_to :update, :organization, organization: current_organization
14
- @form = form(OrganizationExternalDomainWhitelistForm).from_model(current_organization)
14
+ @form = form(OrganizationExternalDomainAllowlistForm).from_model(current_organization)
15
15
  end
16
16
 
17
17
  def update
18
18
  enforce_permission_to :update, :organization, organization: current_organization
19
- @form = form(OrganizationExternalDomainWhitelistForm).from_params(params)
19
+ @form = form(OrganizationExternalDomainAllowlistForm).from_params(params)
20
20
 
21
- UpdateExternalDomainWhitelist.call(@form, current_organization, current_user) do
21
+ UpdateExternalDomainAllowlist.call(@form, current_organization, current_user) do
22
22
  on(:ok) do
23
- flash[:notice] = t("domain_whitelist.update.success", scope: "decidim.admin")
24
- redirect_to edit_organization_external_domain_whitelist_path
23
+ flash[:notice] = t("domain_allowlist.update.success", scope: "decidim.admin")
24
+ redirect_to edit_organization_external_domain_allowlist_path
25
25
  end
26
26
  on(:invalid) do
27
- flash[:notice] = t("domain_whitelist.update.error", scope: "decidim.admin")
27
+ flash[:notice] = t("domain_allowlist.update.error", scope: "decidim.admin")
28
28
  render action: "edit"
29
29
  end
30
30
  end
@@ -26,7 +26,7 @@ module Decidim
26
26
  enforce_permission_to :create, :scope_type
27
27
  @form = form(ScopeTypeForm).from_params(params)
28
28
 
29
- CreateScopeType.call(@form, current_user) do
29
+ CreateScopeType.call(@form) do
30
30
  on(:ok) do
31
31
  flash[:notice] = I18n.t("scope_types.create.success", scope: "decidim.admin")
32
32
  redirect_to scope_types_path
@@ -48,7 +48,7 @@ module Decidim
48
48
  enforce_permission_to(:update, :scope_type, scope_type:)
49
49
  @form = form(ScopeTypeForm).from_params(params)
50
50
 
51
- UpdateScopeType.call(scope_type, @form, current_user) do
51
+ UpdateScopeType.call(@form, scope_type) do
52
52
  on(:ok) do
53
53
  flash[:notice] = I18n.t("scope_types.update.success", scope: "decidim.admin")
54
54
  redirect_to scope_types_path
@@ -64,13 +64,12 @@ module Decidim
64
64
  def destroy
65
65
  enforce_permission_to(:destroy, :scope_type, scope_type:)
66
66
 
67
- Decidim.traceability.perform_action!("delete", scope_type, current_user) do
68
- scope_type.destroy!
67
+ Decidim::Commands::DestroyResource.call(scope_type, current_user) do
68
+ on(:ok) do
69
+ flash[:notice] = I18n.t("scope_types.destroy.success", scope: "decidim.admin")
70
+ redirect_to scope_types_path
71
+ end
69
72
  end
70
-
71
- flash[:notice] = I18n.t("scope_types.destroy.success", scope: "decidim.admin")
72
-
73
- redirect_to scope_types_path
74
73
  end
75
74
 
76
75
  private
@@ -49,7 +49,7 @@ module Decidim
49
49
  enforce_permission_to(:update, :scope, scope:)
50
50
  @form = form(ScopeForm).from_params(params)
51
51
 
52
- UpdateScope.call(scope, @form) do
52
+ UpdateScope.call(@form, scope) do
53
53
  on(:ok) do
54
54
  flash[:notice] = I18n.t("scopes.update.success", scope: "decidim.admin")
55
55
  redirect_to current_scopes_path
@@ -6,7 +6,7 @@ module Decidim
6
6
  def destroy
7
7
  enforce_permission_to(:destroy, :share_token, share_token:)
8
8
 
9
- DestroyShareToken.call(share_token, current_user) do
9
+ Decidim::Commands::DestroyResource.call(share_token, current_user) do
10
10
  on(:ok) do
11
11
  flash[:notice] = I18n.t("share_tokens.destroy.success", scope: "decidim.admin")
12
12
  end
@@ -44,7 +44,7 @@ module Decidim
44
44
  enforce_permission_to :update, :static_page_topic, static_page_topic: topic
45
45
  @form = form(StaticPageTopicForm).from_params(params["static_page_topic"])
46
46
 
47
- UpdateStaticPageTopic.call(topic, @form) do
47
+ UpdateStaticPageTopic.call(@form, topic) do
48
48
  on(:ok) do
49
49
  flash[:notice] = I18n.t("static_page_topics.update.success", scope: "decidim.admin")
50
50
  redirect_to static_page_topics_path
@@ -60,7 +60,7 @@ module Decidim
60
60
  def destroy
61
61
  enforce_permission_to :destroy, :static_page_topic, static_page_topic: topic
62
62
 
63
- DestroyStaticPageTopic.call(topic, current_user) do
63
+ Decidim::Commands::DestroyResource.call(topic, current_user) do
64
64
  on(:ok) do
65
65
  flash[:notice] = I18n.t("static_page_topics.destroy.success", scope: "decidim.admin")
66
66
  redirect_to static_page_topics_path
@@ -77,7 +77,7 @@ module Decidim
77
77
  enforce_permission_to :update, :static_page, static_page: page
78
78
  @form = form(StaticPageForm).from_params(form_params)
79
79
 
80
- UpdateStaticPage.call(page, @form) do
80
+ UpdateStaticPage.call(@form, page) do
81
81
  on(:ok) do
82
82
  flash[:notice] = I18n.t("static_pages.update.success", scope: "decidim.admin")
83
83
  redirect_to static_pages_path
@@ -93,7 +93,7 @@ module Decidim
93
93
  def destroy
94
94
  enforce_permission_to :destroy, :static_page, static_page: page
95
95
 
96
- DestroyStaticPage.call(page, current_user) do
96
+ Decidim::Commands::DestroyResource.call(page, current_user) do
97
97
  on(:ok) do
98
98
  flash[:notice] = I18n.t("static_pages.destroy.success", scope: "decidim.admin")
99
99
  redirect_to static_pages_path