decidim-admin 0.23.2 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim-admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/config/decidim_admin_manifest.js +1 -0
- data/app/assets/javascripts/decidim/admin/application.js.es6 +3 -1
- data/app/assets/javascripts/decidim/admin/budget_rule_toggler.component.js.es6 +23 -20
- data/app/assets/javascripts/decidim/admin/bundle.js +10 -17
- data/app/assets/javascripts/decidim/admin/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/admin/form.js.es6 +1 -0
- data/app/assets/javascripts/decidim/admin/import_guidance.js.es6 +29 -0
- data/app/assets/javascripts/decidim/admin/moderations.js.es6 +24 -0
- data/app/assets/javascripts/decidim/admin/proposal_infinite_edit.js.es6 +20 -0
- data/app/assets/javascripts/decidim/admin/subform_multi_toggler.component.js.es6 +2 -2
- data/app/assets/javascripts/decidim/admin/subform_toggler.component.js.es6 +2 -2
- data/app/assets/javascripts/decidim/admin/user_moderations.js +2 -0
- data/app/assets/stylesheets/decidim/admin/_variables.scss +9 -0
- data/app/assets/stylesheets/decidim/admin/components/_dropdown-menu.scss +3 -0
- data/app/assets/stylesheets/decidim/admin/extra/_action-icon.scss +13 -0
- data/app/assets/stylesheets/decidim/admin/extra/_block_user.scss +5 -0
- data/app/assets/stylesheets/decidim/admin/extra/_title_bar.scss +1 -0
- data/app/assets/stylesheets/decidim/admin/modules/_moderations.scss +39 -0
- data/app/assets/stylesheets/decidim/admin/modules/_modules.scss +2 -0
- data/app/assets/stylesheets/decidim/admin/modules/_reveal.scss +5 -0
- data/app/assets/stylesheets/decidim/admin/modules/_secondary-nav.scss +6 -3
- data/app/assets/stylesheets/decidim/admin/modules/_user-login.scss +2 -2
- data/app/assets/stylesheets/decidim/admin/user_moderations.scss +3 -0
- data/app/assets/stylesheets/decidim/admin/utils/_settings.scss +1 -0
- data/app/cells/decidim/admin/content_block/show.erb +1 -1
- data/app/cells/decidim/admin/content_block_cell.rb +4 -0
- data/app/commands/decidim/admin/block_user.rb +70 -0
- data/app/commands/decidim/admin/create_import.rb +29 -0
- data/app/commands/decidim/admin/create_participatory_space_admin_user_actions.rb +98 -0
- data/app/commands/decidim/admin/create_participatory_space_private_user.rb +1 -1
- data/app/commands/decidim/admin/create_static_page.rb +2 -1
- data/app/commands/decidim/admin/hide_resource.rb +21 -0
- data/app/commands/decidim/admin/impersonate_user.rb +17 -1
- data/app/commands/decidim/admin/promote_managed_user.rb +10 -0
- data/app/commands/decidim/admin/reorder_content_blocks.rb +6 -3
- data/app/commands/decidim/admin/transfer_user.rb +78 -0
- data/app/commands/decidim/admin/unblock_user.rb +48 -0
- data/app/commands/decidim/admin/unreport_user.rb +46 -0
- data/app/commands/decidim/admin/update_organization_appearance.rb +12 -4
- data/app/commands/decidim/admin/update_static_page.rb +2 -1
- data/app/commands/decidim/admin/verify_user_group.rb +1 -1
- data/app/controllers/concerns/decidim/admin/filterable.rb +1 -1
- data/app/controllers/concerns/decidim/admin/global_moderation_context.rb +47 -0
- data/app/controllers/concerns/decidim/admin/landing_page.rb +105 -0
- data/app/controllers/concerns/decidim/admin/landing_page_content_blocks.rb +118 -0
- data/app/controllers/concerns/decidim/moderations/admin/filterable.rb +54 -0
- data/app/controllers/decidim/admin/block_user_controller.rb +60 -0
- data/app/controllers/decidim/admin/components/base_controller.rb +1 -0
- data/app/controllers/decidim/admin/conflicts_controller.rb +46 -0
- data/app/controllers/decidim/admin/exports_controller.rb +1 -2
- data/app/controllers/decidim/admin/global_moderations/reports_controller.rb +18 -0
- data/app/controllers/decidim/admin/global_moderations_controller.rb +32 -0
- data/app/controllers/decidim/admin/impersonations_controller.rb +1 -1
- data/app/controllers/decidim/admin/imports_controller.rb +52 -0
- data/app/controllers/decidim/admin/moderated_users_controller.rb +44 -0
- data/app/controllers/decidim/admin/moderations/reports_controller.rb +39 -0
- data/app/controllers/decidim/admin/moderations_controller.rb +31 -7
- data/app/controllers/decidim/admin/officializations_controller.rb +3 -3
- data/app/controllers/decidim/admin/organization_homepage_controller.rb +6 -2
- data/app/controllers/decidim/admin/static_pages_controller.rb +7 -0
- data/app/events/decidim/resource_hidden_event.rb +37 -0
- data/app/forms/decidim/admin/block_user_form.rb +25 -0
- data/app/forms/decidim/admin/import_form.rb +85 -0
- data/app/forms/decidim/admin/organization_appearance_form.rb +1 -2
- data/app/forms/decidim/admin/static_page_form.rb +6 -1
- data/app/forms/decidim/admin/transfer_user_form.rb +19 -0
- data/app/helpers/decidim/admin/admin_terms_helper.rb +0 -7
- data/app/helpers/decidim/admin/application_helper.rb +5 -4
- data/app/helpers/decidim/admin/exports_helper.rb +2 -2
- data/app/helpers/decidim/admin/filterable_helper.rb +3 -2
- data/app/helpers/decidim/admin/imports_helper.rb +43 -0
- data/app/helpers/decidim/admin/menu_helper.rb +10 -0
- data/app/helpers/decidim/admin/moderations/reports_helper.rb +40 -0
- data/app/helpers/decidim/admin/moderations_helper.rb +36 -0
- data/app/helpers/decidim/admin/newsletters_helper.rb +4 -10
- data/app/helpers/decidim/admin/settings_helper.rb +2 -1
- data/app/helpers/decidim/admin/sidebar_menu_helper.rb +13 -0
- data/app/helpers/decidim/admin/user_moderations_helper.rb +6 -0
- data/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb +1 -1
- data/app/jobs/decidim/admin/verify_user_group_from_csv_job.rb +1 -1
- data/app/permissions/decidim/admin/permissions.rb +7 -6
- data/app/presenters/decidim/admin/dashboard_metric_charts_presenter.rb +1 -1
- data/app/presenters/decidim/admin/secondary_menu_presenter.rb +26 -0
- data/app/queries/decidim/admin/active_users_counter.rb +1 -2
- data/app/queries/decidim/admin/user_filter.rb +1 -2
- data/app/views/decidim/admin/admin_terms/show.html.erb +1 -1
- data/app/views/decidim/admin/attachment_collections/index.html.erb +1 -1
- data/app/views/decidim/admin/attachments/index.html.erb +1 -1
- data/app/views/decidim/admin/block_user/new.html.erb +22 -0
- data/app/views/decidim/admin/categories/index.html.erb +1 -1
- data/app/views/decidim/admin/components/_component.html.erb +12 -0
- data/app/views/decidim/admin/components/_form.html.erb +1 -1
- data/app/views/decidim/admin/conflicts/edit.html.erb +46 -0
- data/app/views/decidim/admin/conflicts/index.html.erb +34 -0
- data/app/views/decidim/admin/dashboard/show.html.erb +2 -1
- data/app/views/decidim/admin/exports/_dropdown.html.erb +1 -1
- data/app/views/decidim/admin/imports/_dropdown.html.erb +9 -0
- data/app/views/decidim/admin/imports/new.html.erb +57 -0
- data/app/views/decidim/admin/moderated_users/_report.html.erb +10 -0
- data/app/views/decidim/admin/moderated_users/index.html.erb +78 -0
- data/app/views/decidim/admin/moderations/_report.html.erb +1 -1
- data/app/views/decidim/admin/moderations/index.html.erb +28 -9
- data/app/views/decidim/admin/moderations/reports/index.html.erb +102 -0
- data/app/views/decidim/admin/moderations/reports/show.html.erb +62 -0
- data/app/views/decidim/admin/newsletters/index.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +2 -2
- data/app/views/decidim/admin/officializations/index.html.erb +13 -4
- data/app/views/decidim/admin/organization_appearance/_form.html.erb +0 -4
- data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +1 -1
- data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +4 -4
- data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +1 -1
- data/app/views/decidim/admin/shared/landing_page/edit.html.erb +47 -0
- data/app/views/decidim/admin/shared/landing_page_content_blocks/edit.html.erb +15 -0
- data/app/views/decidim/admin/static_pages/_form.html.erb +6 -0
- data/app/views/decidim/admin/users/index.html.erb +1 -1
- data/app/views/layouts/decidim/admin/_application.html.erb +5 -1
- data/app/views/layouts/decidim/admin/_title_bar.html.erb +2 -2
- data/app/views/layouts/decidim/admin/global_moderations.html.erb +7 -0
- data/app/views/layouts/decidim/admin/newsletters.erb +1 -1
- data/app/views/layouts/decidim/admin/settings.html.erb +2 -33
- data/app/views/layouts/decidim/admin/users.html.erb +11 -0
- data/config/locales/ar.yml +0 -5
- data/config/locales/bg.yml +0 -1
- data/config/locales/ca.yml +149 -4
- data/config/locales/cs.yml +151 -6
- data/config/locales/de.yml +150 -5
- data/config/locales/el.yml +62 -5
- data/config/locales/en.yml +150 -5
- data/config/locales/es-MX.yml +148 -3
- data/config/locales/es-PY.yml +148 -3
- data/config/locales/es.yml +148 -3
- data/config/locales/eu.yml +0 -3
- data/config/locales/fi-plain.yml +148 -3
- data/config/locales/fi.yml +148 -3
- data/config/locales/fr-CA.yml +139 -4
- data/config/locales/fr.yml +139 -4
- data/config/locales/gl.yml +121 -5
- data/config/locales/hu.yml +13 -5
- data/config/locales/id-ID.yml +0 -3
- data/config/locales/is-IS.yml +36 -3
- data/config/locales/it.yml +59 -5
- data/config/locales/ja.yml +41 -8
- data/config/locales/lv.yml +0 -5
- data/config/locales/nl.yml +120 -7
- data/config/locales/no.yml +11 -5
- data/config/locales/pl.yml +166 -20
- data/config/locales/pt-BR.yml +0 -3
- data/config/locales/pt.yml +0 -5
- data/config/locales/ro-RO.yml +21 -5
- data/config/locales/ru.yml +0 -3
- data/config/locales/sk.yml +0 -5
- data/config/locales/sl.yml +0 -1
- data/config/locales/sr-CS.yml +0 -3
- data/config/locales/sv.yml +50 -4
- data/config/locales/tr-TR.yml +81 -4
- data/config/locales/uk.yml +0 -3
- data/config/locales/zh-CN.yml +0 -5
- data/config/routes.rb +21 -1
- data/lib/decidim/admin.rb +6 -0
- data/lib/decidim/admin/engine.rb +76 -1
- data/lib/decidim/admin/import.rb +12 -0
- data/lib/decidim/admin/import/creator.rb +82 -0
- data/lib/decidim/admin/import/importer.rb +82 -0
- data/lib/decidim/admin/import/importer_factory.rb +17 -0
- data/lib/decidim/admin/import/readers.rb +39 -0
- data/lib/decidim/admin/import/readers/base.rb +31 -0
- data/lib/decidim/admin/import/readers/csv.rb +23 -0
- data/lib/decidim/admin/import/readers/json.rb +25 -0
- data/lib/decidim/admin/import/readers/xls.rb +25 -0
- data/lib/decidim/admin/test/commands/create_attachment_collection_examples.rb +6 -6
- data/lib/decidim/admin/test/commands/create_category_examples.rb +6 -6
- data/lib/decidim/admin/test/filterable_examples.rb +1 -8
- data/lib/decidim/admin/test/manage_moderations_examples.rb +68 -4
- data/lib/decidim/admin/version.rb +1 -1
- metadata +71 -15
- data/app/assets/javascripts/decidim/admin/gallery.js.es6 +0 -5
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Moderations
|
7
|
+
module Admin
|
8
|
+
module Filterable
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
include Decidim::Admin::Filterable
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def base_query
|
17
|
+
collection
|
18
|
+
end
|
19
|
+
|
20
|
+
def filters
|
21
|
+
[
|
22
|
+
:reportable_type_string_eq
|
23
|
+
]
|
24
|
+
end
|
25
|
+
|
26
|
+
def filters_with_values
|
27
|
+
{
|
28
|
+
reportable_type_string_eq: reportable_types
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def dynamically_translated_filters
|
33
|
+
[:reportable_type_string_eq]
|
34
|
+
end
|
35
|
+
|
36
|
+
def translated_reportable_type_string_eq(value)
|
37
|
+
value.constantize.name.demodulize
|
38
|
+
end
|
39
|
+
|
40
|
+
# Private: the predicate used by `Ransack` to perform a search. We used `reported` instead
|
41
|
+
# of `reportable` because otherwise `Ransack` try to traverse the polymorphic
|
42
|
+
# association automatically and it fails.
|
43
|
+
def search_field_predicate
|
44
|
+
:reported_id_string_or_reported_content_cont
|
45
|
+
end
|
46
|
+
|
47
|
+
def reportable_types
|
48
|
+
collection.pluck(:decidim_reportable_type).uniq.sort
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
class BlockUserController < Decidim::Admin::ApplicationController
|
6
|
+
layout "decidim/admin/users"
|
7
|
+
|
8
|
+
helper_method :user
|
9
|
+
|
10
|
+
def new
|
11
|
+
enforce_permission_to :block, :admin_user
|
12
|
+
|
13
|
+
@form = form(BlockUserForm).from_model(user)
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
enforce_permission_to :block, :admin_user
|
18
|
+
|
19
|
+
@form = form(BlockUserForm).from_params(params)
|
20
|
+
|
21
|
+
BlockUser.call(@form) do
|
22
|
+
on(:ok) do
|
23
|
+
flash[:notice] = I18n.t("officializations.block.success", scope: "decidim.admin")
|
24
|
+
redirect_to officializations_path(q: { name_or_nickname_or_email_cont: user.name }), notice: notice
|
25
|
+
end
|
26
|
+
|
27
|
+
on(:invalid) do
|
28
|
+
flash[:alert] = I18n.t("officializations.block.error", scope: "decidim.admin")
|
29
|
+
render :new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy
|
35
|
+
enforce_permission_to :block, :admin_user
|
36
|
+
|
37
|
+
UnblockUser.call(user, current_user) do
|
38
|
+
on(:ok) do
|
39
|
+
flash[:notice] = I18n.t("officializations.unblock.success", scope: "decidim.admin")
|
40
|
+
end
|
41
|
+
|
42
|
+
on(:invalid) do
|
43
|
+
flash[:alert] = I18n.t("officializations.unblock.error", scope: "decidim.admin")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
redirect_to officializations_path(q: { name_or_nickname_or_email_cont: user.name }), notice: notice
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def user
|
53
|
+
@user ||= Decidim::User.find_by(
|
54
|
+
id: params[:user_id],
|
55
|
+
organization: current_organization
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -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
|
-
|
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,
|
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,
|
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,
|
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,
|
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
|
-
|
64
|
-
|
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
|