decidim-admin 0.28.2 → 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/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 +3 -3
- 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 -42
- 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 +78 -3
- 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/participatory_space_export.rb +1 -1
- data/app/controllers/decidim/admin/application_controller.rb +1 -0
- 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/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/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/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/categories/index.html.erb +2 -2
- data/app/views/decidim/admin/components/_form.html.erb +1 -1
- 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 +1 -1
- data/app/views/decidim/admin/impersonatable_users/index.html.erb +3 -3
- data/app/views/decidim/admin/imports/_dropdown.html.erb +1 -1
- data/app/views/decidim/admin/imports/new.html.erb +2 -2
- 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 +3 -3
- 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_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 -10
- data/config/locales/ca.yml +16 -11
- data/config/locales/cs.yml +15 -10
- data/config/locales/de.yml +15 -10
- data/config/locales/el.yml +0 -12
- data/config/locales/en.yml +16 -11
- data/config/locales/es-MX.yml +16 -11
- data/config/locales/es-PY.yml +16 -11
- data/config/locales/es.yml +16 -11
- data/config/locales/eu.yml +16 -11
- data/config/locales/fi-plain.yml +14 -9
- data/config/locales/fi.yml +14 -9
- data/config/locales/fr-CA.yml +14 -9
- data/config/locales/fr.yml +13 -8
- 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 +16 -11
- 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 -10
- data/config/locales/pt.yml +0 -8
- data/config/locales/ro-RO.yml +0 -12
- 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 +0 -8
- 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/manage_attachment_collections_examples.rb +12 -12
- data/lib/decidim/admin/test/manage_attachments_examples.rb +51 -15
- 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 +3 -3
- data/lib/decidim/admin/test/manage_participatory_space_publications_examples.rb +2 -2
- data/lib/decidim/admin/version.rb +1 -1
- metadata +24 -22
- 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/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
@@ -5,16 +5,16 @@ module Decidim
|
|
5
5
|
# This command gets called when permissions for a component are updated
|
6
6
|
# in the admin panel.
|
7
7
|
class UpdateComponentPermissions < Decidim::Command
|
8
|
+
delegate :current_user, to: :form
|
8
9
|
# Public: Initializes the command.
|
9
10
|
#
|
10
11
|
# form - The form from which the data in this component comes from.
|
11
12
|
# component - The component to update.
|
12
13
|
# resource - The resource to update.
|
13
|
-
def initialize(form, component, resource
|
14
|
+
def initialize(form, component, resource)
|
14
15
|
@form = form
|
15
16
|
@component = component
|
16
17
|
@resource = resource
|
17
|
-
@user = user
|
18
18
|
end
|
19
19
|
|
20
20
|
# Public: Sets the permissions for a component.
|
@@ -23,7 +23,7 @@ module Decidim
|
|
23
23
|
def call
|
24
24
|
return broadcast(:invalid) unless form.valid?
|
25
25
|
|
26
|
-
Decidim.traceability.perform_action!("update_permissions", @component,
|
26
|
+
Decidim.traceability.perform_action!("update_permissions", @component, current_user) do
|
27
27
|
transaction do
|
28
28
|
update_permissions
|
29
29
|
run_hooks
|
@@ -2,19 +2,20 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
|
-
class
|
5
|
+
class UpdateExternalDomainAllowlist < Decidim::Command
|
6
6
|
attr_reader :form, :organization
|
7
7
|
|
8
|
-
|
8
|
+
delegate :current_user, to: :form
|
9
|
+
|
10
|
+
def initialize(form, organization)
|
9
11
|
@form = form
|
10
12
|
@organization = organization
|
11
|
-
@user = user
|
12
13
|
end
|
13
14
|
|
14
15
|
def call
|
15
16
|
return broadcast(:invalid) if form.invalid?
|
16
17
|
|
17
|
-
Decidim.traceability.perform_action!("update_external_domain", @organization,
|
18
|
+
Decidim.traceability.perform_action!("update_external_domain", @organization, current_user) do
|
18
19
|
save_domains!
|
19
20
|
end
|
20
21
|
|
@@ -24,7 +25,7 @@ module Decidim
|
|
24
25
|
private
|
25
26
|
|
26
27
|
def save_domains!
|
27
|
-
organization.
|
28
|
+
organization.external_domain_allowlist = form.external_domains.filter_map do |external_domain_form|
|
28
29
|
external_domain_form.value unless external_domain_form.deleted
|
29
30
|
end.flatten
|
30
31
|
|
@@ -5,10 +5,11 @@ module Decidim
|
|
5
5
|
# This command gets called when a content block is updated from the admin
|
6
6
|
# panel.
|
7
7
|
class UpdateHelpSections < Decidim::Command
|
8
|
-
|
8
|
+
delegate :current_user, to: :form
|
9
|
+
|
10
|
+
def initialize(form, organization)
|
9
11
|
@form = form
|
10
12
|
@organization = organization
|
11
|
-
@user = user
|
12
13
|
end
|
13
14
|
|
14
15
|
def call
|
@@ -18,7 +19,7 @@ module Decidim
|
|
18
19
|
@form.sections.each do |section|
|
19
20
|
next unless content_has_changed?(section)
|
20
21
|
|
21
|
-
Decidim.traceability.perform_action!("update", ContextualHelpSection,
|
22
|
+
Decidim.traceability.perform_action!("update", ContextualHelpSection, current_user, { "resource" => { "title" => section.id.humanize } }) do
|
22
23
|
ContextualHelpSection.set_content(@organization, section.id, section.content)
|
23
24
|
ContextualHelpSection.find_by(organization: @organization, section_id: section.id)
|
24
25
|
end
|
@@ -30,6 +31,8 @@ module Decidim
|
|
30
31
|
|
31
32
|
private
|
32
33
|
|
34
|
+
attr_reader :form
|
35
|
+
|
33
36
|
def content_has_changed?(section)
|
34
37
|
return if ContextualHelpSection.find_by(organization: @organization, section_id: section.id).nil? && section.content.compact_blank.blank?
|
35
38
|
|
@@ -4,17 +4,16 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
# Updates the newsletter given form data.
|
6
6
|
class UpdateNewsletter < Decidim::Command
|
7
|
+
delegate :current_user, to: :form
|
7
8
|
# Initializes the command.
|
8
9
|
#
|
9
10
|
# newsletter - The Newsletter to update.
|
10
11
|
# form - The form object containing the data to update.
|
11
|
-
|
12
|
-
def initialize(newsletter, form, user)
|
12
|
+
def initialize(newsletter, form)
|
13
13
|
@newsletter = newsletter
|
14
14
|
@content_block = newsletter.template
|
15
15
|
@form = form
|
16
|
-
@
|
17
|
-
@organization = user.organization
|
16
|
+
@organization = form.current_organization
|
18
17
|
end
|
19
18
|
|
20
19
|
def call
|
@@ -32,19 +31,20 @@ module Decidim
|
|
32
31
|
|
33
32
|
private
|
34
33
|
|
35
|
-
attr_reader :
|
34
|
+
attr_reader :newsletter, :content_block, :organization, :form
|
36
35
|
|
37
36
|
def update_newsletter
|
37
|
+
# pp current_user.inspect
|
38
38
|
@newsletter = Decidim.traceability.update!(
|
39
39
|
newsletter,
|
40
|
-
|
40
|
+
current_user,
|
41
41
|
subject: form.subject,
|
42
|
-
author:
|
42
|
+
author: current_user
|
43
43
|
)
|
44
44
|
end
|
45
45
|
|
46
46
|
def update_content_block
|
47
|
-
ContentBlocks::UpdateContentBlock.call(form, content_block,
|
47
|
+
ContentBlocks::UpdateContentBlock.call(form, content_block, current_user) do
|
48
48
|
on(:ok) do |content_block|
|
49
49
|
@content_block = content_block
|
50
50
|
end
|
@@ -4,62 +4,18 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic for updating the current
|
6
6
|
# organization.
|
7
|
-
class UpdateOrganization < Decidim::
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def initialize(organization, form)
|
13
|
-
@organization = organization
|
14
|
-
@form = form
|
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
|
-
return broadcast(:ok, @organization) if update_organization
|
27
|
-
|
28
|
-
broadcast(:invalid)
|
29
|
-
end
|
7
|
+
class UpdateOrganization < Decidim::Commands::UpdateResource
|
8
|
+
fetch_form_attributes :name, :default_locale, :reference_prefix, :time_zone, :twitter_handler,
|
9
|
+
:facebook_handler, :instagram_handler, :youtube_handler, :github_handler, :badges_enabled,
|
10
|
+
:user_groups_enabled, :comments_max_length, :enable_machine_translations,
|
11
|
+
:admin_terms_of_service_body, :rich_text_editor_in_public_views, :enable_participatory_space_filters
|
30
12
|
|
31
13
|
private
|
32
14
|
|
33
|
-
attr_reader :form, :organization
|
34
|
-
|
35
|
-
def update_organization
|
36
|
-
@organization = Decidim.traceability.update!(
|
37
|
-
@organization,
|
38
|
-
form.current_user,
|
39
|
-
attributes
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
15
|
def attributes
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
reference_prefix: form.reference_prefix,
|
48
|
-
time_zone: form.time_zone,
|
49
|
-
twitter_handler: form.twitter_handler,
|
50
|
-
facebook_handler: form.facebook_handler,
|
51
|
-
instagram_handler: form.instagram_handler,
|
52
|
-
youtube_handler: form.youtube_handler,
|
53
|
-
github_handler: form.github_handler,
|
54
|
-
badges_enabled: form.badges_enabled,
|
55
|
-
user_groups_enabled: form.user_groups_enabled,
|
56
|
-
comments_max_length: form.comments_max_length,
|
57
|
-
enable_machine_translations: form.enable_machine_translations,
|
58
|
-
admin_terms_of_service_body: form.admin_terms_of_service_body,
|
59
|
-
rich_text_editor_in_public_views: form.rich_text_editor_in_public_views,
|
60
|
-
enable_participatory_space_filters: form.enable_participatory_space_filters
|
61
|
-
}.merge(welcome_notification_attributes)
|
62
|
-
.merge(machine_translation_attributes || {})
|
16
|
+
super
|
17
|
+
.merge(welcome_notification_attributes)
|
18
|
+
.merge(machine_translation_attributes)
|
63
19
|
end
|
64
20
|
|
65
21
|
def welcome_notification_attributes
|
@@ -71,7 +27,7 @@ module Decidim
|
|
71
27
|
end
|
72
28
|
|
73
29
|
def machine_translation_attributes
|
74
|
-
return unless Decidim.config.enable_machine_translations
|
30
|
+
return {} unless Decidim.config.enable_machine_translations
|
75
31
|
|
76
32
|
{
|
77
33
|
machine_translation_display_priority: form.machine_translation_display_priority
|
@@ -4,59 +4,20 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic for updating the current
|
6
6
|
# organization appearance.
|
7
|
-
class UpdateOrganizationAppearance < Decidim::
|
8
|
-
|
7
|
+
class UpdateOrganizationAppearance < Decidim::Commands::UpdateResource
|
8
|
+
fetch_file_attributes :logo, :highlighted_content_banner_image, :favicon, :official_img_footer
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@form = form
|
17
|
-
end
|
18
|
-
|
19
|
-
# Executes the command. Broadcasts these events:
|
20
|
-
#
|
21
|
-
# - :ok when everything is valid.
|
22
|
-
# - :invalid if the form was not valid and we could not proceed.
|
23
|
-
#
|
24
|
-
# Returns nothing.
|
25
|
-
def call
|
26
|
-
return broadcast(:invalid) if form.invalid?
|
27
|
-
|
28
|
-
begin
|
29
|
-
update_organization
|
30
|
-
broadcast(:ok, organization)
|
31
|
-
rescue ActiveRecord::RecordInvalid
|
32
|
-
image_fields.each do |field|
|
33
|
-
form.errors.add(field, organization.errors[field]) if organization.errors.include? field
|
34
|
-
end
|
35
|
-
broadcast(:invalid)
|
36
|
-
end
|
37
|
-
end
|
10
|
+
fetch_form_attributes :cta_button_path, :cta_button_text, :description, :official_url,
|
11
|
+
:highlighted_content_banner_enabled, :highlighted_content_banner_action_url,
|
12
|
+
:highlighted_content_banner_title, :highlighted_content_banner_short_description,
|
13
|
+
:highlighted_content_banner_action_title,
|
14
|
+
:highlighted_content_banner_action_subtitle, :enable_omnipresent_banner, :omnipresent_banner_url,
|
15
|
+
:omnipresent_banner_title, :omnipresent_banner_short_description
|
38
16
|
|
39
17
|
private
|
40
18
|
|
41
|
-
def image_fields
|
42
|
-
[:logo, :highlighted_content_banner_image, :favicon, :official_img_footer]
|
43
|
-
end
|
44
|
-
|
45
|
-
attr_reader :form, :organization
|
46
|
-
|
47
|
-
def update_organization
|
48
|
-
@organization = Decidim.traceability.update!(
|
49
|
-
organization,
|
50
|
-
form.current_user,
|
51
|
-
attributes
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
19
|
def attributes
|
56
|
-
|
57
|
-
.merge(attachment_attributes(*image_fields))
|
58
|
-
.merge(highlighted_content_banner_attributes)
|
59
|
-
.merge(omnipresent_banner_attributes)
|
20
|
+
super
|
60
21
|
.merge(colors_attributes)
|
61
22
|
.delete_if { |_k, val| val.is_a?(Decidim::ApplicationUploader) }
|
62
23
|
.tap do |attributes|
|
@@ -64,44 +25,12 @@ module Decidim
|
|
64
25
|
end
|
65
26
|
end
|
66
27
|
|
67
|
-
def appearance_attributes
|
68
|
-
{
|
69
|
-
cta_button_path: form.cta_button_path,
|
70
|
-
cta_button_text: form.cta_button_text,
|
71
|
-
description: form.description,
|
72
|
-
official_url: form.official_url
|
73
|
-
}
|
74
|
-
end
|
75
|
-
|
76
|
-
def highlighted_content_banner_attributes
|
77
|
-
{
|
78
|
-
highlighted_content_banner_enabled: form.highlighted_content_banner_enabled,
|
79
|
-
highlighted_content_banner_action_url: form.highlighted_content_banner_action_url,
|
80
|
-
highlighted_content_banner_title: form.highlighted_content_banner_title,
|
81
|
-
highlighted_content_banner_short_description: form.highlighted_content_banner_short_description,
|
82
|
-
highlighted_content_banner_action_title: form.highlighted_content_banner_action_title,
|
83
|
-
highlighted_content_banner_action_subtitle: form.highlighted_content_banner_action_subtitle
|
84
|
-
}
|
85
|
-
end
|
86
|
-
|
87
|
-
def omnipresent_banner_attributes
|
88
|
-
{
|
89
|
-
enable_omnipresent_banner: form.enable_omnipresent_banner,
|
90
|
-
omnipresent_banner_url: form.omnipresent_banner_url,
|
91
|
-
omnipresent_banner_short_description: form.omnipresent_banner_short_description,
|
92
|
-
omnipresent_banner_title: form.omnipresent_banner_title
|
93
|
-
}
|
94
|
-
end
|
95
|
-
|
96
28
|
def colors_attributes
|
97
29
|
{
|
98
30
|
colors: {
|
99
31
|
primary: form.primary_color,
|
100
32
|
secondary: form.secondary_color,
|
101
|
-
tertiary: form.tertiary_color
|
102
|
-
success: form.success_color,
|
103
|
-
warning: form.warning_color,
|
104
|
-
alert: form.alert_color
|
33
|
+
tertiary: form.tertiary_color
|
105
34
|
}.compact_blank
|
106
35
|
}
|
107
36
|
end
|
@@ -3,50 +3,17 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when updating a scope.
|
6
|
-
class UpdateScope < Decidim::
|
7
|
-
|
8
|
-
#
|
9
|
-
# scope - The Scope to update
|
10
|
-
# form - A form object with the params.
|
11
|
-
def initialize(scope, form)
|
12
|
-
@scope = scope
|
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_scope
|
26
|
-
broadcast(:ok)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
6
|
+
class UpdateScope < Decidim::Commands::UpdateResource
|
7
|
+
fetch_form_attributes :name, :code, :scope_type
|
30
8
|
|
31
|
-
|
9
|
+
protected
|
32
10
|
|
33
|
-
def
|
34
|
-
|
35
|
-
@scope,
|
36
|
-
form.current_user,
|
37
|
-
attributes,
|
11
|
+
def extra_params
|
12
|
+
{
|
38
13
|
extra: {
|
39
|
-
parent_name:
|
40
|
-
scope_type_name:
|
14
|
+
parent_name: resource.parent.try(:name),
|
15
|
+
scope_type_name: resource.scope_type.try(:name)
|
41
16
|
}
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
def attributes
|
46
|
-
{
|
47
|
-
name: form.name,
|
48
|
-
code: form.code,
|
49
|
-
scope_type: form.scope_type
|
50
17
|
}
|
51
18
|
end
|
52
19
|
end
|
@@ -3,48 +3,8 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when updating a scope type.
|
6
|
-
class UpdateScopeType < Decidim::
|
7
|
-
|
8
|
-
#
|
9
|
-
# scope_type - The ScopeType to update
|
10
|
-
# form - A form object with the params.
|
11
|
-
def initialize(scope_type, form, user)
|
12
|
-
@scope_type = scope_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_scope_type
|
27
|
-
broadcast(:ok)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
attr_reader :form
|
33
|
-
|
34
|
-
def update_scope_type
|
35
|
-
Decidim.traceability.update!(
|
36
|
-
@scope_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 UpdateScopeType < Decidim::Commands::UpdateResource
|
7
|
+
fetch_form_attributes :name, :plural
|
48
8
|
end
|
49
9
|
end
|
50
10
|
end
|
@@ -3,56 +3,15 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when updating a static page.
|
6
|
-
class UpdateStaticPage < Decidim::
|
7
|
-
|
8
|
-
#
|
9
|
-
# page - The StaticPage to update
|
10
|
-
# form - A form object with the params.
|
11
|
-
def initialize(page, form)
|
12
|
-
@page = page
|
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_page
|
26
|
-
update_organization_tos_version if form.changed_notably
|
27
|
-
broadcast(:ok)
|
28
|
-
end
|
6
|
+
class UpdateStaticPage < Decidim::Commands::UpdateResource
|
7
|
+
fetch_form_attributes :title, :slug, :weight, :topic, :content, :allow_public_access
|
29
8
|
|
30
9
|
private
|
31
10
|
|
32
|
-
|
33
|
-
|
34
|
-
def update_page
|
35
|
-
Decidim.traceability.update!(
|
36
|
-
@page,
|
37
|
-
form.current_user,
|
38
|
-
attributes
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
def attributes
|
43
|
-
{
|
44
|
-
title: form.title,
|
45
|
-
slug: form.slug,
|
46
|
-
show_in_footer: form.show_in_footer,
|
47
|
-
weight: form.weight,
|
48
|
-
topic: form.topic,
|
49
|
-
content: form.content,
|
50
|
-
allow_public_access: form.allow_public_access
|
51
|
-
}
|
52
|
-
end
|
11
|
+
def run_after_hooks
|
12
|
+
return unless form.changed_notably
|
53
13
|
|
54
|
-
|
55
|
-
UpdateOrganizationTosVersion.call(@form.organization, @page, @form)
|
14
|
+
UpdateOrganizationTosVersion.call(form.organization, resource, form)
|
56
15
|
end
|
57
16
|
end
|
58
17
|
end
|
@@ -3,49 +3,8 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when updating a static page topic.
|
6
|
-
class UpdateStaticPageTopic < Decidim::
|
7
|
-
|
8
|
-
#
|
9
|
-
# page - The StaticPageTopic to update
|
10
|
-
# form - A form object with the params.
|
11
|
-
def initialize(topic, form)
|
12
|
-
@topic = topic
|
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_topic
|
26
|
-
broadcast(:ok)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
attr_reader :form
|
32
|
-
|
33
|
-
def update_topic
|
34
|
-
Decidim.traceability.update!(
|
35
|
-
@topic,
|
36
|
-
form.current_user,
|
37
|
-
attributes
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
def attributes
|
42
|
-
{
|
43
|
-
title: form.title,
|
44
|
-
description: form.description,
|
45
|
-
show_in_footer: form.show_in_footer,
|
46
|
-
weight: form.weight
|
47
|
-
}
|
48
|
-
end
|
6
|
+
class UpdateStaticPageTopic < Decidim::Commands::UpdateResource
|
7
|
+
fetch_form_attributes :title, :description, :show_in_footer, :weight
|
49
8
|
end
|
50
9
|
end
|
51
10
|
end
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
# A Rails routes constraint to only allow access to an Organization admin to
|
6
6
|
# the organization dashboard.
|
7
7
|
class OrganizationDashboardConstraint
|
8
|
-
# Initializes the
|
8
|
+
# Initializes the constraint.
|
9
9
|
#
|
10
10
|
# request [Rack::Request]
|
11
11
|
def initialize(request)
|
@@ -79,7 +79,7 @@ module Decidim
|
|
79
79
|
|
80
80
|
# Method to be implemented at the controller. Defines the permissions for
|
81
81
|
# edit and update actions.
|
82
|
-
# For example `enforce_permission_to :
|
82
|
+
# For example `enforce_permission_to :update, :process, process: scoped_resource
|
83
83
|
def enforce_permission_to_update_resource
|
84
84
|
raise "#{self.class.name} is expected to implement #enforce_permission_to_update_resource"
|
85
85
|
end
|
@@ -99,7 +99,7 @@ module Decidim
|
|
99
99
|
# Method to be implemented at the controller. Returns a string
|
100
100
|
# with the cell name to be used for the drag'n'drop for each content_block.
|
101
101
|
#
|
102
|
-
# Example: "decidim/
|
102
|
+
# Example: "decidim/participatory_processes/content_block"
|
103
103
|
def resource_content_block_cell
|
104
104
|
raise "#{self.class.name} is expected to implement #resource_content_block_cell"
|
105
105
|
end
|