decidim-admin 0.28.4 → 0.29.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/app/cells/decidim/admin/content_block_cell.rb +0 -1
- data/app/cells/decidim/admin/results_per_page/show.erb +2 -2
- data/app/cells/decidim/admin/results_per_page_cell.rb +0 -2
- data/app/commands/decidim/admin/create_area.rb +4 -32
- data/app/commands/decidim/admin/create_area_type.rb +4 -33
- data/app/commands/decidim/admin/create_attachment.rb +5 -4
- data/app/commands/decidim/admin/create_attachment_collection.rb +3 -3
- data/app/commands/decidim/admin/create_category.rb +4 -37
- data/app/commands/decidim/admin/create_component.rb +7 -40
- data/app/commands/decidim/admin/create_newsletter.rb +11 -29
- data/app/commands/decidim/admin/create_participatory_space_private_user.rb +4 -4
- data/app/commands/decidim/admin/create_scope.rb +15 -32
- data/app/commands/decidim/admin/create_scope_type.rb +3 -32
- data/app/commands/decidim/admin/create_static_page.rb +6 -47
- data/app/commands/decidim/admin/create_static_page_topic.rb +4 -26
- data/app/commands/decidim/admin/deliver_newsletter.rb +4 -5
- data/app/commands/decidim/admin/destroy_area.rb +2 -25
- data/app/commands/decidim/admin/destroy_category.rb +4 -29
- data/app/commands/decidim/admin/destroy_component.rb +5 -43
- data/app/commands/decidim/admin/destroy_newsletter.rb +2 -30
- data/app/commands/decidim/admin/destroy_participatory_space_private_user.rb +5 -32
- data/app/commands/decidim/admin/destroy_scope.rb +6 -33
- data/app/commands/decidim/admin/officialize_user.rb +1 -1
- data/app/commands/decidim/admin/participatory_space/create_admin.rb +4 -4
- data/app/commands/decidim/admin/process_participatory_space_private_user_import_csv.rb +5 -4
- data/app/commands/decidim/admin/promote_managed_user.rb +4 -5
- data/app/commands/decidim/admin/unofficialize_user.rb +1 -1
- data/app/commands/decidim/admin/update_area.rb +2 -41
- data/app/commands/decidim/admin/update_area_type.rb +2 -42
- data/app/commands/decidim/admin/update_attachment.rb +10 -7
- data/app/commands/decidim/admin/update_attachment_collection.rb +3 -3
- data/app/commands/decidim/admin/update_category.rb +2 -45
- data/app/commands/decidim/admin/update_component.rb +4 -5
- data/app/commands/decidim/admin/update_component_permissions.rb +3 -3
- data/app/commands/decidim/admin/{update_external_domain_whitelist.rb → update_external_domain_allowlist.rb} +6 -5
- data/app/commands/decidim/admin/update_help_sections.rb +6 -3
- data/app/commands/decidim/admin/update_newsletter.rb +8 -8
- data/app/commands/decidim/admin/update_organization.rb +9 -53
- data/app/commands/decidim/admin/update_organization_appearance.rb +10 -81
- data/app/commands/decidim/admin/update_scope.rb +7 -40
- data/app/commands/decidim/admin/update_scope_type.rb +2 -42
- data/app/commands/decidim/admin/update_static_page.rb +5 -46
- data/app/commands/decidim/admin/update_static_page_topic.rb +2 -43
- data/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
- data/app/controllers/concerns/decidim/admin/content_blocks/landing_page.rb +2 -2
- data/app/controllers/concerns/decidim/admin/filterable.rb +79 -4
- data/app/controllers/concerns/decidim/admin/global_moderation_context.rb +1 -1
- data/app/controllers/concerns/decidim/admin/needs_admin_tos_accepted.rb +0 -7
- data/app/controllers/concerns/decidim/admin/paginable.rb +20 -0
- data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +1 -1
- data/app/controllers/decidim/admin/application_controller.rb +2 -1
- data/app/controllers/decidim/admin/area_types_controller.rb +8 -9
- data/app/controllers/decidim/admin/areas_controller.rb +1 -1
- data/app/controllers/decidim/admin/authorization_workflows_controller.rb +1 -1
- data/app/controllers/decidim/admin/categories_controller.rb +2 -2
- data/app/controllers/decidim/admin/component_permissions_controller.rb +1 -1
- data/app/controllers/decidim/admin/components_controller.rb +2 -2
- data/app/controllers/decidim/admin/concerns/has_attachment_collections.rb +2 -2
- data/app/controllers/decidim/admin/concerns/has_attachments.rb +2 -2
- data/app/controllers/decidim/admin/concerns/has_private_users.rb +1 -1
- data/app/controllers/decidim/admin/concerns/has_private_users_csv_import.rb +1 -1
- data/app/controllers/decidim/admin/conflicts_controller.rb +5 -13
- data/app/controllers/decidim/admin/help_sections_controller.rb +1 -1
- data/app/controllers/decidim/admin/managed_users/promotions_controller.rb +1 -1
- data/app/controllers/decidim/admin/moderations/reports_controller.rb +4 -4
- data/app/controllers/decidim/admin/moderations_controller.rb +7 -7
- data/app/controllers/decidim/admin/newsletter_templates_controller.rb +1 -1
- data/app/controllers/decidim/admin/newsletters_controller.rb +5 -5
- data/app/controllers/decidim/admin/organization_appearance_controller.rb +1 -1
- data/app/controllers/decidim/admin/organization_controller.rb +1 -1
- data/app/controllers/decidim/admin/{organization_external_domain_whitelist_controller.rb → organization_external_domain_allowlist_controller.rb} +7 -7
- data/app/controllers/decidim/admin/scope_types_controller.rb +7 -8
- data/app/controllers/decidim/admin/scopes_controller.rb +1 -1
- data/app/controllers/decidim/admin/share_tokens_controller.rb +1 -1
- data/app/controllers/decidim/admin/static_page_topics_controller.rb +2 -2
- data/app/controllers/decidim/admin/static_pages_controller.rb +2 -2
- data/app/forms/decidim/admin/attachment_form.rb +7 -1
- data/app/forms/decidim/admin/organization_appearance_form.rb +0 -3
- data/app/forms/decidim/admin/{organization_external_domain_whitelist_form.rb → organization_external_domain_allowlist_form.rb} +3 -3
- data/app/forms/decidim/admin/organization_form.rb +2 -2
- data/app/forms/decidim/admin/static_page_form.rb +0 -1
- data/app/helpers/decidim/admin/application_helper.rb +0 -13
- data/app/helpers/decidim/admin/filterable_helper.rb +19 -3
- data/app/helpers/decidim/admin/moderations/reports_helper.rb +3 -1
- data/app/helpers/decidim/admin/newsletters_helper.rb +3 -3
- data/app/helpers/decidim/admin/paginable/per_page_helper.rb +22 -0
- data/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb +2 -2
- data/app/packs/entrypoints/decidim_admin.js +4 -1
- data/app/packs/src/decidim/admin/application.js +19 -15
- data/app/packs/src/decidim/admin/css_preview.js +39 -0
- data/app/packs/src/decidim/admin/form.js +18 -1
- data/app/packs/src/decidim/admin/participatory_space_search.js +1 -1
- data/app/packs/src/decidim/admin/proposal_infinite_edit.js +2 -2
- data/app/packs/src/decidim/admin/sync_radio_buttons.js +27 -0
- data/app/packs/src/decidim/admin/text_copy.js +19 -0
- data/app/packs/stylesheets/decidim/admin/_cards.scss +1 -1
- data/app/packs/stylesheets/decidim/admin/_datepicker.scss +62 -0
- data/app/packs/stylesheets/decidim/admin/_item_edit.scss +1 -1
- data/app/packs/stylesheets/decidim/admin/_item_show.scss +8 -0
- data/app/packs/stylesheets/decidim/admin/_proposal_status.scss +5 -0
- data/app/packs/stylesheets/decidim/admin/application.scss +2 -0
- data/app/permissions/decidim/admin/permissions.rb +2 -2
- data/app/queries/decidim/admin/user_filter.rb +4 -4
- data/app/queries/decidim/admin/user_groups_evaluation.rb +1 -1
- data/app/views/decidim/admin/attachment_collections/index.html.erb +1 -1
- data/app/views/decidim/admin/attachments/_form.html.erb +21 -2
- data/app/views/decidim/admin/attachments/index.html.erb +2 -2
- data/app/views/decidim/admin/authorization_workflows/index.html.erb +26 -8
- data/app/views/decidim/admin/block_user/new.html.erb +1 -1
- data/app/views/decidim/admin/categories/index.html.erb +2 -2
- data/app/views/decidim/admin/components/_form.html.erb +1 -1
- data/app/views/decidim/admin/components/index.html.erb +1 -5
- data/app/views/decidim/admin/conflicts/index.html.erb +6 -29
- data/app/views/decidim/admin/dashboard/_pending_moderations.html.erb +1 -1
- data/app/views/decidim/admin/dashboard/show.html.erb +1 -1
- data/app/views/decidim/admin/exports/_dropdown.html.erb +6 -6
- data/app/views/decidim/admin/impersonatable_users/index.html.erb +3 -3
- data/app/views/decidim/admin/imports/_dropdown.html.erb +5 -7
- data/app/views/decidim/admin/imports/new.html.erb +6 -7
- data/app/views/decidim/admin/logs/_filters.html.erb +3 -3
- data/app/views/decidim/admin/managed_users/promotions/new.html.erb +1 -1
- data/app/views/decidim/admin/moderated_users/index.html.erb +2 -2
- data/app/views/decidim/admin/moderations/index.html.erb +5 -5
- data/app/views/decidim/admin/moderations/reports/index.html.erb +6 -6
- data/app/views/decidim/admin/moderations/reports/show.html.erb +4 -4
- data/app/views/decidim/admin/newsletter_templates/index.html.erb +2 -2
- data/app/views/decidim/admin/newsletter_templates/show.html.erb +7 -7
- data/app/views/decidim/admin/newsletters/index.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +6 -7
- data/app/views/decidim/admin/newsletters/show.html.erb +1 -1
- data/app/views/decidim/admin/organization/_form.html.erb +3 -3
- data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +0 -3
- data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +5 -5
- data/app/views/decidim/admin/organization_appearance/form/_minimap.html.erb +3 -3
- data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/_external_domain.html.erb +4 -4
- data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/_form.html.erb +2 -2
- data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/edit.html.erb +2 -2
- data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +1 -1
- data/app/views/decidim/admin/participatory_space_private_users_csv_imports/new.html.erb +1 -1
- data/app/views/decidim/admin/share_tokens/_share_tokens.html.erb +1 -1
- data/app/views/decidim/admin/shared/_adjacent_navigation.html.erb +30 -0
- data/app/views/decidim/admin/shared/_admin_confirm_modal.html.erb +7 -7
- data/app/views/decidim/admin/shared/_filters.html.erb +1 -1
- data/app/views/decidim/admin/shared/_gallery.html.erb +1 -1
- data/app/views/decidim/admin/shared/landing_page/_content_blocks.html.erb +2 -2
- data/app/views/decidim/admin/static_page_topics/index.html.erb +1 -1
- data/app/views/decidim/admin/static_pages/_form.html.erb +0 -4
- data/app/views/decidim/admin/users_statistics/_users_count.html.erb +2 -2
- data/app/views/layouts/decidim/admin/_admin_timeout_modal.html.erb +2 -2
- data/app/views/layouts/decidim/admin/_application.html.erb +4 -4
- data/app/views/layouts/decidim/admin/_callouts_full.html.erb +1 -1
- data/app/views/layouts/decidim/admin/_js_configuration.html.erb +3 -1
- data/app/views/layouts/decidim/admin/_title_bar.html.erb +2 -2
- data/app/views/layouts/decidim/admin/_title_bar_responsive.html.erb +2 -2
- data/config/locales/ar.yml +0 -7
- data/config/locales/bg.yml +15 -12
- data/config/locales/ca.yml +18 -15
- data/config/locales/cs.yml +15 -17
- data/config/locales/de.yml +15 -12
- data/config/locales/el.yml +0 -12
- data/config/locales/en.yml +16 -13
- data/config/locales/es-MX.yml +16 -13
- data/config/locales/es-PY.yml +16 -13
- data/config/locales/es.yml +18 -15
- data/config/locales/eu.yml +16 -13
- data/config/locales/fi-plain.yml +15 -12
- data/config/locales/fi.yml +19 -16
- data/config/locales/fr-CA.yml +14 -11
- data/config/locales/fr.yml +13 -10
- data/config/locales/ga-IE.yml +0 -3
- data/config/locales/gl.yml +0 -5
- data/config/locales/hu.yml +9 -10
- data/config/locales/id-ID.yml +0 -3
- data/config/locales/is-IS.yml +0 -3
- data/config/locales/it.yml +0 -8
- data/config/locales/ja.yml +18 -15
- data/config/locales/kaa.yml +0 -3
- data/config/locales/ko.yml +0 -6
- data/config/locales/lb.yml +0 -8
- data/config/locales/lt.yml +0 -13
- data/config/locales/lv.yml +0 -3
- data/config/locales/nl.yml +0 -8
- data/config/locales/no.yml +0 -8
- data/config/locales/pl.yml +14 -9
- data/config/locales/pt-BR.yml +8 -13
- data/config/locales/pt.yml +0 -8
- data/config/locales/ro-RO.yml +3 -21
- data/config/locales/ru.yml +0 -3
- data/config/locales/sk.yml +0 -3
- data/config/locales/sq-AL.yml +0 -3
- data/config/locales/sr-CS.yml +0 -3
- data/config/locales/sv.yml +207 -355
- data/config/locales/th-TH.yml +0 -3
- data/config/locales/tr-TR.yml +0 -5
- data/config/locales/uk.yml +0 -3
- data/config/locales/zh-CN.yml +0 -3
- data/config/locales/zh-TW.yml +0 -12
- data/config/routes.rb +1 -1
- data/decidim-admin.gemspec +1 -1
- data/lib/decidim/admin/import/creator.rb +1 -1
- data/lib/decidim/admin/import/importer_factory.rb +2 -2
- data/lib/decidim/admin/menu.rb +4 -4
- data/lib/decidim/admin/test/commands/create_attachment_collection_examples.rb +3 -2
- data/lib/decidim/admin/test/commands/create_category_examples.rb +4 -2
- data/lib/decidim/admin/test/commands/update_attachment_collection_examples.rb +3 -2
- data/lib/decidim/admin/test/commands/update_category_examples.rb +3 -2
- data/lib/decidim/admin/test/filterable_examples.rb +5 -3
- data/lib/decidim/admin/test/filters_participatory_space_user_roles_examples.rb +5 -5
- data/lib/decidim/admin/test/invite_participatory_space_admins_shared_examples.rb +1 -1
- data/lib/decidim/admin/test/invite_participatory_space_users_shared_context.rb +0 -1
- data/lib/decidim/admin/test/manage_attachment_collections_examples.rb +12 -12
- data/lib/decidim/admin/test/manage_attachments_examples.rb +52 -28
- data/lib/decidim/admin/test/manage_categories_examples.rb +13 -13
- data/lib/decidim/admin/test/manage_component_permissions_examples.rb +5 -5
- data/lib/decidim/admin/test/manage_hide_content_examples.rb +4 -4
- data/lib/decidim/admin/test/manage_moderations_examples.rb +21 -21
- data/lib/decidim/admin/test/manage_paginated_collection_examples.rb +5 -5
- data/lib/decidim/admin/test/manage_participatory_space_publications_examples.rb +2 -2
- data/lib/decidim/admin/version.rb +1 -1
- data/lib/decidim/admin.rb +15 -0
- metadata +27 -24
- data/app/commands/decidim/admin/destroy_share_token.rb +0 -46
- data/app/commands/decidim/admin/destroy_static_page.rb +0 -40
- data/app/commands/decidim/admin/destroy_static_page_topic.rb +0 -40
- data/app/controllers/concerns/decidim/admin/verification_conflicts/filterable.rb +0 -31
- data/app/views/layouts/decidim/admin/login.html.erb +0 -19
- /data/app/packs/src/decidim/admin/{external_domain_whitelist.js → external_domain_allowlist.js} +0 -0
@@ -3,16 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic to destroy an area.
|
6
|
-
class DestroyArea < Decidim::
|
7
|
-
# Public: Initializes the command.
|
8
|
-
#
|
9
|
-
# area - The area to destroy
|
10
|
-
# current_user - the user performing the action
|
11
|
-
def initialize(area, current_user)
|
12
|
-
@area = area
|
13
|
-
@current_user = current_user
|
14
|
-
end
|
15
|
-
|
6
|
+
class DestroyArea < Decidim::Commands::DestroyResource
|
16
7
|
# Executes the command. Broadcasts these events:
|
17
8
|
#
|
18
9
|
# - :ok when everything is valid.
|
@@ -20,25 +11,11 @@ module Decidim
|
|
20
11
|
#
|
21
12
|
# Returns nothing.
|
22
13
|
def call
|
23
|
-
|
14
|
+
destroy_resource
|
24
15
|
broadcast(:ok)
|
25
16
|
rescue ActiveRecord::RecordNotDestroyed
|
26
17
|
broadcast(:has_spaces)
|
27
18
|
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
attr_reader :current_user
|
32
|
-
|
33
|
-
def destroy_area
|
34
|
-
Decidim.traceability.perform_action!(
|
35
|
-
"delete",
|
36
|
-
@area,
|
37
|
-
current_user
|
38
|
-
) do
|
39
|
-
@area.destroy!
|
40
|
-
end
|
41
|
-
end
|
42
19
|
end
|
43
20
|
end
|
44
21
|
end
|
@@ -4,36 +4,11 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic to destroy a category in the
|
6
6
|
# system.
|
7
|
-
class DestroyCategory < Decidim::
|
8
|
-
|
9
|
-
#
|
10
|
-
# category - A Category that will be destroyed
|
11
|
-
def initialize(category, user)
|
12
|
-
@category = category
|
13
|
-
@user = user
|
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) if category.nil? || category.subcategories.any? || !category.unused?
|
24
|
-
|
25
|
-
destroy_category
|
26
|
-
broadcast(:ok)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
attr_reader :category
|
7
|
+
class DestroyCategory < Decidim::Commands::DestroyResource
|
8
|
+
protected
|
32
9
|
|
33
|
-
def
|
34
|
-
|
35
|
-
category.destroy!
|
36
|
-
end
|
10
|
+
def invalid?
|
11
|
+
resource.nil? || resource.subcategories.any? || !resource.unused?
|
37
12
|
end
|
38
13
|
end
|
39
14
|
end
|
@@ -2,54 +2,16 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
|
-
# This command deals with destroying a
|
6
|
-
class DestroyComponent < Decidim::
|
7
|
-
# Public: Initializes the command.
|
8
|
-
#
|
9
|
-
# component - The Component to be destroyed.
|
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: Executes the command.
|
17
|
-
#
|
18
|
-
# Broadcasts :ok if it got destroyed, raises an exception otherwise.
|
19
|
-
def call
|
20
|
-
begin
|
21
|
-
destroy_component
|
22
|
-
rescue StandardError
|
23
|
-
return broadcast(:invalid)
|
24
|
-
end
|
25
|
-
broadcast(:ok)
|
26
|
-
end
|
27
|
-
|
5
|
+
# This command deals with destroying a component from the admin panel.
|
6
|
+
class DestroyComponent < Decidim::Commands::DestroyResource
|
28
7
|
private
|
29
8
|
|
30
|
-
def destroy_component
|
31
|
-
transaction do
|
32
|
-
run_before_hooks
|
33
|
-
|
34
|
-
Decidim.traceability.perform_action!(
|
35
|
-
"delete",
|
36
|
-
@component,
|
37
|
-
@current_user
|
38
|
-
) do
|
39
|
-
@component.destroy!
|
40
|
-
end
|
41
|
-
|
42
|
-
run_hooks
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
9
|
def run_before_hooks
|
47
|
-
|
48
|
-
@component.manifest.run_hooks(:before_destroy, @component)
|
10
|
+
resource.manifest.run_hooks(:before_destroy, resource)
|
49
11
|
end
|
50
12
|
|
51
|
-
def
|
52
|
-
|
13
|
+
def run_after_hooks
|
14
|
+
resource.manifest.run_hooks(:destroy, resource)
|
53
15
|
end
|
54
16
|
end
|
55
17
|
end
|
@@ -3,38 +3,10 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# This command deals with destroying a newsletter from the admin panel.
|
6
|
-
class DestroyNewsletter < Decidim::
|
7
|
-
# Public: Initializes the command.
|
8
|
-
#
|
9
|
-
# newsletter - The Newsletter to be destroyed.
|
10
|
-
def initialize(newsletter, current_user)
|
11
|
-
@newsletter = newsletter
|
12
|
-
@current_user = current_user
|
13
|
-
end
|
14
|
-
|
15
|
-
# Public: Executes the command.
|
16
|
-
#
|
17
|
-
# Broadcasts :ok if it got destroyed
|
18
|
-
def call
|
19
|
-
return broadcast(:already_sent) if newsletter.sent?
|
20
|
-
|
21
|
-
destroy_newsletter
|
22
|
-
broadcast(:ok)
|
23
|
-
end
|
24
|
-
|
6
|
+
class DestroyNewsletter < Decidim::Commands::DestroyResource
|
25
7
|
private
|
26
8
|
|
27
|
-
|
28
|
-
|
29
|
-
def destroy_newsletter
|
30
|
-
Decidim.traceability.perform_action!(
|
31
|
-
"delete",
|
32
|
-
newsletter,
|
33
|
-
current_user
|
34
|
-
) do
|
35
|
-
newsletter.destroy!
|
36
|
-
end
|
37
|
-
end
|
9
|
+
def invalid? = resource.sent?
|
38
10
|
end
|
39
11
|
end
|
40
12
|
end
|
@@ -3,42 +3,15 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic to destroy a participatory space private user.
|
6
|
-
class DestroyParticipatorySpacePrivateUser < Decidim::
|
7
|
-
# Public: Initializes the command.
|
8
|
-
#
|
9
|
-
# participatory_space_private_user - The participatory space private user to destroy
|
10
|
-
# current_user - the user performing the action
|
11
|
-
def initialize(participatory_space_private_user, current_user)
|
12
|
-
@participatory_space_private_user = participatory_space_private_user
|
13
|
-
@current_user = current_user
|
14
|
-
end
|
15
|
-
|
16
|
-
# Executes the command. Broadcasts these events:
|
17
|
-
#
|
18
|
-
# - :ok when everything is valid.
|
19
|
-
# - :invalid if the form was not valid and we could not proceed.
|
20
|
-
#
|
21
|
-
# Returns nothing.
|
22
|
-
def call
|
23
|
-
destroy_participatory_space_private_user
|
24
|
-
broadcast(:ok)
|
25
|
-
end
|
26
|
-
|
6
|
+
class DestroyParticipatorySpacePrivateUser < Decidim::Commands::DestroyResource
|
27
7
|
private
|
28
8
|
|
29
|
-
|
30
|
-
|
31
|
-
def destroy_participatory_space_private_user
|
32
|
-
Decidim.traceability.perform_action!(
|
33
|
-
"delete",
|
34
|
-
@participatory_space_private_user,
|
35
|
-
current_user,
|
9
|
+
def extra_params
|
10
|
+
{
|
36
11
|
resource: {
|
37
|
-
title:
|
12
|
+
title: resource.user.name
|
38
13
|
}
|
39
|
-
|
40
|
-
@participatory_space_private_user.destroy!
|
41
|
-
end
|
14
|
+
}
|
42
15
|
end
|
43
16
|
end
|
44
17
|
end
|
@@ -3,43 +3,16 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic to destroy a scope.
|
6
|
-
class DestroyScope < Decidim::
|
7
|
-
# Public: Initializes the command.
|
8
|
-
#
|
9
|
-
# scope - The Scope to destroy
|
10
|
-
# current_user - the user performing the action
|
11
|
-
def initialize(scope, current_user)
|
12
|
-
@scope = scope
|
13
|
-
@current_user = current_user
|
14
|
-
end
|
15
|
-
|
16
|
-
# Executes the command. Broadcasts these events:
|
17
|
-
#
|
18
|
-
# - :ok when everything is valid.
|
19
|
-
# - :invalid if the form was not valid and we could not proceed.
|
20
|
-
#
|
21
|
-
# Returns nothing.
|
22
|
-
def call
|
23
|
-
update_scope
|
24
|
-
broadcast(:ok)
|
25
|
-
end
|
26
|
-
|
6
|
+
class DestroyScope < Decidim::Commands::DestroyResource
|
27
7
|
private
|
28
8
|
|
29
|
-
|
30
|
-
|
31
|
-
def update_scope
|
32
|
-
Decidim.traceability.perform_action!(
|
33
|
-
"delete",
|
34
|
-
@scope,
|
35
|
-
current_user,
|
9
|
+
def extra_params
|
10
|
+
{
|
36
11
|
extra: {
|
37
|
-
parent_name:
|
38
|
-
scope_type_name:
|
12
|
+
parent_name: resource.parent.try(:name),
|
13
|
+
scope_type_name: resource.scope_type.try(:name)
|
39
14
|
}
|
40
|
-
|
41
|
-
@scope.destroy!
|
42
|
-
end
|
15
|
+
}
|
43
16
|
end
|
44
17
|
end
|
45
18
|
end
|
@@ -4,6 +4,7 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
module ParticipatorySpace
|
6
6
|
class CreateAdmin < Decidim::Command
|
7
|
+
delegate :current_user, to: :form
|
7
8
|
# Public: Initializes the command.
|
8
9
|
#
|
9
10
|
# form - A form object with the params.
|
@@ -11,7 +12,6 @@ module Decidim
|
|
11
12
|
# user role
|
12
13
|
def initialize(form, participatory_space, options = {})
|
13
14
|
@form = form
|
14
|
-
@current_user = form.current_user
|
15
15
|
@participatory_space = participatory_space
|
16
16
|
@event_class = options.delete(:event_class)
|
17
17
|
@event = options.delete(:event)
|
@@ -41,7 +41,7 @@ module Decidim
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
-
attr_reader :form, :participatory_space, :
|
44
|
+
attr_reader :form, :participatory_space, :user
|
45
45
|
|
46
46
|
def event_class = @event_class || (raise NotImplementedError, "You must define an event_class")
|
47
47
|
|
@@ -67,7 +67,7 @@ module Decidim
|
|
67
67
|
|
68
68
|
def extra_info = { resource: { title: user.name } }
|
69
69
|
|
70
|
-
def role_params = { role
|
70
|
+
def role_params = { :role => form.role.to_sym, :user => user, role_class.new.target_space_association => participatory_space }
|
71
71
|
|
72
72
|
def send_notification(user)
|
73
73
|
Decidim::EventsManager.publish(
|
@@ -114,7 +114,7 @@ module Decidim
|
|
114
114
|
current_user: user
|
115
115
|
)
|
116
116
|
|
117
|
-
Decidim::CreateFollow.new(form
|
117
|
+
Decidim::CreateFollow.new(form).call
|
118
118
|
end
|
119
119
|
|
120
120
|
def existing_user
|
@@ -7,14 +7,13 @@ module Decidim
|
|
7
7
|
class ProcessParticipatorySpacePrivateUserImportCsv < Decidim::Command
|
8
8
|
include Decidim::Admin::CustomImport
|
9
9
|
|
10
|
+
delegate :current_user, to: :form
|
10
11
|
# Public: Initializes the command.
|
11
12
|
#
|
12
13
|
# form - the form object containing the uploaded file
|
13
|
-
# current_user - the user performing the action
|
14
14
|
# private_users_to - The private_users_to that will hold the user role
|
15
|
-
def initialize(form,
|
15
|
+
def initialize(form, private_users_to)
|
16
16
|
@form = form
|
17
|
-
@current_user = current_user
|
18
17
|
@private_users_to = private_users_to
|
19
18
|
end
|
20
19
|
|
@@ -33,9 +32,11 @@ module Decidim
|
|
33
32
|
|
34
33
|
private
|
35
34
|
|
35
|
+
attr_reader :form
|
36
|
+
|
36
37
|
def process_csv
|
37
38
|
process_import_file(@form.file) do |(email, user_name)|
|
38
|
-
ImportParticipatorySpacePrivateUserCsvJob.perform_later(email, user_name, @private_users_to,
|
39
|
+
ImportParticipatorySpacePrivateUserCsvJob.perform_later(email, user_name, @private_users_to, current_user) if email.present? && user_name.present?
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
@@ -8,15 +8,14 @@ module Decidim
|
|
8
8
|
# will be invited to the application and will lose the managed flag
|
9
9
|
# so the user cannot be impersonated anymore.
|
10
10
|
class PromoteManagedUser < Decidim::Command
|
11
|
+
delegate :current_user, to: :form
|
11
12
|
# Public: Initializes the command.
|
12
13
|
#
|
13
14
|
# form - A form object with the params.
|
14
15
|
# user - The user to promote
|
15
|
-
|
16
|
-
def initialize(form, user, promoted_by)
|
16
|
+
def initialize(form, user)
|
17
17
|
@form = form
|
18
18
|
@user = user
|
19
|
-
@promoted_by = promoted_by
|
20
19
|
end
|
21
20
|
|
22
21
|
# Executes the command. Broadcasts these events:
|
@@ -35,7 +34,7 @@ module Decidim
|
|
35
34
|
broadcast(:ok)
|
36
35
|
end
|
37
36
|
|
38
|
-
attr_reader :form, :user
|
37
|
+
attr_reader :form, :user
|
39
38
|
|
40
39
|
private
|
41
40
|
|
@@ -46,7 +45,7 @@ module Decidim
|
|
46
45
|
end
|
47
46
|
|
48
47
|
def invite_user
|
49
|
-
user.invite!(
|
48
|
+
user.invite!(current_user)
|
50
49
|
end
|
51
50
|
|
52
51
|
def email_already_exists?
|
@@ -3,47 +3,8 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when updating an area.
|
6
|
-
class UpdateArea < Decidim::
|
7
|
-
|
8
|
-
#
|
9
|
-
# area - The Area to update
|
10
|
-
# form - A form object with the params.
|
11
|
-
def initialize(area, form)
|
12
|
-
@area = area
|
13
|
-
@form = form
|
14
|
-
end
|
15
|
-
|
16
|
-
# Executes the command. Broadcasts these events:
|
17
|
-
#
|
18
|
-
# - :ok when everything is valid.
|
19
|
-
# - :invalid if the form was not valid and we could not proceed.
|
20
|
-
#
|
21
|
-
# Returns nothing.
|
22
|
-
def call
|
23
|
-
return broadcast(:invalid) if form.invalid?
|
24
|
-
|
25
|
-
update_area
|
26
|
-
broadcast(:ok)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
attr_reader :form
|
32
|
-
|
33
|
-
def update_area
|
34
|
-
Decidim.traceability.update!(
|
35
|
-
@area,
|
36
|
-
form.current_user,
|
37
|
-
attributes
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
def attributes
|
42
|
-
{
|
43
|
-
name: form.name,
|
44
|
-
area_type: form.area_type
|
45
|
-
}
|
46
|
-
end
|
6
|
+
class UpdateArea < Decidim::Commands::UpdateResource
|
7
|
+
fetch_form_attributes :name, :area_type
|
47
8
|
end
|
48
9
|
end
|
49
10
|
end
|
@@ -3,48 +3,8 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when updating an area type.
|
6
|
-
class UpdateAreaType < Decidim::
|
7
|
-
|
8
|
-
#
|
9
|
-
# area_type - The AreaType to update
|
10
|
-
# form - A form object with the params.
|
11
|
-
def initialize(area_type, form, user)
|
12
|
-
@area_type = area_type
|
13
|
-
@form = form
|
14
|
-
@user = user
|
15
|
-
end
|
16
|
-
|
17
|
-
# Executes the command. Broadcasts these events:
|
18
|
-
#
|
19
|
-
# - :ok when everything is valid.
|
20
|
-
# - :invalid if the form was not valid and we could not proceed.
|
21
|
-
#
|
22
|
-
# Returns nothing.
|
23
|
-
def call
|
24
|
-
return broadcast(:invalid) if form.invalid?
|
25
|
-
|
26
|
-
update_area_type
|
27
|
-
broadcast(:ok)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
attr_reader :form
|
33
|
-
|
34
|
-
def update_area_type
|
35
|
-
Decidim.traceability.update!(
|
36
|
-
@area_type,
|
37
|
-
@user,
|
38
|
-
attributes
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
def attributes
|
43
|
-
{
|
44
|
-
name: form.name,
|
45
|
-
plural: form.plural
|
46
|
-
}
|
47
|
-
end
|
6
|
+
class UpdateAreaType < Decidim::Commands::UpdateResource
|
7
|
+
fetch_form_attributes :name, :plural
|
48
8
|
end
|
49
9
|
end
|
50
10
|
end
|
@@ -9,14 +9,14 @@ module Decidim
|
|
9
9
|
|
10
10
|
attr_reader :attachment
|
11
11
|
|
12
|
+
delegate :current_user, to: :form
|
12
13
|
# Public: Initializes the command.
|
13
14
|
#
|
14
15
|
# attachment - the Attachment to update
|
15
16
|
# form - A form object with the params.
|
16
|
-
def initialize(attachment, form
|
17
|
+
def initialize(attachment, form)
|
17
18
|
@attachment = attachment
|
18
19
|
@form = form
|
19
|
-
@user = user
|
20
20
|
end
|
21
21
|
|
22
22
|
# Executes the command. Broadcasts these events:
|
@@ -37,20 +37,23 @@ module Decidim
|
|
37
37
|
attr_reader :form
|
38
38
|
|
39
39
|
def update_attachment
|
40
|
-
Decidim.traceability.update!(@attachment,
|
40
|
+
Decidim.traceability.update!(@attachment, current_user, attributes)
|
41
41
|
end
|
42
42
|
|
43
43
|
def attributes
|
44
44
|
{
|
45
45
|
title: form.title,
|
46
46
|
file: form.file,
|
47
|
+
link: form.link,
|
47
48
|
description: form.description,
|
48
|
-
weight: form.weight
|
49
|
-
attachment_collection: form.attachment_collection
|
49
|
+
weight: form.weight
|
50
50
|
}.merge(
|
51
51
|
attachment_attributes(:file)
|
52
|
-
).
|
53
|
-
|
52
|
+
).compact_blank.merge(
|
53
|
+
attachment_collection: form.attachment_collection
|
54
|
+
).tap do |attrs|
|
55
|
+
attrs[:file] = nil if form.link.present? && form.file.blank?
|
56
|
+
attrs[:link] = nil if form.file.present? && form.link.blank?
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|
@@ -4,14 +4,14 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when updating an attachment collection.
|
6
6
|
class UpdateAttachmentCollection < Decidim::Command
|
7
|
+
delegate :current_user, to: :form
|
7
8
|
# Public: Initializes the command.
|
8
9
|
#
|
9
10
|
# attachment_collection - The AttachmentCollection to update
|
10
11
|
# form - A form object with the params.
|
11
|
-
def initialize(attachment_collection, form
|
12
|
+
def initialize(attachment_collection, form)
|
12
13
|
@attachment_collection = attachment_collection
|
13
14
|
@form = form
|
14
|
-
@user = user
|
15
15
|
end
|
16
16
|
|
17
17
|
# Executes the command. Broadcasts these events:
|
@@ -34,7 +34,7 @@ module Decidim
|
|
34
34
|
def update_attachment_collection
|
35
35
|
Decidim.traceability.update!(
|
36
36
|
@attachment_collection,
|
37
|
-
|
37
|
+
current_user,
|
38
38
|
attributes
|
39
39
|
)
|
40
40
|
end
|
@@ -4,51 +4,8 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when updating a category in the
|
6
6
|
# system.
|
7
|
-
class UpdateCategory < Decidim::
|
8
|
-
|
9
|
-
|
10
|
-
# Public: Initializes the command.
|
11
|
-
#
|
12
|
-
# category - the Category to update
|
13
|
-
# form - A form object with the params.
|
14
|
-
def initialize(category, form, user)
|
15
|
-
@category = category
|
16
|
-
@form = form
|
17
|
-
@user = user
|
18
|
-
end
|
19
|
-
|
20
|
-
# Executes the command. Broadcasts these events:
|
21
|
-
#
|
22
|
-
# - :ok when everything is valid.
|
23
|
-
# - :invalid if the form was not valid and we could not proceed.
|
24
|
-
#
|
25
|
-
# Returns nothing.
|
26
|
-
def call
|
27
|
-
return broadcast(:invalid) if form.invalid?
|
28
|
-
|
29
|
-
update_category
|
30
|
-
broadcast(:ok)
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
attr_reader :form
|
36
|
-
|
37
|
-
def update_category
|
38
|
-
Decidim.traceability.update!(
|
39
|
-
category,
|
40
|
-
@user,
|
41
|
-
attributes
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
def attributes
|
46
|
-
{
|
47
|
-
name: form.name,
|
48
|
-
weight: form.weight,
|
49
|
-
parent_id: form.parent_id
|
50
|
-
}
|
51
|
-
end
|
7
|
+
class UpdateCategory < Decidim::Commands::UpdateResource
|
8
|
+
fetch_form_attributes :name, :weight, :parent_id
|
52
9
|
end
|
53
10
|
end
|
54
11
|
end
|
@@ -3,18 +3,17 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# This command gets called when a component is created from the admin panel.
|
6
|
-
class UpdateComponent < Decidim::
|
6
|
+
class UpdateComponent < Decidim::Commands::UpdateResource
|
7
7
|
attr_reader :form, :component, :previous_settings
|
8
8
|
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# form - The form from which the data in this component comes from.
|
12
12
|
# component - The component to update.
|
13
|
-
def initialize(form, component
|
14
|
-
@manifest = component.manifest
|
13
|
+
def initialize(form, component)
|
15
14
|
@form = form
|
16
15
|
@component = component
|
17
|
-
@
|
16
|
+
@manifest = component.manifest
|
18
17
|
end
|
19
18
|
|
20
19
|
# Public: Creates the Component.
|
@@ -23,7 +22,7 @@ module Decidim
|
|
23
22
|
def call
|
24
23
|
return broadcast(:invalid) if form.invalid?
|
25
24
|
|
26
|
-
Decidim.traceability.perform_action!("update", @component,
|
25
|
+
Decidim.traceability.perform_action!("update", @component, form.current_user) do
|
27
26
|
transaction do
|
28
27
|
update_component
|
29
28
|
run_hooks
|