decidim-admin 0.23.5 → 0.24.2

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

Potentially problematic release.


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

Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/decidim_admin_manifest.js +1 -0
  3. data/app/assets/javascripts/decidim/admin/application.js.es6 +4 -1
  4. data/app/assets/javascripts/decidim/admin/budget_rule_toggler.component.js.es6 +23 -20
  5. data/app/assets/javascripts/decidim/admin/bundle.js +10 -17
  6. data/app/assets/javascripts/decidim/admin/bundle.js.map +1 -1
  7. data/app/assets/javascripts/decidim/admin/form.js.es6 +1 -0
  8. data/app/assets/javascripts/decidim/admin/import_guidance.js.es6 +29 -0
  9. data/app/assets/javascripts/decidim/admin/moderations.js.es6 +24 -0
  10. data/app/assets/javascripts/decidim/admin/proposal_infinite_edit.js.es6 +20 -0
  11. data/app/assets/javascripts/decidim/admin/subform_multi_toggler.component.js.es6 +2 -2
  12. data/app/assets/javascripts/decidim/admin/subform_toggler.component.js.es6 +2 -2
  13. data/app/assets/javascripts/decidim/admin/user_moderations.js +2 -0
  14. data/app/assets/stylesheets/decidim/admin/_variables.scss +9 -0
  15. data/app/assets/stylesheets/decidim/admin/components/_dropdown-menu.scss +3 -0
  16. data/app/assets/stylesheets/decidim/admin/extra/_action-icon.scss +13 -0
  17. data/app/assets/stylesheets/decidim/admin/extra/_block_user.scss +5 -0
  18. data/app/assets/stylesheets/decidim/admin/extra/_title_bar.scss +1 -0
  19. data/app/assets/stylesheets/decidim/admin/modules/_moderations.scss +39 -0
  20. data/app/assets/stylesheets/decidim/admin/modules/_modules.scss +2 -0
  21. data/app/assets/stylesheets/decidim/admin/modules/_reveal.scss +5 -0
  22. data/app/assets/stylesheets/decidim/admin/modules/_secondary-nav.scss +6 -3
  23. data/app/assets/stylesheets/decidim/admin/modules/_user-login.scss +2 -2
  24. data/app/assets/stylesheets/decidim/admin/user_moderations.scss +3 -0
  25. data/app/assets/stylesheets/decidim/admin/utils/_settings.scss +1 -0
  26. data/app/cells/decidim/admin/content_block/show.erb +1 -1
  27. data/app/cells/decidim/admin/content_block_cell.rb +4 -0
  28. data/app/commands/decidim/admin/block_user.rb +70 -0
  29. data/app/commands/decidim/admin/create_import.rb +29 -0
  30. data/app/commands/decidim/admin/create_participatory_space_private_user.rb +1 -1
  31. data/app/commands/decidim/admin/create_static_page.rb +2 -1
  32. data/app/commands/decidim/admin/hide_resource.rb +21 -0
  33. data/app/commands/decidim/admin/impersonate_user.rb +17 -1
  34. data/app/commands/decidim/admin/promote_managed_user.rb +10 -0
  35. data/app/commands/decidim/admin/reorder_content_blocks.rb +6 -3
  36. data/app/commands/decidim/admin/transfer_user.rb +78 -0
  37. data/app/commands/decidim/admin/unblock_user.rb +48 -0
  38. data/app/commands/decidim/admin/unreport_user.rb +46 -0
  39. data/app/commands/decidim/admin/update_organization_appearance.rb +12 -4
  40. data/app/commands/decidim/admin/update_static_page.rb +2 -1
  41. data/app/commands/decidim/admin/verify_user_group.rb +1 -1
  42. data/app/controllers/concerns/decidim/admin/filterable.rb +1 -1
  43. data/app/controllers/concerns/decidim/admin/global_moderation_context.rb +47 -0
  44. data/app/controllers/concerns/decidim/admin/landing_page.rb +105 -0
  45. data/app/controllers/concerns/decidim/admin/landing_page_content_blocks.rb +118 -0
  46. data/app/controllers/concerns/decidim/moderations/admin/filterable.rb +54 -0
  47. data/app/controllers/decidim/admin/block_user_controller.rb +60 -0
  48. data/app/controllers/decidim/admin/components/base_controller.rb +1 -0
  49. data/app/controllers/decidim/admin/conflicts_controller.rb +46 -0
  50. data/app/controllers/decidim/admin/exports_controller.rb +1 -2
  51. data/app/controllers/decidim/admin/global_moderations/reports_controller.rb +18 -0
  52. data/app/controllers/decidim/admin/global_moderations_controller.rb +32 -0
  53. data/app/controllers/decidim/admin/impersonations_controller.rb +1 -1
  54. data/app/controllers/decidim/admin/imports_controller.rb +52 -0
  55. data/app/controllers/decidim/admin/moderated_users_controller.rb +44 -0
  56. data/app/controllers/decidim/admin/moderations/reports_controller.rb +39 -0
  57. data/app/controllers/decidim/admin/moderations_controller.rb +31 -7
  58. data/app/controllers/decidim/admin/officializations_controller.rb +3 -3
  59. data/app/controllers/decidim/admin/organization_homepage_controller.rb +6 -2
  60. data/app/controllers/decidim/admin/static_pages_controller.rb +7 -0
  61. data/app/events/decidim/resource_hidden_event.rb +37 -0
  62. data/app/forms/decidim/admin/block_user_form.rb +25 -0
  63. data/app/forms/decidim/admin/import_form.rb +85 -0
  64. data/app/forms/decidim/admin/organization_appearance_form.rb +1 -2
  65. data/app/forms/decidim/admin/static_page_form.rb +6 -1
  66. data/app/forms/decidim/admin/transfer_user_form.rb +19 -0
  67. data/app/helpers/decidim/admin/admin_terms_helper.rb +0 -7
  68. data/app/helpers/decidim/admin/application_helper.rb +5 -4
  69. data/app/helpers/decidim/admin/exports_helper.rb +2 -2
  70. data/app/helpers/decidim/admin/filterable_helper.rb +3 -2
  71. data/app/helpers/decidim/admin/imports_helper.rb +43 -0
  72. data/app/helpers/decidim/admin/menu_helper.rb +10 -0
  73. data/app/helpers/decidim/admin/moderations/reports_helper.rb +40 -0
  74. data/app/helpers/decidim/admin/moderations_helper.rb +36 -0
  75. data/app/helpers/decidim/admin/newsletters_helper.rb +4 -10
  76. data/app/helpers/decidim/admin/settings_helper.rb +2 -1
  77. data/app/helpers/decidim/admin/sidebar_menu_helper.rb +13 -0
  78. data/app/helpers/decidim/admin/user_moderations_helper.rb +6 -0
  79. data/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb +1 -1
  80. data/app/jobs/decidim/admin/verify_user_group_from_csv_job.rb +1 -1
  81. data/app/permissions/decidim/admin/permissions.rb +7 -6
  82. data/app/presenters/decidim/admin/dashboard_metric_charts_presenter.rb +1 -1
  83. data/app/presenters/decidim/admin/secondary_menu_presenter.rb +26 -0
  84. data/app/queries/decidim/admin/active_users_counter.rb +1 -2
  85. data/app/queries/decidim/admin/user_filter.rb +1 -2
  86. data/app/views/decidim/admin/admin_terms/show.html.erb +1 -1
  87. data/app/views/decidim/admin/area_types/index.html.erb +2 -2
  88. data/app/views/decidim/admin/areas/index.html.erb +1 -1
  89. data/app/views/decidim/admin/attachment_collections/index.html.erb +1 -1
  90. data/app/views/decidim/admin/attachments/index.html.erb +1 -1
  91. data/app/views/decidim/admin/block_user/new.html.erb +22 -0
  92. data/app/views/decidim/admin/categories/index.html.erb +1 -1
  93. data/app/views/decidim/admin/components/_component.html.erb +12 -0
  94. data/app/views/decidim/admin/conflicts/edit.html.erb +46 -0
  95. data/app/views/decidim/admin/conflicts/index.html.erb +34 -0
  96. data/app/views/decidim/admin/dashboard/show.html.erb +2 -1
  97. data/app/views/decidim/admin/exports/_dropdown.html.erb +1 -1
  98. data/app/views/decidim/admin/imports/_dropdown.html.erb +9 -0
  99. data/app/views/decidim/admin/imports/new.html.erb +57 -0
  100. data/app/views/decidim/admin/moderated_users/_report.html.erb +10 -0
  101. data/app/views/decidim/admin/moderated_users/index.html.erb +78 -0
  102. data/app/views/decidim/admin/moderations/_report.html.erb +1 -1
  103. data/app/views/decidim/admin/moderations/index.html.erb +28 -9
  104. data/app/views/decidim/admin/moderations/reports/index.html.erb +102 -0
  105. data/app/views/decidim/admin/moderations/reports/show.html.erb +62 -0
  106. data/app/views/decidim/admin/newsletters/index.html.erb +1 -1
  107. data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +3 -3
  108. data/app/views/decidim/admin/newsletters/show.html.erb +1 -1
  109. data/app/views/decidim/admin/officializations/index.html.erb +13 -4
  110. data/app/views/decidim/admin/organization_appearance/_form.html.erb +0 -4
  111. data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +1 -1
  112. data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +4 -4
  113. data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +1 -1
  114. data/app/views/decidim/admin/scopes/index.html.erb +1 -1
  115. data/app/views/decidim/admin/shared/landing_page/edit.html.erb +47 -0
  116. data/app/views/decidim/admin/shared/landing_page_content_blocks/edit.html.erb +15 -0
  117. data/app/views/decidim/admin/static_pages/_form.html.erb +6 -0
  118. data/app/views/decidim/admin/static_pages/_topic.html.erb +3 -3
  119. data/app/views/decidim/admin/users/index.html.erb +2 -2
  120. data/app/views/layouts/decidim/admin/_application.html.erb +6 -1
  121. data/app/views/layouts/decidim/admin/_js_configuration.html.erb +26 -0
  122. data/app/views/layouts/decidim/admin/_title_bar.html.erb +2 -2
  123. data/app/views/layouts/decidim/admin/global_moderations.html.erb +7 -0
  124. data/app/views/layouts/decidim/admin/newsletters.erb +1 -1
  125. data/app/views/layouts/decidim/admin/pages.html.erb +2 -2
  126. data/app/views/layouts/decidim/admin/settings.html.erb +2 -33
  127. data/app/views/layouts/decidim/admin/users.html.erb +11 -0
  128. data/config/locales/ar.yml +0 -5
  129. data/config/locales/bg.yml +0 -1
  130. data/config/locales/ca.yml +150 -4
  131. data/config/locales/cs.yml +151 -5
  132. data/config/locales/de.yml +150 -5
  133. data/config/locales/el.yml +55 -5
  134. data/config/locales/en.yml +151 -5
  135. data/config/locales/es-MX.yml +149 -3
  136. data/config/locales/es-PY.yml +149 -3
  137. data/config/locales/es.yml +149 -3
  138. data/config/locales/eu.yml +0 -3
  139. data/config/locales/fi-plain.yml +149 -3
  140. data/config/locales/fi.yml +149 -3
  141. data/config/locales/fr-CA.yml +146 -4
  142. data/config/locales/fr.yml +146 -4
  143. data/config/locales/gl.yml +120 -5
  144. data/config/locales/hu.yml +13 -5
  145. data/config/locales/id-ID.yml +0 -3
  146. data/config/locales/is-IS.yml +19 -3
  147. data/config/locales/it.yml +59 -5
  148. data/config/locales/ja.yml +59 -5
  149. data/config/locales/lv.yml +0 -5
  150. data/config/locales/nl.yml +113 -4
  151. data/config/locales/no.yml +11 -5
  152. data/config/locales/pl.yml +150 -5
  153. data/config/locales/pt-BR.yml +0 -3
  154. data/config/locales/pt.yml +0 -5
  155. data/config/locales/ro-RO.yml +102 -5
  156. data/config/locales/ru.yml +0 -3
  157. data/config/locales/sk.yml +0 -5
  158. data/config/locales/sl.yml +0 -1
  159. data/config/locales/sr-CS.yml +0 -3
  160. data/config/locales/sv.yml +149 -4
  161. data/config/locales/tr-TR.yml +81 -4
  162. data/config/locales/uk.yml +0 -3
  163. data/config/locales/zh-CN.yml +0 -5
  164. data/config/routes.rb +21 -1
  165. data/lib/decidim/admin.rb +6 -0
  166. data/lib/decidim/admin/engine.rb +76 -1
  167. data/lib/decidim/admin/import.rb +12 -0
  168. data/lib/decidim/admin/import/creator.rb +82 -0
  169. data/lib/decidim/admin/import/importer.rb +82 -0
  170. data/lib/decidim/admin/import/importer_factory.rb +17 -0
  171. data/lib/decidim/admin/import/readers.rb +39 -0
  172. data/lib/decidim/admin/import/readers/base.rb +31 -0
  173. data/lib/decidim/admin/import/readers/csv.rb +23 -0
  174. data/lib/decidim/admin/import/readers/json.rb +25 -0
  175. data/lib/decidim/admin/import/readers/xls.rb +25 -0
  176. data/lib/decidim/admin/test/commands/create_attachment_collection_examples.rb +6 -6
  177. data/lib/decidim/admin/test/commands/create_category_examples.rb +6 -6
  178. data/lib/decidim/admin/test/filterable_examples.rb +1 -8
  179. data/lib/decidim/admin/test/manage_moderations_examples.rb +68 -4
  180. data/lib/decidim/admin/version.rb +1 -1
  181. metadata +71 -15
  182. data/app/assets/javascripts/decidim/admin/gallery.js.es6 +0 -5
@@ -14,6 +14,7 @@ module Decidim
14
14
 
15
15
  helper Decidim::ResourceHelper
16
16
  helper Decidim::Admin::ExportsHelper
17
+ helper Decidim::Admin::ImportsHelper
17
18
  helper Decidim::Admin::BulkActionsHelper
18
19
  helper Decidim::Admin::ResourcePermissionsHelper
19
20
 
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ class ConflictsController < Decidim::Admin::ApplicationController
6
+ layout "decidim/admin/users"
7
+
8
+ def index
9
+ @conflicts = Decidim::Verifications::Conflict.all
10
+ end
11
+
12
+ def edit
13
+ conflict = Decidim::Verifications::Conflict.find(params[:id])
14
+
15
+ @form = form(TransferUserForm).from_params(
16
+ user: conflict.current_user,
17
+ managed_user: conflict.managed_user,
18
+ conflict: conflict
19
+ )
20
+ end
21
+
22
+ def update
23
+ conflict = Decidim::Verifications::Conflict.find(params[:id])
24
+
25
+ @form = form(TransferUserForm).from_params(
26
+ current_user: current_user,
27
+ conflict: conflict,
28
+ reason: params[:transfer_user][:reason],
29
+ email: params[:transfer_user][:email]
30
+ )
31
+
32
+ TransferUser.call(@form) do
33
+ on(:ok) do
34
+ flash[:notice] = I18n.t("success", scope: "decidim.admin.conflicts.transfer")
35
+ redirect_to conflicts_path
36
+ end
37
+
38
+ on(:invalid) do
39
+ flash.now[:alert] = I18n.t("error", scope: "decidim.admin.conflicts.transfer")
40
+ redirect_to decidim.root_path
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -9,8 +9,7 @@ module Decidim
9
9
  def create
10
10
  enforce_permission_to :export, :component_data, component: component
11
11
  name = params[:id]
12
-
13
- ExportJob.perform_later(current_user, component, name, params[:format] || default_format)
12
+ ExportJob.perform_later(current_user, component, name, params[:format] || default_format, params[:resource_id].presence)
14
13
 
15
14
  flash[:notice] = t("decidim.admin.exports.notice")
16
15
 
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ module GlobalModerations
6
+ # This controller allows admins to manage reports in a moderation.
7
+ class ReportsController < Decidim::Admin::Moderations::ReportsController
8
+ layout "decidim/admin/global_moderations"
9
+
10
+ include Decidim::Admin::GlobalModerationContext
11
+
12
+ def moderation
13
+ @moderation ||= moderations_for_user.find(params[:moderation_id])
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ # This controller allows admin users to manage all moderations from the
6
+ # participatory spaces they have access to.
7
+ class GlobalModerationsController < Decidim::Admin::ModerationsController
8
+ layout "decidim/admin/global_moderations"
9
+
10
+ include Decidim::Admin::GlobalModerationContext
11
+
12
+ # Private: This method is used by the `Filterable` concern as the base query
13
+ # without applying filtering and/or sorting options.
14
+ def collection
15
+ @collection ||=
16
+ if params[:hidden]
17
+ moderations_for_user.where.not(hidden_at: nil)
18
+ else
19
+ moderations_for_user.where(hidden_at: nil)
20
+ end
21
+ end
22
+
23
+ # Private: fins the reportable of the specific moderation the user is
24
+ # trying to manage.
25
+ #
26
+ # Returns a resource implementing the `Decidim::Reportable` concern.
27
+ def reportable
28
+ @reportable ||= moderations_for_user.find(params[:id]).reportable
29
+ end
30
+ end
31
+ end
32
+ end
@@ -97,7 +97,7 @@ module Decidim
97
97
  managed: true,
98
98
  name: params.dig(:impersonate_user, :name)
99
99
  ) do |u|
100
- u.nickname = UserBaseEntity.nicknamize(u.name, organization: current_organization)
100
+ u.nickname = Decidim::UserBaseEntity.nicknamize(u.name, organization: current_organization)
101
101
  u.admin = false
102
102
  u.tos_agreement = true
103
103
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ # This controller allows admins to import resources from a file.
6
+ class ImportsController < Decidim::Admin::ApplicationController
7
+ include Decidim::ComponentPathHelper
8
+
9
+ def new
10
+ enforce_permission_to :import, :component_data, component: current_component
11
+ @form = form(Admin::ImportForm).from_params(
12
+ {
13
+ # We need to set "default" creator because form-class doesn't have context / current_component
14
+ # when it sets it's default values.
15
+ creator: current_component.manifest.import_manifests.first.creator
16
+ },
17
+ current_component: current_component
18
+ )
19
+ end
20
+
21
+ def create
22
+ enforce_permission_to :import, :component_data, component: current_component
23
+
24
+ @form = form(Admin::ImportForm).from_params(
25
+ params,
26
+ current_component: current_component,
27
+ current_organization: current_organization
28
+ )
29
+
30
+ CreateImport.call(@form) do
31
+ on(:ok) do |imported_data|
32
+ flash[:notice] = t("decidim.admin.imports.notice",
33
+ number: imported_data.length,
34
+ resource_name: imported_data.first.resource_manifest.name.pluralize)
35
+ redirect_to manage_component_path(current_component)
36
+ end
37
+
38
+ on(:invalid) do
39
+ flash.now[:alert] = t("decidim.admin.imports.error")
40
+ render :new
41
+ end
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def current_component
48
+ @current_component ||= current_participatory_space.components.find(params[:component_id])
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ class ModeratedUsersController < Decidim::Admin::ApplicationController
6
+ include Decidim::Moderations::Admin::Filterable
7
+
8
+ layout "decidim/admin/users"
9
+
10
+ def index
11
+ enforce_permission_to :read, :moderate_users
12
+
13
+ @moderated_users = filtered_collection.page(params[:page]).per(15)
14
+ end
15
+
16
+ def ignore
17
+ enforce_permission_to :unreport, :moderate_users
18
+
19
+ Admin::UnreportUser.call(reportable, current_user) do
20
+ on(:ok) do
21
+ flash[:notice] = I18n.t("reportable.unreport.success", scope: "decidim.moderations.admin")
22
+ redirect_to moderated_users_path
23
+ end
24
+
25
+ on(:invalid) do
26
+ flash.now[:alert] = I18n.t("reportable.unreport.invalid", scope: "decidim.moderations.admin")
27
+ redirect_to moderated_users_path
28
+ end
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def reportable
35
+ @reportable ||= UserModeration.find(params[:id]).user
36
+ end
37
+
38
+ def collection
39
+ target_scope = params[:blocked] && params[:blocked] == "true" ? :blocked : :unblocked
40
+ UserModeration.send(target_scope)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ module Moderations
6
+ # This controller allows admins to manage reports in a moderation.
7
+ class ReportsController < Decidim::Admin::ApplicationController
8
+ helper_method :moderation, :reports, :permission_resource
9
+
10
+ def index
11
+ enforce_permission_to :read, permission_resource
12
+ end
13
+
14
+ def show
15
+ enforce_permission_to :read, permission_resource
16
+ @report = reports.find(params[:id])
17
+ end
18
+
19
+ private
20
+
21
+ def reports
22
+ @reports ||= moderation.reports
23
+ end
24
+
25
+ def moderation
26
+ @moderation ||= participatory_space_moderations.find(params[:moderation_id])
27
+ end
28
+
29
+ def participatory_space_moderations
30
+ @participatory_space_moderations ||= Decidim::Moderation.where(participatory_space: current_participatory_space)
31
+ end
32
+
33
+ def permission_resource
34
+ :moderation
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -4,14 +4,21 @@ module Decidim
4
4
  module Admin
5
5
  # This controller allows admins to manage moderations in a participatory process.
6
6
  class ModerationsController < Decidim::Admin::ApplicationController
7
- helper_method :moderations, :allowed_to?
7
+ include Decidim::Moderations::Admin::Filterable
8
+
9
+ helper_method :moderations, :allowed_to?, :query, :permission_resource
8
10
 
9
11
  def index
10
- enforce_permission_to :read, :moderation
12
+ enforce_permission_to :read, permission_resource
13
+ end
14
+
15
+ def show
16
+ enforce_permission_to :read, permission_resource
17
+ @moderation = collection.find(params[:id])
11
18
  end
12
19
 
13
20
  def unreport
14
- enforce_permission_to :unreport, :moderation
21
+ enforce_permission_to :unreport, permission_resource
15
22
 
16
23
  Admin::UnreportResource.call(reportable, current_user) do
17
24
  on(:ok) do
@@ -27,7 +34,7 @@ module Decidim
27
34
  end
28
35
 
29
36
  def hide
30
- enforce_permission_to :hide, :moderation
37
+ enforce_permission_to :hide, permission_resource
31
38
 
32
39
  Admin::HideResource.call(reportable, current_user) do
33
40
  on(:ok) do
@@ -43,7 +50,7 @@ module Decidim
43
50
  end
44
51
 
45
52
  def unhide
46
- enforce_permission_to :unhide, :moderation
53
+ enforce_permission_to :unhide, permission_resource
47
54
 
48
55
  Admin::UnhideResource.call(reportable, current_user) do
49
56
  on(:ok) do
@@ -60,8 +67,10 @@ module Decidim
60
67
 
61
68
  private
62
69
 
63
- def moderations
64
- @moderations ||= begin
70
+ # Private: This method is used by the `Filterable` concern as the base query
71
+ # without applying filtering and/or sorting options.
72
+ def collection
73
+ @collection ||= begin
65
74
  if params[:hidden]
66
75
  participatory_space_moderations.where.not(hidden_at: nil)
67
76
  else
@@ -70,6 +79,13 @@ module Decidim
70
79
  end
71
80
  end
72
81
 
82
+ # Private: Returns a collection of `Moderation` filtered and/or sorted by
83
+ # some criteria. The `filtered_collection` is provided by the
84
+ # `Filterable` concern.
85
+ def moderations
86
+ @moderations ||= filtered_collection
87
+ end
88
+
73
89
  def reportable
74
90
  @reportable ||= participatory_space_moderations.find(params[:id]).reportable
75
91
  end
@@ -77,6 +93,14 @@ module Decidim
77
93
  def participatory_space_moderations
78
94
  @participatory_space_moderations ||= Decidim::Moderation.where(participatory_space: current_participatory_space)
79
95
  end
96
+
97
+ # Private: Defines the resource that permissions will check. This is
98
+ # added so that the `GlobalModerationController` can overwrite this method
99
+ # and define the custom permission resource, so that the permission system
100
+ # is not overridden.
101
+ def permission_resource
102
+ :moderation
103
+ end
80
104
  end
81
105
  end
82
106
  end
@@ -32,7 +32,7 @@ module Decidim
32
32
  on(:ok) do |user|
33
33
  notice = I18n.t("officializations.create.success", scope: "decidim.admin")
34
34
 
35
- redirect_to officializations_path(q: user.name), notice: notice
35
+ redirect_to officializations_path(q: { name_or_nickname_or_email_cont: user.name }), notice: notice
36
36
  end
37
37
  end
38
38
  end
@@ -44,7 +44,7 @@ module Decidim
44
44
  on(:ok) do
45
45
  notice = I18n.t("officializations.destroy.success", scope: "decidim.admin")
46
46
 
47
- redirect_to officializations_path(q: user.name), notice: notice
47
+ redirect_to officializations_path(q: { name_or_nickname_or_email_cont: user.name }), notice: notice
48
48
  end
49
49
  end
50
50
  end
@@ -60,7 +60,7 @@ module Decidim
60
60
  private
61
61
 
62
62
  def collection
63
- @collection ||= current_organization.users.not_deleted
63
+ @collection ||= current_organization.users.not_deleted.left_outer_joins(:user_moderation)
64
64
  end
65
65
 
66
66
  def user
@@ -31,11 +31,15 @@ module Decidim
31
31
  end
32
32
 
33
33
  def active_blocks
34
- @active_blocks ||= content_blocks.published
34
+ @active_blocks ||= content_blocks.published.where(manifest_name: Decidim.content_blocks.for(:homepage).map(&:name))
35
+ end
36
+
37
+ def unpublished_blocks
38
+ @unpublished_blocks ||= content_blocks.unpublished.where(manifest_name: Decidim.content_blocks.for(:homepage).map(&:name))
35
39
  end
36
40
 
37
41
  def inactive_blocks
38
- @inactive_blocks ||= content_blocks.unpublished + unused_manifests
42
+ @inactive_blocks ||= unpublished_blocks + unused_manifests
39
43
  end
40
44
 
41
45
  def used_manifests
@@ -82,6 +82,13 @@ module Decidim
82
82
  form_params = params.to_unsafe_hash
83
83
  form_params["static_page"] ||= {}
84
84
  form_params["static_page"]["organization"] = current_organization
85
+ form_params["static_page"]["allow_public_access"] ||= begin
86
+ if page
87
+ page.allow_public_access
88
+ else
89
+ false
90
+ end
91
+ end
85
92
 
86
93
  return form_params unless page
87
94
 
@@ -0,0 +1,37 @@
1
+ # frozen-string_literal: true
2
+
3
+ module Decidim
4
+ class ResourceHiddenEvent < Decidim::Events::SimpleEvent
5
+ i18n_attributes :resource_path, :report_reasons, :resource_type, :resource_content
6
+
7
+ def resource_path
8
+ @resource.reported_content_url
9
+ end
10
+
11
+ def resource_url
12
+ @resource.reported_content_url
13
+ end
14
+
15
+ def report_reasons
16
+ extra["report_reasons"].map do |reason|
17
+ I18n.t("decidim.admin.moderations.report.reasons.#{reason}").downcase
18
+ end.join(", ")
19
+ end
20
+
21
+ def resource_title
22
+ nil
23
+ end
24
+
25
+ def resource_content
26
+ translated_attribute(@resource[@resource.reported_attributes.first]).truncate(100, separator: " ")
27
+ end
28
+
29
+ def resource_text
30
+ "<i>#{resource_content}</i>"
31
+ end
32
+
33
+ def resource_type
34
+ @resource.model_name.human.downcase
35
+ end
36
+ end
37
+ end