decidim-admin 0.29.1 → 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/block_user.rb +1 -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 +43 -1
- 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/conflicts_controller.rb +1 -1
- data/app/controllers/decidim/admin/global_moderations_controller.rb +4 -0
- data/app/controllers/decidim/admin/impersonations_controller.rb +1 -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 -6
- 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/help_section_form.rb +1 -1
- data/app/forms/decidim/admin/impersonate_user_form.rb +5 -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/organization_appearance_form.rb +2 -2
- data/app/forms/decidim/admin/organization_form.rb +2 -2
- 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/static_page_form.rb +1 -1
- 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/forms/decidim/admin/transfer_user_form.rb +15 -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 -73
- 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/_moderations.scss +8 -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 +59 -19
- 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/conflicts/edit.html.erb +21 -11
- 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 +15 -7
- 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/newsletter_templates/index.html.erb +0 -1
- 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/shared/landing_page_content_blocks/edit.html.erb +1 -1
- 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 +91 -36
- data/config/locales/bg.yml +48 -51
- data/config/locales/bn-BD.yml +1 -0
- data/config/locales/bs-BA.yml +499 -0
- 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 +298 -48
- data/config/locales/es-PY.yml +298 -48
- data/config/locales/es.yml +298 -48
- data/config/locales/eu.yml +433 -171
- data/config/locales/fi-plain.yml +298 -48
- data/config/locales/fi.yml +315 -65
- 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 -20
- data/config/locales/is-IS.yml +0 -18
- data/config/locales/it.yml +1 -46
- data/config/locales/ja.yml +303 -55
- data/config/locales/kaa.yml +0 -10
- 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 -27
- 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 +30 -46
- data/config/locales/ro-RO.yml +35 -50
- data/config/locales/ru.yml +1 -22
- data/config/locales/sk.yml +1 -27
- data/config/locales/sl.yml +0 -7
- data/config/locales/sq-AL.yml +0 -25
- data/config/locales/sr-CS.yml +1 -27
- data/config/locales/sv.yml +297 -47
- data/config/locales/tr-TR.yml +1 -44
- data/config/locales/uk.yml +0 -20
- data/config/locales/zh-CN.yml +0 -44
- data/config/locales/zh-TW.yml +1 -50
- data/config/routes.rb +14 -13
- data/decidim-admin.gemspec +2 -2
- data/lib/decidim/admin/engine.rb +3 -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 +106 -30
- 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
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command that reorders a collection of components
|
6
|
+
class ReorderComponents < Decidim::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# components - the components to reorder
|
10
|
+
# order - an Array holding the order of IDs of the components
|
11
|
+
def initialize(components, order)
|
12
|
+
@components = components
|
13
|
+
@order = order
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if the data was not valid and we could not proceed.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
return broadcast(:invalid) unless valid_params?
|
24
|
+
|
25
|
+
reorder_components
|
26
|
+
broadcast(:ok)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :components, :order
|
32
|
+
|
33
|
+
def valid_params?
|
34
|
+
order.present? && components.present?
|
35
|
+
end
|
36
|
+
|
37
|
+
def reorder_components
|
38
|
+
transaction do
|
39
|
+
order.each_with_index do |id, index|
|
40
|
+
component = components.find_by(id:)
|
41
|
+
component.update!(weight: index + 1) if component.present?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command that reorders a collection of taxonomies
|
6
|
+
# the ones that might be missing.
|
7
|
+
class ReorderTaxonomies < Decidim::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# organization - the Organization where the content blocks reside
|
11
|
+
# order - an Array holding the order of IDs of published content blocks.
|
12
|
+
def initialize(organization, order, offset = 0)
|
13
|
+
@organization = organization
|
14
|
+
@order = order
|
15
|
+
@offset = offset
|
16
|
+
end
|
17
|
+
|
18
|
+
# Executes the command. Broadcasts these events:
|
19
|
+
#
|
20
|
+
# - :ok when everything is valid.
|
21
|
+
# - :invalid if the data was not valid and we could not proceed.
|
22
|
+
#
|
23
|
+
# Returns nothing.
|
24
|
+
def call
|
25
|
+
return broadcast(:invalid) if order.blank?
|
26
|
+
return broadcast(:invalid) if collection.empty?
|
27
|
+
|
28
|
+
reorder_steps
|
29
|
+
broadcast(:ok)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :organization, :offset
|
35
|
+
|
36
|
+
def reorder_steps
|
37
|
+
transaction do
|
38
|
+
reset_weights
|
39
|
+
collection.reload
|
40
|
+
set_new_weights
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def reset_weights
|
45
|
+
# rubocop:disable Rails/SkipsModelValidations
|
46
|
+
collection.where.not(weight: nil).where(id: order).update_all(weight: nil)
|
47
|
+
# rubocop:enable Rails/SkipsModelValidations
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_new_weights
|
51
|
+
data = order.each_with_index.inject({}) do |hash, (id, index)|
|
52
|
+
hash.update(id => index + 1 + offset)
|
53
|
+
end
|
54
|
+
|
55
|
+
data.each do |id, weight|
|
56
|
+
item = collection.find_by(id:)
|
57
|
+
item.update!(weight:) if item.present?
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def order
|
62
|
+
return nil unless @order.is_a?(Array) && @order.present?
|
63
|
+
|
64
|
+
@order
|
65
|
+
end
|
66
|
+
|
67
|
+
def collection
|
68
|
+
@collection ||= Decidim::Taxonomy.where(organization:, parent_id: first_item.parent_id)
|
69
|
+
end
|
70
|
+
|
71
|
+
def first_item
|
72
|
+
@first_item ||= Decidim::Taxonomy.where(organization:).find(order.first)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
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 unhide 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:
|
@@ -22,7 +24,7 @@ module Decidim
|
|
22
24
|
def call
|
23
25
|
return broadcast(:invalid) unless unhideable?
|
24
26
|
|
25
|
-
unhide!
|
27
|
+
@with_admin_log ? unhide_with_admin_log! : unhide!
|
26
28
|
broadcast(:ok, @reportable)
|
27
29
|
end
|
28
30
|
|
@@ -32,7 +34,7 @@ module Decidim
|
|
32
34
|
@reportable.hidden? && @reportable.reported?
|
33
35
|
end
|
34
36
|
|
35
|
-
def
|
37
|
+
def unhide_with_admin_log!
|
36
38
|
Decidim.traceability.perform_action!(
|
37
39
|
"unhide",
|
38
40
|
@reportable.moderation,
|
@@ -41,6 +43,12 @@ module Decidim
|
|
41
43
|
reportable_type: @reportable.class.name
|
42
44
|
}
|
43
45
|
) do
|
46
|
+
unhide!
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def unhide!
|
51
|
+
Decidim.traceability.perform_action_without_log!(@current_user) do
|
44
52
|
@reportable.moderation.update!(hidden_at: nil)
|
45
53
|
end
|
46
54
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
class UnpublishAllParticipatorySpacePrivateUsers < 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
|
+
unpublish_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 unpublish_all
|
34
|
+
# rubocop:disable Rails/SkipsModelValidations
|
35
|
+
# Using update_all for performance reasons
|
36
|
+
participatory_space.participatory_space_private_users.update_all(published: false)
|
37
|
+
# rubocop:enable Rails/SkipsModelValidations
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_action_log
|
41
|
+
Decidim.traceability.perform_action!(
|
42
|
+
"unpublish_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
|
@@ -8,9 +8,11 @@ module Decidim
|
|
8
8
|
#
|
9
9
|
# reportable - A Decidim::Reportable
|
10
10
|
# current_user - the user performing the action
|
11
|
-
|
11
|
+
# with_admin_log Boolean - determines whether to log the action of unreport 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:
|
@@ -22,13 +24,13 @@ module Decidim
|
|
22
24
|
def call
|
23
25
|
return broadcast(:invalid) unless @reportable.reported?
|
24
26
|
|
25
|
-
unreport!
|
27
|
+
@with_admin_log ? unreport_with_admin_log! : unreport!
|
26
28
|
broadcast(:ok, @reportable)
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
30
32
|
|
31
|
-
def
|
33
|
+
def unreport_with_admin_log!
|
32
34
|
Decidim.traceability.perform_action!(
|
33
35
|
"unreport",
|
34
36
|
@reportable.moderation,
|
@@ -37,6 +39,12 @@ module Decidim
|
|
37
39
|
reportable_type: @reportable.class.name
|
38
40
|
}
|
39
41
|
) do
|
42
|
+
unreport!
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def unreport!
|
47
|
+
Decidim.traceability.perform_action_without_log!(@current_user) do
|
40
48
|
@reportable.moderation.destroy!
|
41
49
|
end
|
42
50
|
end
|
@@ -25,7 +25,10 @@ module Decidim
|
|
25
25
|
|
26
26
|
Decidim.traceability.perform_action!("update_permissions", @component, current_user) do
|
27
27
|
transaction do
|
28
|
+
permissions_with_changes_in_ephemeral_handlers
|
28
29
|
update_permissions
|
30
|
+
raise ActiveRecord::Rollback unless clean_ephemeral_authorizations
|
31
|
+
|
29
32
|
run_hooks
|
30
33
|
end
|
31
34
|
end
|
@@ -44,7 +47,36 @@ module Decidim
|
|
44
47
|
end
|
45
48
|
|
46
49
|
def update_permissions
|
47
|
-
|
50
|
+
if resource
|
51
|
+
resource_permissions.update!(permissions: permissions_with_differences(component.permissions, selected_permissions))
|
52
|
+
else
|
53
|
+
component.update!(permissions: selected_permissions)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def clean_ephemeral_authorizations
|
58
|
+
handler_names = permissions_with_changes_in_ephemeral_handlers.values.map { |config| config["authorization_handlers"].keys }.flatten.uniq
|
59
|
+
ephemeral_handler_names = handler_names.select { |handler_name| Decidim::Verifications::Adapter.from_element(handler_name).ephemeral? }
|
60
|
+
|
61
|
+
ephemeral_handler_names.each do |name|
|
62
|
+
Decidim::Verifications::RevokeByNameAuthorizations.call(current_user.organization, name, current_user) do
|
63
|
+
on(:ok) do
|
64
|
+
return true
|
65
|
+
end
|
66
|
+
|
67
|
+
on(:invalid) do
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def run_hooks
|
75
|
+
component.manifest.run_hooks(:permission_update, component:, resource:)
|
76
|
+
end
|
77
|
+
|
78
|
+
def selected_permissions
|
79
|
+
@selected_permissions ||= configured_permissions.inject({}) do |result, (key, value)|
|
48
80
|
handlers_content = {}
|
49
81
|
|
50
82
|
selected_handlers(value).each do |handler_key|
|
@@ -58,27 +90,35 @@ module Decidim
|
|
58
90
|
|
59
91
|
result.update(key => selected_handlers(value).any? ? serialized : {})
|
60
92
|
end
|
61
|
-
|
62
|
-
if resource
|
63
|
-
resource_permissions.update!(permissions: different_from_component_permissions(permissions))
|
64
|
-
else
|
65
|
-
component.update!(permissions:)
|
66
|
-
end
|
67
93
|
end
|
68
94
|
|
69
|
-
def
|
70
|
-
|
95
|
+
def permissions_with_changes_in_ephemeral_handlers
|
96
|
+
@permissions_with_changes_in_ephemeral_handlers ||= begin
|
97
|
+
old_permissions = ((resource.present? ? resource_permissions.permissions : component.permissions) || {}).deep_stringify_keys
|
98
|
+
|
99
|
+
selected_permissions.deep_stringify_keys.reject do |action, config|
|
100
|
+
old_config = old_permissions[action] || { "authorization_handlers" => {} }
|
101
|
+
Hashdiff.diff(config, old_config).none? do |_, key, _|
|
102
|
+
handler_name = key.split(".")[1]
|
103
|
+
next if handler_name.blank?
|
104
|
+
|
105
|
+
Decidim::Verifications::Adapter.from_element(handler_name).ephemeral? && config["authorization_handlers"].keys.include?(handler_name)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
71
109
|
end
|
72
110
|
|
73
111
|
def resource_permissions
|
74
112
|
@resource_permissions ||= resource.resource_permission || resource.build_resource_permission
|
75
113
|
end
|
76
114
|
|
77
|
-
def
|
78
|
-
return
|
115
|
+
def permissions_with_differences(old_permissions, new_permissions)
|
116
|
+
return new_permissions unless old_permissions
|
117
|
+
|
118
|
+
old_permissions = old_permissions.deep_stringify_keys
|
79
119
|
|
80
|
-
|
81
|
-
Hashdiff.diff(
|
120
|
+
new_permissions.deep_stringify_keys.reject do |action, config|
|
121
|
+
Hashdiff.diff(old_permissions[action], config).empty?
|
82
122
|
end
|
83
123
|
end
|
84
124
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic when updating a participatory space
|
6
|
+
# private user.
|
7
|
+
class UpdateParticipatorySpacePrivateUser < Decidim::Commands::UpdateResource
|
8
|
+
fetch_form_attributes :role, :published
|
9
|
+
end
|
10
|
+
end
|
11
|
+
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 update a share token.
|
6
|
+
# This command is called from the controller.
|
7
|
+
class UpdateShareToken < Decidim::Commands::UpdateResource
|
8
|
+
fetch_form_attributes :expires_at, :registered_only
|
9
|
+
|
10
|
+
delegate :participatory_space, :component, to: :resource
|
11
|
+
|
12
|
+
def extra_params
|
13
|
+
{
|
14
|
+
participatory_space: {
|
15
|
+
title: participatory_space&.title
|
16
|
+
},
|
17
|
+
resource: {
|
18
|
+
title: component&.name
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command to update a taxonomy.
|
6
|
+
class UpdateTaxonomy < Decidim::Commands::UpdateResource
|
7
|
+
fetch_form_attributes :name, :parent_id
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
def extra_params
|
12
|
+
{
|
13
|
+
extra: {
|
14
|
+
parent_name: resource.parent.try(:name)
|
15
|
+
}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
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 UpdateTaxonomyFilter < Decidim::Commands::UpdateResource
|
8
|
+
fetch_form_attributes :filter_items, :internal_name, :name, :participatory_space_manifests
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def resource_class = Decidim::TaxonomyFilter
|
13
|
+
|
14
|
+
def run_before_hooks
|
15
|
+
resource.filter_items.destroy_all
|
16
|
+
end
|
17
|
+
|
18
|
+
def extra_params
|
19
|
+
{
|
20
|
+
extra: {
|
21
|
+
taxonomy_name: resource.root_taxonomy.name,
|
22
|
+
filter_items_count: form.filter_items.count
|
23
|
+
}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
module ComponentTaxonomiesHelper
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
helper_method :current_component_taxonomy_filters
|
10
|
+
end
|
11
|
+
|
12
|
+
def current_component_taxonomy_filters
|
13
|
+
@current_component_taxonomy_filters ||= TaxonomyFilter.for(current_organization)
|
14
|
+
.for_manifest(current_participatory_space.manifest.name)
|
15
|
+
.where(id: current_component.settings.taxonomy_filters)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -30,8 +30,9 @@ module Decidim
|
|
30
30
|
:search_field_predicate,
|
31
31
|
:adjacent_items
|
32
32
|
|
33
|
-
delegate :
|
34
|
-
delegate :
|
33
|
+
delegate :taxonomies, to: :current_organization
|
34
|
+
delegate :available_root_taxonomies, to: :current_component
|
35
|
+
delegate :available_taxonomy_ids, to: :current_component
|
35
36
|
|
36
37
|
def query
|
37
38
|
@query ||= base_query.ransack(ransack_params, search_context: :admin, auth_object: current_user)
|
@@ -188,36 +189,32 @@ module Decidim
|
|
188
189
|
query.klass.model_name.human(count: 2)
|
189
190
|
end
|
190
191
|
|
191
|
-
|
192
|
-
|
193
|
-
categories.each_with_object({}) do |category, hash|
|
194
|
-
hash[category.id] = category.subcategories.any? ? category_ids_hash(category.subcategories) : nil
|
195
|
-
end
|
192
|
+
def taxonomy_order_or_search?
|
193
|
+
ransack_params[:taxonomies_part_of_contains].present? || ransack_params[:s]&.include?("taxonomies_name")
|
196
194
|
end
|
197
195
|
|
198
|
-
# A tree of
|
199
|
-
def
|
200
|
-
|
201
|
-
|
196
|
+
# A tree of Taxonomy IDs. Leaves are `nil`.
|
197
|
+
def taxonomy_ids_hash(taxonomies)
|
198
|
+
filtered_taxonomies = taxonomies.roots.or(taxonomies.where(id: available_taxonomy_ids))
|
199
|
+
return nil if filtered_taxonomies.blank?
|
200
|
+
|
201
|
+
filtered_taxonomies.each_with_object({}) do |taxonomy, hash|
|
202
|
+
hash[taxonomy.id] = taxonomy_ids_hash(taxonomy.children)
|
202
203
|
end
|
203
204
|
end
|
204
205
|
|
205
206
|
# Array<Symbol> of filters that implement a method to find translations.
|
206
207
|
# Useful when translations cannot be found in i18n or come from a Model.
|
207
208
|
def dynamically_translated_filters
|
208
|
-
[:
|
209
|
+
[:taxonomies_part_of_contains]
|
209
210
|
end
|
210
211
|
|
211
212
|
def find_dynamic_translation(filter, value)
|
212
213
|
send("translated_#{filter}", value) if filter.in?(dynamically_translated_filters)
|
213
214
|
end
|
214
215
|
|
215
|
-
def
|
216
|
-
translated_attribute(
|
217
|
-
end
|
218
|
-
|
219
|
-
def translated_category_id_eq(id)
|
220
|
-
translated_attribute(categories.find_by(id:).name)
|
216
|
+
def translated_taxonomies_part_of_contains(id)
|
217
|
+
translated_attribute(taxonomies.find_by(id:).name)
|
221
218
|
end
|
222
219
|
end
|
223
220
|
end
|