decidim-admin 0.29.2 → 0.30.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/admin/multi_select_picker/show.erb +10 -0
- data/app/cells/decidim/admin/multi_select_picker_cell.rb +38 -0
- data/app/commands/decidim/admin/bulk_action.rb +92 -0
- data/app/commands/decidim/admin/bulk_block_users.rb +75 -0
- data/app/commands/decidim/admin/bulk_unblock_users.rb +66 -0
- data/app/commands/decidim/admin/bulk_unreport_users.rb +69 -0
- data/app/commands/decidim/admin/content_blocks/update_content_block.rb +1 -1
- data/app/commands/decidim/admin/create_participatory_space_private_user.rb +3 -1
- data/app/commands/decidim/admin/create_share_token.rb +39 -0
- data/app/commands/decidim/admin/create_taxonomy.rb +23 -0
- data/app/commands/decidim/admin/create_taxonomy_filter.rb +24 -0
- data/app/commands/decidim/admin/destroy_share_token.rb +22 -0
- data/app/commands/decidim/admin/destroy_taxonomy.rb +18 -0
- data/app/commands/decidim/admin/destroy_taxonomy_filter.rb +20 -0
- data/app/commands/decidim/admin/hide_menu_component.rb +37 -0
- data/app/commands/decidim/admin/hide_resource.rb +4 -2
- data/app/commands/decidim/admin/publish_all_participatory_space_private_users.rb +50 -0
- data/app/commands/decidim/admin/publish_component.rb +3 -0
- data/app/commands/decidim/admin/reorder_components.rb +47 -0
- data/app/commands/decidim/admin/reorder_taxonomies.rb +76 -0
- data/app/commands/decidim/admin/unhide_resource.rb +11 -3
- data/app/commands/decidim/admin/unpublish_all_participatory_space_private_users.rb +50 -0
- data/app/commands/decidim/admin/unreport_resource.rb +11 -3
- data/app/commands/decidim/admin/update_component_permissions.rb +53 -13
- data/app/commands/decidim/admin/update_participatory_space_private_user.rb +11 -0
- data/app/commands/decidim/admin/update_share_token.rb +24 -0
- data/app/commands/decidim/admin/update_taxonomy.rb +20 -0
- data/app/commands/decidim/admin/update_taxonomy_filter.rb +28 -0
- data/app/controllers/concerns/decidim/admin/component_taxonomies_helper.rb +19 -0
- data/app/controllers/concerns/decidim/admin/filterable.rb +15 -18
- data/app/controllers/concerns/decidim/admin/has_trashable_resources.rb +170 -0
- data/app/controllers/concerns/decidim/admin/needs_admin_tos_accepted.rb +2 -29
- data/app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb +12 -2
- data/app/controllers/concerns/decidim/admin/taxonomies/filterable.rb +27 -0
- data/app/controllers/decidim/admin/application_controller.rb +1 -2
- data/app/controllers/decidim/admin/areas_controller.rb +1 -0
- data/app/controllers/decidim/admin/block_user_controller.rb +42 -0
- data/app/controllers/decidim/admin/component_permissions_controller.rb +2 -4
- data/app/controllers/decidim/admin/components_controller.rb +50 -9
- data/app/controllers/decidim/admin/concerns/has_private_users.rb +59 -2
- data/app/controllers/decidim/admin/global_moderations_controller.rb +4 -0
- data/app/controllers/decidim/admin/moderated_users_controller.rb +26 -0
- data/app/controllers/decidim/admin/moderations_controller.rb +18 -0
- data/app/controllers/decidim/admin/newsletters_controller.rb +50 -7
- data/app/controllers/decidim/admin/resource_permissions_controller.rb +1 -1
- data/app/controllers/decidim/admin/scopes_controller.rb +1 -0
- data/app/controllers/decidim/admin/share_tokens_controller.rb +109 -7
- data/app/controllers/decidim/admin/taxonomies_controller.rb +129 -0
- data/app/controllers/decidim/admin/taxonomy_filters_controller.rb +112 -0
- data/app/controllers/decidim/admin/taxonomy_filters_selector_controller.rb +81 -0
- data/app/controllers/decidim/admin/taxonomy_items_controller.rb +91 -0
- data/app/forms/concerns/decidim/has_taxonomy_form_attributes.rb +57 -0
- data/app/forms/decidim/admin/block_users_form.rb +21 -0
- data/app/forms/decidim/admin/import_example_form.rb +1 -1
- data/app/forms/decidim/admin/newsletter_form.rb +1 -1
- data/app/forms/decidim/admin/participatory_space_private_user_form.rb +5 -0
- data/app/forms/decidim/admin/selective_newsletter_form.rb +46 -11
- data/app/forms/decidim/admin/share_token_form.rb +55 -0
- data/app/forms/decidim/admin/taxonomy_filter_form.rb +85 -0
- data/app/forms/decidim/admin/taxonomy_form.rb +20 -0
- data/app/forms/decidim/admin/taxonomy_item_form.rb +54 -0
- data/app/helpers/decidim/admin/application_helper.rb +0 -1
- data/app/helpers/decidim/admin/bulk_actions_helper.rb +0 -31
- data/app/helpers/decidim/admin/moderations/reports_helper.rb +1 -1
- data/app/helpers/decidim/admin/moderations_helper.rb +1 -1
- data/app/helpers/decidim/admin/newsletters_helper.rb +57 -27
- data/app/helpers/decidim/admin/scopes_helper.rb +0 -6
- data/app/helpers/decidim/admin/search_form_helper.rb +1 -1
- data/app/helpers/decidim/admin/settings_helper.rb +85 -11
- data/app/jobs/decidim/admin/newsletter_job.rb +3 -1
- data/app/packs/entrypoints/decidim_admin.js +4 -0
- data/app/packs/src/decidim/admin/application.js +2 -0
- data/app/packs/src/decidim/admin/draggable-table.js +33 -0
- data/app/packs/src/decidim/admin/form.js +0 -1
- data/app/packs/src/decidim/admin/global_moderations.js +186 -0
- data/app/packs/src/decidim/admin/managed_moderated_users.js +186 -0
- data/app/packs/src/decidim/admin/newsletters.js +164 -82
- data/app/packs/src/decidim/admin/proposal_infinite_edit.js +3 -6
- data/app/packs/src/decidim/admin/sortable.js +28 -16
- data/app/packs/src/decidim/admin/taxonomy_filters.js +93 -0
- data/app/packs/stylesheets/decidim/admin/_component-show.scss +66 -5
- data/app/packs/stylesheets/decidim/admin/_legacy_foundation.scss +13 -0
- data/app/packs/stylesheets/decidim/admin/_select_picker.scss +20 -0
- data/app/packs/stylesheets/decidim/admin/_table-list.scss +22 -0
- data/app/packs/stylesheets/decidim/admin/_taxonomies.scss +74 -0
- data/app/packs/stylesheets/decidim/admin/application.scss +3 -0
- data/app/permissions/decidim/admin/permissions.rb +32 -1
- data/app/queries/decidim/admin/newsletter_recipients.rb +50 -14
- data/app/views/decidim/admin/areas/index.html.erb +3 -0
- data/app/views/decidim/admin/block_user/bulk_new.html.erb +45 -0
- data/app/views/decidim/admin/components/_actions.html.erb +50 -33
- data/app/views/decidim/admin/components/{_component.html.erb → _component_row.html.erb} +10 -5
- data/app/views/decidim/admin/components/_components_table.html.erb +18 -0
- data/app/views/decidim/admin/components/_form.html.erb +0 -12
- data/app/views/decidim/admin/components/_taxonomy_filters_drawer.html.erb +2 -0
- data/app/views/decidim/admin/components/_visibility_label.html.erb +9 -0
- data/app/views/decidim/admin/components/index.html.erb +12 -14
- data/app/views/decidim/admin/components/manage_trash.html.erb +11 -0
- data/app/views/decidim/admin/moderated_users/_bulk-actions.html.erb +6 -0
- data/app/views/decidim/admin/moderated_users/bulk_actions/_block.html.erb +20 -0
- data/app/views/decidim/admin/moderated_users/bulk_actions/_dropdown.html.erb +40 -0
- data/app/views/decidim/admin/moderated_users/bulk_actions/_unblock.html.erb +20 -0
- data/app/views/decidim/admin/moderated_users/bulk_actions/_unreport.html.erb +20 -0
- data/app/views/decidim/admin/moderated_users/index.html.erb +14 -6
- data/app/views/decidim/admin/moderations/_bulk-actions.html.erb +7 -0
- data/app/views/decidim/admin/moderations/_moderation-tr.html.erb +50 -0
- data/app/views/decidim/admin/moderations/_moderations-thead.html.erb +18 -0
- data/app/views/decidim/admin/moderations/bulk_actions/_dropdown.html.erb +43 -0
- data/app/views/decidim/admin/moderations/bulk_actions/_hide.html.erb +20 -0
- data/app/views/decidim/admin/moderations/bulk_actions/_unhide.html.erb +20 -0
- data/app/views/decidim/admin/moderations/bulk_actions/_unreport.html.erb +20 -0
- data/app/views/decidim/admin/moderations/index.html.erb +13 -81
- data/app/views/decidim/admin/newsletters/confirm_recipients.html.erb +64 -0
- data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +44 -20
- data/app/views/decidim/admin/participatory_space_private_users/_form.html.erb +6 -0
- data/app/views/decidim/admin/participatory_space_private_users/edit.html.erb +19 -0
- data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +15 -1
- data/app/views/decidim/admin/resource_permissions/_options_form.html.erb +5 -0
- data/app/views/decidim/admin/resource_permissions/edit.html.erb +2 -2
- data/app/views/decidim/admin/scope_types/index.html.erb +3 -0
- data/app/views/decidim/admin/scopes/index.html.erb +3 -0
- data/app/views/decidim/admin/share_tokens/_form.html.erb +52 -0
- data/app/views/decidim/admin/share_tokens/edit.html.erb +33 -0
- data/app/views/decidim/admin/share_tokens/index.html.erb +47 -0
- data/app/views/decidim/admin/share_tokens/new.html.erb +69 -0
- data/app/views/decidim/admin/taxonomies/_filters.html.erb +19 -0
- data/app/views/decidim/admin/taxonomies/_form.html.erb +5 -0
- data/app/views/decidim/admin/taxonomies/_row.html.erb +40 -0
- data/app/views/decidim/admin/taxonomies/_row_children.html.erb +8 -0
- data/app/views/decidim/admin/taxonomies/_table.html.erb +86 -0
- data/app/views/decidim/admin/taxonomies/_taxonomy_actions.html.erb +15 -0
- data/app/views/decidim/admin/taxonomies/edit.html.erb +87 -0
- data/app/views/decidim/admin/taxonomies/index.html.erb +28 -0
- data/app/views/decidim/admin/taxonomies/new.html.erb +16 -0
- data/app/views/decidim/admin/taxonomy_filters/_check_boxes.html.erb +10 -0
- data/app/views/decidim/admin/taxonomy_filters/_form.html.erb +96 -0
- data/app/views/decidim/admin/taxonomy_filters/_table.html.erb +33 -0
- data/app/views/decidim/admin/taxonomy_filters/edit.html.erb +22 -0
- data/app/views/decidim/admin/taxonomy_filters/index.html.erb +26 -0
- data/app/views/decidim/admin/taxonomy_filters/new.html.erb +32 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/_check_boxes.html.erb +7 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/_component_table.html.erb +25 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/_taxonomies_select.html.erb +16 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/index.html.erb +1 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/new.html.erb +27 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/show.html.erb +18 -0
- data/app/views/decidim/admin/taxonomy_items/_form.html.erb +8 -0
- data/app/views/decidim/admin/taxonomy_items/edit.html.erb +12 -0
- data/app/views/decidim/admin/taxonomy_items/new.html.erb +12 -0
- data/app/views/layouts/decidim/admin/taxonomy_filters.html.erb +17 -0
- data/app/views/layouts/decidim/admin/taxonomy_filters_selector.html.erb +10 -0
- data/config/locales/ar.yml +45 -37
- data/config/locales/bg.yml +48 -51
- data/config/locales/bs-BA.yml +1 -27
- data/config/locales/ca.yml +300 -50
- data/config/locales/cs.yml +298 -46
- data/config/locales/de.yml +300 -50
- data/config/locales/el.yml +1 -50
- data/config/locales/en.yml +300 -50
- data/config/locales/es-MX.yml +297 -47
- data/config/locales/es-PY.yml +297 -47
- data/config/locales/es.yml +297 -47
- data/config/locales/eu.yml +301 -51
- data/config/locales/fi-plain.yml +297 -47
- data/config/locales/fi.yml +297 -47
- data/config/locales/fr-CA.yml +183 -47
- data/config/locales/fr.yml +183 -47
- data/config/locales/ga-IE.yml +0 -23
- data/config/locales/gl.yml +1 -46
- data/config/locales/hu.yml +1 -51
- data/config/locales/id-ID.yml +0 -24
- data/config/locales/is-IS.yml +0 -30
- data/config/locales/it.yml +1 -46
- data/config/locales/ja.yml +298 -50
- data/config/locales/kaa.yml +0 -7
- data/config/locales/ko.yml +0 -50
- data/config/locales/lb.yml +1 -46
- data/config/locales/lt.yml +1 -50
- data/config/locales/lv.yml +1 -28
- data/config/locales/nl.yml +1 -46
- data/config/locales/no.yml +1 -46
- data/config/locales/pl.yml +3 -51
- data/config/locales/pt-BR.yml +38 -50
- data/config/locales/pt.yml +29 -49
- data/config/locales/ro-RO.yml +35 -50
- data/config/locales/ru.yml +1 -24
- data/config/locales/sk.yml +1 -28
- data/config/locales/sl.yml +0 -5
- data/config/locales/sq-AL.yml +0 -22
- data/config/locales/sr-CS.yml +1 -27
- data/config/locales/sv.yml +296 -46
- data/config/locales/th-TH.yml +0 -10
- data/config/locales/tr-TR.yml +1 -44
- data/config/locales/uk.yml +0 -23
- data/config/locales/zh-CN.yml +0 -38
- data/config/locales/zh-TW.yml +1 -50
- data/config/routes.rb +13 -12
- data/decidim-admin.gemspec +1 -1
- data/lib/decidim/admin/engine.rb +2 -1
- data/lib/decidim/admin/import/creator.rb +2 -6
- data/lib/decidim/admin/import/readers/json.rb +1 -1
- data/lib/decidim/admin/menu.rb +9 -1
- data/lib/decidim/admin/search_form_builder.rb +1 -1
- data/lib/decidim/admin/test/destroy_admin_examples.rb +2 -2
- data/lib/decidim/admin/test/filterable_examples.rb +100 -9
- data/lib/decidim/admin/test/forms/attachment_collection_form_examples.rb +1 -1
- data/lib/decidim/admin/test/forms/attachment_form_examples.rb +1 -1
- data/lib/decidim/admin/test/invite_participatory_space_admins_shared_examples.rb +2 -4
- data/lib/decidim/admin/test/manage_component_permissions_examples.rb +5 -5
- data/lib/decidim/admin/test/manage_hide_content_examples.rb +0 -1
- data/lib/decidim/admin/test/manage_moderations_examples.rb +3 -3
- data/lib/decidim/admin/test/manage_resource_soft_deletion_examples.rb +113 -0
- data/lib/decidim/admin/test/manage_taxonomy_filters_examples.rb +127 -0
- data/lib/decidim/admin/test/taxonomy_filters_examples.rb +32 -0
- data/lib/decidim/admin/test.rb +3 -1
- data/lib/decidim/admin/version.rb +1 -1
- metadata +103 -29
- data/app/commands/decidim/admin/create_category.rb +0 -15
- data/app/commands/decidim/admin/destroy_category.rb +0 -15
- data/app/commands/decidim/admin/destroy_component.rb +0 -19
- data/app/commands/decidim/admin/update_category.rb +0 -11
- data/app/controllers/decidim/admin/categories_controller.rb +0 -98
- data/app/forms/decidim/admin/category_form.rb +0 -32
- data/app/helpers/decidim/admin/resource_scope_helper.rb +0 -52
- data/app/packs/src/decidim/admin/scope_picker_enabler.component.js +0 -12
- data/app/views/decidim/admin/categories/_form.html.erb +0 -18
- data/app/views/decidim/admin/categories/edit.html.erb +0 -19
- data/app/views/decidim/admin/categories/index.html.erb +0 -65
- data/app/views/decidim/admin/categories/new.html.erb +0 -19
- data/app/views/decidim/admin/share_tokens/_share_tokens.html.erb +0 -45
- data/lib/decidim/admin/test/commands/create_category_examples.rb +0 -74
- data/lib/decidim/admin/test/commands/destroy_category_examples.rb +0 -83
- data/lib/decidim/admin/test/commands/update_category_examples.rb +0 -76
- data/lib/decidim/admin/test/forms/category_form_examples.rb +0 -70
- data/lib/decidim/admin/test/manage_categories_examples.rb +0 -128
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48272c228554c612efad0837403c06e2955c0a5a71df4b1f57ef0b9d12d986c6
|
4
|
+
data.tar.gz: bfd117609106eb1d64f292a6b2e84cc524c7c9dab2bfa3dce05bc8ddfe44408a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9af4afad6391f293b4b3a1a8fd6b3bb262b1da9bda95b8cbadb0a43236475b0ba3a615315278d7da8e750dbe2a1d9a76e30f513cbb4993c580e83dd08b2123de
|
7
|
+
data.tar.gz: 57fad1f9f4ff5488fd0f5d35d2aff8105f7c7e37cb66dbf6da69a577e74567b11c037a88f82be3b4dc0834d505e2248ec8697ada0a42a02c15f3dbd956789ea6
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# Universal cell for rendering multi-select pickers
|
6
|
+
class MultiSelectPickerCell < Decidim::ViewModel
|
7
|
+
include ActionView::Helpers::FormOptionsHelper
|
8
|
+
|
9
|
+
def show
|
10
|
+
render :show
|
11
|
+
end
|
12
|
+
|
13
|
+
def cell_options_for_select
|
14
|
+
context[:options_for_select] || []
|
15
|
+
end
|
16
|
+
|
17
|
+
def selected_values
|
18
|
+
context[:selected_values] || []
|
19
|
+
end
|
20
|
+
|
21
|
+
def select_id
|
22
|
+
context[:select_id]
|
23
|
+
end
|
24
|
+
|
25
|
+
def field_name
|
26
|
+
context[:field_name]
|
27
|
+
end
|
28
|
+
|
29
|
+
def placeholder
|
30
|
+
context[:placeholder] || ""
|
31
|
+
end
|
32
|
+
|
33
|
+
def css_classes
|
34
|
+
context[:class] || ""
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
class BulkAction < Decidim::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
#
|
8
|
+
# current_user - the user that performs the action
|
9
|
+
# action - can be hide, unhide and unreport resources
|
10
|
+
# selected_moderations - all resources selected by current_user
|
11
|
+
def initialize(current_user, action, selected_moderations)
|
12
|
+
@current_user = current_user
|
13
|
+
@action = action
|
14
|
+
@selected_moderations = selected_moderations
|
15
|
+
@result = { ok: [], ko: [] }
|
16
|
+
end
|
17
|
+
|
18
|
+
# Executes the command. Broadcasts these events:
|
19
|
+
#
|
20
|
+
# - :ok when everything is valid, together with the resource.
|
21
|
+
# - :invalid if the resource is not reported
|
22
|
+
#
|
23
|
+
# Returns nothing.
|
24
|
+
def call
|
25
|
+
return broadcast(:invalid) if selected_moderations.blank?
|
26
|
+
|
27
|
+
process_reportables
|
28
|
+
create_action_log if selected_moderations.first.reportable
|
29
|
+
|
30
|
+
broadcast(:ok, **result)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
attr_reader :action, :selected_moderations, :current_user, :result, :with_admin_log
|
36
|
+
|
37
|
+
def create_action_log
|
38
|
+
action_log_type = "bulk_#{action}"
|
39
|
+
|
40
|
+
Decidim::ActionLogger.log(
|
41
|
+
action_log_type,
|
42
|
+
current_user,
|
43
|
+
selected_moderations.first,
|
44
|
+
nil,
|
45
|
+
extra: {
|
46
|
+
reported_content:,
|
47
|
+
reported_count: result[:ok].count
|
48
|
+
}
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def reported_content
|
53
|
+
@reported_content ||= result[:ok].group_by(&:decidim_reportable_type).to_h do |klass, moderations|
|
54
|
+
[
|
55
|
+
klass.split("::").last.downcase.pluralize,
|
56
|
+
moderations.to_h { |moderation| [moderation.reportable.id, moderation.title] }
|
57
|
+
]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def process_reportables
|
62
|
+
selected_moderations.each do |moderation|
|
63
|
+
next unless moderation
|
64
|
+
|
65
|
+
if moderation.respond_to?(:organization) && moderation.organization != current_user.organization
|
66
|
+
result[:ko] << moderation
|
67
|
+
next
|
68
|
+
end
|
69
|
+
command.call(moderation.reportable, current_user, with_admin_log: false) do
|
70
|
+
on(:ok) do
|
71
|
+
result[:ok] << moderation
|
72
|
+
end
|
73
|
+
on(:invalid) do
|
74
|
+
result[:ko] << moderation
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def command
|
81
|
+
case action
|
82
|
+
when "hide"
|
83
|
+
Admin::HideResource
|
84
|
+
when "unreport"
|
85
|
+
Admin::UnreportResource
|
86
|
+
when "unhide"
|
87
|
+
Admin::UnhideResource
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
class BulkBlockUsers < Decidim::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
def initialize(form)
|
8
|
+
@form = form
|
9
|
+
@result = { ok: [], ko: [] }
|
10
|
+
end
|
11
|
+
|
12
|
+
# Executes the command. Broadcasts these events:
|
13
|
+
#
|
14
|
+
# - :ok when everything is valid, together with the resource.
|
15
|
+
# - :invalid if the resource is not reported
|
16
|
+
#
|
17
|
+
# Returns nothing.
|
18
|
+
def call
|
19
|
+
return broadcast(:invalid) unless form.valid?
|
20
|
+
|
21
|
+
block_all_users!
|
22
|
+
create_action_log if first_blocked
|
23
|
+
|
24
|
+
broadcast(:ok, **result)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :form, :result, :first_blocked
|
30
|
+
|
31
|
+
def create_action_log
|
32
|
+
Decidim::ActionLogger.log(
|
33
|
+
"bulk_block",
|
34
|
+
form.current_user,
|
35
|
+
first_blocked,
|
36
|
+
nil,
|
37
|
+
extra: {
|
38
|
+
blocked:,
|
39
|
+
reportable_type: first_blocked.class.name,
|
40
|
+
current_justification: form.justification
|
41
|
+
}
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def blocked
|
46
|
+
@blocked ||= result[:ok].to_h { |user| [user.id, user.extended_data["user_name"]] }
|
47
|
+
end
|
48
|
+
|
49
|
+
def block_all_users!
|
50
|
+
form.users.each do |user|
|
51
|
+
transaction do
|
52
|
+
Decidim::UserModeration.find_or_create_by!(user:)
|
53
|
+
|
54
|
+
@current_blocking = UserBlock.create!(
|
55
|
+
justification: form.justification,
|
56
|
+
user:,
|
57
|
+
blocking_user: form.current_user
|
58
|
+
)
|
59
|
+
|
60
|
+
user.blocked = true
|
61
|
+
user.blocked_at = Time.current
|
62
|
+
user.block_id = @current_blocking.id
|
63
|
+
user.extended_data["user_name"] = user.name
|
64
|
+
user.name = "Blocked user"
|
65
|
+
user.save!
|
66
|
+
end
|
67
|
+
result[:ok] << user
|
68
|
+
@first_blocked ||= user
|
69
|
+
rescue ActiveRecord::RecordInvalid
|
70
|
+
result[:ko] << user
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
class BulkUnblockUsers < Decidim::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
def initialize(blocked_users, current_user)
|
8
|
+
@blocked_users = blocked_users
|
9
|
+
@current_user = current_user
|
10
|
+
@result = { ok: [], ko: [] }
|
11
|
+
end
|
12
|
+
|
13
|
+
# Executes the command. Broadcasts these events:
|
14
|
+
#
|
15
|
+
# - :ok when everything is valid, together with the resource.
|
16
|
+
# - :invalid if the resource is not reported
|
17
|
+
#
|
18
|
+
# Returns nothing.
|
19
|
+
def call
|
20
|
+
return broadcast(:invalid) if blocked_users.blank?
|
21
|
+
|
22
|
+
unblock_users!
|
23
|
+
create_action_log if first_unblocked
|
24
|
+
|
25
|
+
broadcast(:ok, **result)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :current_user, :blocked_users, :result, :first_unblocked
|
31
|
+
|
32
|
+
def create_action_log
|
33
|
+
Decidim::ActionLogger.log(
|
34
|
+
"bulk_unblock",
|
35
|
+
current_user,
|
36
|
+
first_unblocked,
|
37
|
+
nil,
|
38
|
+
extra: {
|
39
|
+
unblocked:,
|
40
|
+
reportable_type: first_unblocked.class.name
|
41
|
+
}
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def unblocked
|
46
|
+
@unblocked ||= result[:ok].to_h { |blocked_user| [blocked_user.id, blocked_user.extended_data["user_name"]] }
|
47
|
+
end
|
48
|
+
|
49
|
+
def unblock_users!
|
50
|
+
blocked_users.each do |blocked_user|
|
51
|
+
transaction do
|
52
|
+
blocked_user.blocked = false
|
53
|
+
blocked_user.blocked_at = nil
|
54
|
+
blocked_user.block_id = nil
|
55
|
+
blocked_user.name = blocked_user.extended_data["user_name"]
|
56
|
+
blocked_user.save!
|
57
|
+
end
|
58
|
+
result[:ok] << blocked_user
|
59
|
+
@first_unblocked ||= blocked_user
|
60
|
+
rescue ActiveRecord::RecordInvalid
|
61
|
+
result[:ko] << blocked_user
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
class BulkUnreportUsers < Decidim::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
#
|
8
|
+
# current_user - the user that performs the action
|
9
|
+
# reportables - all Decidim::Reportable selected by current_user
|
10
|
+
def initialize(current_user, reportables)
|
11
|
+
@current_user = current_user
|
12
|
+
@reportables = reportables
|
13
|
+
@result = { ok: [], ko: [] }
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid, together with the resource.
|
19
|
+
# - :invalid if the resource is not reported
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
return broadcast(:invalid) if reportables.blank?
|
24
|
+
|
25
|
+
bulk_unreport_users!
|
26
|
+
create_action_log if first_unreported
|
27
|
+
|
28
|
+
broadcast(:ok, **result)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :reportables, :current_user, :result, :first_unreported
|
34
|
+
|
35
|
+
def create_action_log
|
36
|
+
Decidim::ActionLogger.log(
|
37
|
+
"bulk_ignore",
|
38
|
+
current_user,
|
39
|
+
first_unreported,
|
40
|
+
nil,
|
41
|
+
extra: {
|
42
|
+
unreported:,
|
43
|
+
reportable_type: first_unreported.class.name
|
44
|
+
}
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def unreported
|
49
|
+
@unreported ||= result[:ok].to_h { |reportable| [reportable.id, reportable.name] }
|
50
|
+
end
|
51
|
+
|
52
|
+
def bulk_unreport_users!
|
53
|
+
reportables.each do |reportable|
|
54
|
+
next unless reportable
|
55
|
+
|
56
|
+
if reportable.respond_to?(:organization) && reportable.organization != current_user.organization
|
57
|
+
result[:ok] << reportable
|
58
|
+
next
|
59
|
+
end
|
60
|
+
reportable.user_moderation.destroy!
|
61
|
+
result[:ok] << reportable
|
62
|
+
@first_unreported ||= reportable
|
63
|
+
rescue ActiveRecord::RecordInvalid
|
64
|
+
result[:ko] << reportable
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -70,7 +70,7 @@ module Decidim
|
|
70
70
|
|
71
71
|
if form.images[image_name]
|
72
72
|
content_block.images_container.send("#{image_name}=", form.images[image_name])
|
73
|
-
elsif form.images["remove_#{image_name}"
|
73
|
+
elsif form.images[:"remove_#{image_name}"] == "1"
|
74
74
|
content_block.images_container.send("#{image_name}=", nil)
|
75
75
|
end
|
76
76
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic to create a share token.
|
6
|
+
# This command is called from the controller.
|
7
|
+
class CreateShareToken < Decidim::Commands::CreateResource
|
8
|
+
fetch_form_attributes :token, :expires_at, :registered_only, :organization, :user, :token_for
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def resource_class = Decidim::ShareToken
|
13
|
+
|
14
|
+
def extra_params
|
15
|
+
{
|
16
|
+
participatory_space: {
|
17
|
+
title: participatory_space&.title
|
18
|
+
},
|
19
|
+
resource: {
|
20
|
+
title: component&.name
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def participatory_space
|
26
|
+
return form.token_for if form.token_for.try(:manifest).is_a?(Decidim::ParticipatorySpaceManifest)
|
27
|
+
return current_participatory_space if respond_to?(:current_participatory_space)
|
28
|
+
|
29
|
+
component&.participatory_space
|
30
|
+
end
|
31
|
+
|
32
|
+
def component
|
33
|
+
return form.token_for if form.token_for.is_a?(Decidim::Component)
|
34
|
+
|
35
|
+
form.token_for.try(:component)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic to create a taxonomy.
|
6
|
+
# This command is called from the controller.
|
7
|
+
class CreateTaxonomy < Decidim::Commands::CreateResource
|
8
|
+
fetch_form_attributes :name, :organization, :parent_id
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def resource_class = Decidim::Taxonomy
|
13
|
+
|
14
|
+
def extra_params
|
15
|
+
{
|
16
|
+
extra: {
|
17
|
+
parent_name: form.try(:parent).try(:name)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic to create a new taxonomy filter in the
|
6
|
+
# system.
|
7
|
+
class CreateTaxonomyFilter < Decidim::Commands::CreateResource
|
8
|
+
fetch_form_attributes :root_taxonomy_id, :filter_items, :internal_name, :name, :participatory_space_manifests
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def resource_class = Decidim::TaxonomyFilter
|
13
|
+
|
14
|
+
def extra_params
|
15
|
+
{
|
16
|
+
extra: {
|
17
|
+
taxonomy_name: form.root_taxonomy.name,
|
18
|
+
filter_items_count: form.filter_items.count
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic to destroy a share token.
|
6
|
+
# This command is called from the controller.
|
7
|
+
class DestroyShareToken < Decidim::Commands::DestroyResource
|
8
|
+
delegate :participatory_space, :component, to: :resource
|
9
|
+
|
10
|
+
def extra_params
|
11
|
+
{
|
12
|
+
participatory_space: {
|
13
|
+
title: participatory_space&.title
|
14
|
+
},
|
15
|
+
resource: {
|
16
|
+
title: component&.name
|
17
|
+
}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic to destroy a taxonomy.
|
6
|
+
class DestroyTaxonomy < Decidim::Commands::DestroyResource
|
7
|
+
private
|
8
|
+
|
9
|
+
def extra_params
|
10
|
+
{
|
11
|
+
extra: {
|
12
|
+
parent_name: resource.parent.try(:name)
|
13
|
+
}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic to destroy a taxonomy in the
|
6
|
+
# system.
|
7
|
+
class DestroyTaxonomyFilter < Decidim::Commands::DestroyResource
|
8
|
+
private
|
9
|
+
|
10
|
+
def extra_params
|
11
|
+
{
|
12
|
+
extra: {
|
13
|
+
taxonomy_name: resource.root_taxonomy.name,
|
14
|
+
filter_items_count: resource.try(:filter_items_count)
|
15
|
+
}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# This command gets called when a component is marked as not visible (hidden) in the menu from the admin panel.
|
6
|
+
class HideMenuComponent < Decidim::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# component - The component to publish.
|
10
|
+
# current_user - the user performing the action
|
11
|
+
def initialize(component, current_user)
|
12
|
+
@component = component
|
13
|
+
@current_user = current_user
|
14
|
+
end
|
15
|
+
|
16
|
+
# Public: Publishes the Component.
|
17
|
+
#
|
18
|
+
# Broadcasts :ok if disabled visibility, :invalid otherwise.
|
19
|
+
def call
|
20
|
+
Decidim.traceability.perform_action!(
|
21
|
+
:menu_hidden,
|
22
|
+
component,
|
23
|
+
current_user,
|
24
|
+
visibility: "all"
|
25
|
+
) do
|
26
|
+
component.update!(visible: false)
|
27
|
+
end
|
28
|
+
|
29
|
+
broadcast(:ok)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :component, :current_user
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -8,9 +8,11 @@ module Decidim
|
|
8
8
|
#
|
9
9
|
# reportable - A Decidim::Reportable
|
10
10
|
# current_user - the user that performs the action
|
11
|
-
|
11
|
+
# with_admin_log Boolean - determines whether to log the action of hiding a resource in the admin log
|
12
|
+
def initialize(reportable, current_user, with_admin_log: true)
|
12
13
|
@reportable = reportable
|
13
14
|
@current_user = current_user
|
15
|
+
@with_admin_log = with_admin_log
|
14
16
|
end
|
15
17
|
|
16
18
|
# Executes the command. Broadcasts these events:
|
@@ -24,7 +26,7 @@ module Decidim
|
|
24
26
|
|
25
27
|
with_events do
|
26
28
|
tool = Decidim::ModerationTools.new(@reportable, @current_user)
|
27
|
-
tool.hide!
|
29
|
+
@with_admin_log ? tool.hide_with_admin_log! : tool.hide!
|
28
30
|
tool.send_notification_to_author
|
29
31
|
end
|
30
32
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
class PublishAllParticipatorySpacePrivateUsers < Decidim::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
#
|
8
|
+
# participatory_space - the participatory space
|
9
|
+
# current_user - the current user
|
10
|
+
def initialize(participatory_space, current_user)
|
11
|
+
@participatory_space = participatory_space
|
12
|
+
@current_user = current_user
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Broadcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid.
|
18
|
+
# - :invalid if the form was not valid and we could not proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
publish_all
|
23
|
+
create_action_log
|
24
|
+
broadcast(:ok)
|
25
|
+
rescue ActiveRecord::RecordInvalid
|
26
|
+
broadcast(:invalid)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :participatory_space, :current_user
|
32
|
+
|
33
|
+
def publish_all
|
34
|
+
# rubocop:disable Rails/SkipsModelValidations
|
35
|
+
# Using update_all for performance reasons
|
36
|
+
participatory_space.participatory_space_private_users.update_all(published: true)
|
37
|
+
# rubocop:enable Rails/SkipsModelValidations
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_action_log
|
41
|
+
Decidim.traceability.perform_action!(
|
42
|
+
"publish_all_members",
|
43
|
+
participatory_space,
|
44
|
+
current_user,
|
45
|
+
private_users_ids: participatory_space.participatory_space_private_users.pluck(:id)
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|