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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2203fd3c924ab306246e912329cdaac02091b61e4e8d2db4027ff44705b8032
|
4
|
+
data.tar.gz: 6119bde10948eca047d065a5030536b2c7ac720062f2ff0f81862b6f07b5c384
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 981be4fdb86e6aa0eed5d5d51f3df7d7fff0fd317646247a06e14de255d4d5235ca2cc70d87705ce061ca35178c3ead74d6555df004e6cd5349c27d273d656e8
|
7
|
+
data.tar.gz: 586c39385d2a7b2bc6fe356c9405b6b426b39f30c5afe457cab495d905f177829a3c7ebca332ee51e08b1cd5a6ede59cc00b1c160922ea9b9322d964acc9cde5
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<span
|
2
|
-
<ul class="
|
1
|
+
<span><%= t("decidim.admin.actions.per_page") %> :</span>
|
2
|
+
<ul class="dropdown menu" data-dropdown-menu data-close-on-click-inside="false">
|
3
3
|
<li class="is-dropdown-submenu-parent">
|
4
4
|
<a title="<%= %(#{per_page} #{t("decidim.admin.actions.per_page")}) %>">
|
5
5
|
<%= per_page %>
|
@@ -4,8 +4,6 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
class ResultsPerPageCell < Decidim::ViewModel
|
6
6
|
property :per_page, :per_page_range
|
7
|
-
delegate :params, to: :controller, prefix: false
|
8
|
-
|
9
7
|
def path_for_num_per_page(num_per_page = per_page_range.first)
|
10
8
|
controller.url_for(params.to_unsafe_h.merge(per_page: num_per_page))
|
11
9
|
end
|
@@ -3,40 +3,12 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when creating an area
|
6
|
-
class CreateArea < Decidim::
|
7
|
-
|
8
|
-
#
|
9
|
-
# form - A form object with the params.
|
10
|
-
def initialize(form)
|
11
|
-
@form = form
|
12
|
-
end
|
6
|
+
class CreateArea < Decidim::Commands::CreateResource
|
7
|
+
fetch_form_attributes :name, :organization, :area_type
|
13
8
|
|
14
|
-
|
15
|
-
#
|
16
|
-
# - :ok when everything is valid.
|
17
|
-
# - :invalid if the form was not valid and we could not proceed.
|
18
|
-
#
|
19
|
-
# Returns nothing.
|
20
|
-
def call
|
21
|
-
return broadcast(:invalid) if form.invalid?
|
9
|
+
protected
|
22
10
|
|
23
|
-
|
24
|
-
broadcast(:ok)
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
attr_reader :form
|
30
|
-
|
31
|
-
def create_area
|
32
|
-
Decidim.traceability.create!(
|
33
|
-
Area,
|
34
|
-
form.current_user,
|
35
|
-
name: form.name,
|
36
|
-
organization: form.organization,
|
37
|
-
area_type: form.area_type
|
38
|
-
)
|
39
|
-
end
|
11
|
+
def resource_class = Decidim::Area
|
40
12
|
end
|
41
13
|
end
|
42
14
|
end
|
@@ -3,41 +3,12 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when creating an area type.
|
6
|
-
class CreateAreaType < Decidim::
|
7
|
-
|
8
|
-
#
|
9
|
-
# form - A form object with the params.
|
10
|
-
def initialize(form, user)
|
11
|
-
@form = form
|
12
|
-
@user = user
|
13
|
-
end
|
6
|
+
class CreateAreaType < Decidim::Commands::CreateResource
|
7
|
+
fetch_form_attributes :name, :organization, :plural
|
14
8
|
|
15
|
-
|
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
|
-
return broadcast(:invalid) if form.invalid?
|
9
|
+
protected
|
23
10
|
|
24
|
-
|
25
|
-
broadcast(:ok)
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
attr_reader :form
|
31
|
-
|
32
|
-
def create_area_type
|
33
|
-
Decidim.traceability.create!(
|
34
|
-
AreaType,
|
35
|
-
@user,
|
36
|
-
name: form.name,
|
37
|
-
organization: form.organization,
|
38
|
-
plural: form.plural
|
39
|
-
)
|
40
|
-
end
|
11
|
+
def resource_class = Decidim::AreaType
|
41
12
|
end
|
42
13
|
end
|
43
14
|
end
|
@@ -5,14 +5,14 @@ module Decidim
|
|
5
5
|
# A command with all the business logic to add an attachment to a
|
6
6
|
# participatory process.
|
7
7
|
class CreateAttachment < Decidim::Command
|
8
|
+
delegate :current_user, to: :form
|
8
9
|
# Public: Initializes the command.
|
9
10
|
#
|
10
11
|
# form - A form object with the params.
|
11
12
|
# attached_to - The ActiveRecord::Base that will hold the attachment
|
12
|
-
def initialize(form, attached_to
|
13
|
+
def initialize(form, attached_to)
|
13
14
|
@form = form
|
14
15
|
@attached_to = attached_to
|
15
|
-
@user = user
|
16
16
|
end
|
17
17
|
|
18
18
|
# Executes the command. Broadcasts these events:
|
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
build_attachment
|
28
28
|
|
29
29
|
if @attachment.valid?
|
30
|
-
Decidim.traceability.perform_action!(:create, Decidim::Attachment,
|
30
|
+
Decidim.traceability.perform_action!(:create, Decidim::Attachment, current_user) do
|
31
31
|
@attachment.save!
|
32
32
|
notify_followers
|
33
33
|
broadcast(:ok)
|
@@ -51,7 +51,8 @@ module Decidim
|
|
51
51
|
weight: form.weight,
|
52
52
|
attachment_collection: form.attachment_collection,
|
53
53
|
file: form.file, # Define attached_to before this
|
54
|
-
content_type: blob(form.file).content_type
|
54
|
+
content_type: form.file && blob(form.file).content_type,
|
55
|
+
link: form.file ? nil : form.link
|
55
56
|
)
|
56
57
|
end
|
57
58
|
|
@@ -5,14 +5,14 @@ module Decidim
|
|
5
5
|
# A command with all the business logic to add an attachment collection
|
6
6
|
# to a participatory space.
|
7
7
|
class CreateAttachmentCollection < Decidim::Command
|
8
|
+
delegate :current_user, to: :form
|
8
9
|
# Public: Initializes the command.
|
9
10
|
#
|
10
11
|
# form - A form object with the params.
|
11
12
|
# collection_for - The ActiveRecord::Base that will hold the collection
|
12
|
-
def initialize(form, collection_for
|
13
|
+
def initialize(form, collection_for)
|
13
14
|
@form = form
|
14
15
|
@collection_for = collection_for
|
15
|
-
@user = user
|
16
16
|
end
|
17
17
|
|
18
18
|
# Executes the command. Broadcasts these events:
|
@@ -35,7 +35,7 @@ module Decidim
|
|
35
35
|
def create_attachment_collection
|
36
36
|
Decidim.traceability.create!(
|
37
37
|
AttachmentCollection,
|
38
|
-
|
38
|
+
current_user,
|
39
39
|
attributes
|
40
40
|
)
|
41
41
|
end
|
@@ -4,45 +4,12 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic to create a new category in the
|
6
6
|
# system.
|
7
|
-
class CreateCategory < Decidim::
|
8
|
-
|
9
|
-
#
|
10
|
-
# form - A form object with the params.
|
11
|
-
# participatory_space - The participatory space that will hold the
|
12
|
-
# category
|
13
|
-
def initialize(form, participatory_space, user)
|
14
|
-
@form = form
|
15
|
-
@participatory_space = participatory_space
|
16
|
-
@user = user
|
17
|
-
end
|
7
|
+
class CreateCategory < Decidim::Commands::CreateResource
|
8
|
+
fetch_form_attributes :name, :weight, :parent_id, :participatory_space
|
18
9
|
|
19
|
-
|
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?
|
10
|
+
protected
|
27
11
|
|
28
|
-
|
29
|
-
broadcast(:ok)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
attr_reader :form
|
35
|
-
|
36
|
-
def create_category
|
37
|
-
Decidim.traceability.create!(
|
38
|
-
Category,
|
39
|
-
@user,
|
40
|
-
name: form.name,
|
41
|
-
weight: form.weight,
|
42
|
-
parent_id: form.parent_id,
|
43
|
-
participatory_space: @participatory_space
|
44
|
-
)
|
45
|
-
end
|
12
|
+
def resource_class = Decidim::Category
|
46
13
|
end
|
47
14
|
end
|
48
15
|
end
|
@@ -3,50 +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 CreateComponent < Decidim::
|
7
|
-
|
8
|
-
|
9
|
-
# Public: Initializes the command.
|
10
|
-
#
|
11
|
-
# form - The form from which the data in this component comes from.
|
12
|
-
def initialize(form)
|
13
|
-
@form = form
|
14
|
-
@manifest = form.manifest
|
15
|
-
end
|
16
|
-
|
17
|
-
# Public: Creates the Component.
|
18
|
-
#
|
19
|
-
# Broadcasts :ok if created, :invalid otherwise.
|
20
|
-
def call
|
21
|
-
return broadcast(:invalid) if form.invalid?
|
22
|
-
|
23
|
-
transaction do
|
24
|
-
create_component
|
25
|
-
run_hooks
|
26
|
-
end
|
27
|
-
|
28
|
-
broadcast(:ok)
|
29
|
-
end
|
6
|
+
class CreateComponent < Decidim::Commands::CreateResource
|
7
|
+
fetch_form_attributes :name, :participatory_space, :weight, :settings, :default_step_settings, :step_settings
|
30
8
|
|
31
9
|
private
|
32
10
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
manifest_name: manifest.name,
|
38
|
-
name: form.name,
|
39
|
-
participatory_space: form.participatory_space,
|
40
|
-
weight: form.weight,
|
41
|
-
settings: form.settings,
|
42
|
-
default_step_settings: form.default_step_settings,
|
43
|
-
step_settings: form.step_settings
|
44
|
-
)
|
45
|
-
end
|
11
|
+
# Use `reverse_merge` instead of `merge` as we need the `manifest_name` first
|
12
|
+
def attributes = super.reverse_merge({ manifest_name: form.manifest.name })
|
13
|
+
|
14
|
+
def resource_class = Decidim::Component
|
46
15
|
|
47
|
-
def run_hooks
|
48
|
-
manifest.run_hooks(:create, @component)
|
49
|
-
end
|
16
|
+
def run_after_hooks = form.manifest.run_hooks(:create, resource)
|
50
17
|
end
|
51
18
|
end
|
52
19
|
end
|
@@ -4,48 +4,30 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
# Creates a newsletter and assigns the right author and
|
6
6
|
# organization.
|
7
|
-
class CreateNewsletter < Decidim::
|
7
|
+
class CreateNewsletter < Decidim::Commands::CreateResource
|
8
|
+
fetch_form_attributes :subject, :organization
|
8
9
|
# Initializes the command.
|
9
10
|
#
|
10
11
|
# form - The source fo data for this newsletter.
|
11
12
|
# content_block - An instance of `Decidim::ContentBlock` that holds the
|
12
13
|
# newsletter attributes.
|
13
|
-
|
14
|
-
|
15
|
-
@form = form
|
14
|
+
def initialize(form, content_block)
|
15
|
+
super(form)
|
16
16
|
@content_block = content_block
|
17
|
-
@user = user
|
18
|
-
end
|
19
|
-
|
20
|
-
def call
|
21
|
-
return broadcast(:invalid) unless form.valid?
|
22
|
-
|
23
|
-
transaction do
|
24
|
-
create_newsletter
|
25
|
-
create_content_block
|
26
|
-
end
|
27
|
-
|
28
|
-
broadcast(:ok, newsletter)
|
29
17
|
end
|
30
18
|
|
31
19
|
private
|
32
20
|
|
33
|
-
attr_reader :
|
21
|
+
attr_reader :content_block
|
34
22
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
user,
|
39
|
-
subject: form.subject,
|
40
|
-
author: user,
|
41
|
-
organization: user.organization
|
42
|
-
)
|
43
|
-
end
|
23
|
+
def resource_class = Decidim::Newsletter
|
24
|
+
|
25
|
+
def attributes = super.merge({ author: form.current_user })
|
44
26
|
|
45
|
-
def
|
46
|
-
ContentBlocks::UpdateContentBlock.call(form, content_block,
|
27
|
+
def run_after_hooks
|
28
|
+
ContentBlocks::UpdateContentBlock.call(form, content_block, form.current_user) do
|
47
29
|
on(:ok) do |content_block|
|
48
|
-
content_block.update(scoped_resource_id:
|
30
|
+
content_block.update(scoped_resource_id: resource.id)
|
49
31
|
@content_block = content_block
|
50
32
|
end
|
51
33
|
on(:invalid) do
|
@@ -5,14 +5,14 @@ module Decidim
|
|
5
5
|
# A command with all the business logic when creating a new participatory space
|
6
6
|
# private user in the system.
|
7
7
|
class CreateParticipatorySpacePrivateUser < Decidim::Command
|
8
|
+
delegate :current_user, to: :form
|
8
9
|
# Public: Initializes the command.
|
9
10
|
#
|
10
11
|
# form - A form object with the params.
|
11
12
|
# private_user_to - The private_user_to that will hold the
|
12
13
|
# user role
|
13
|
-
def initialize(form,
|
14
|
+
def initialize(form, private_user_to, via_csv: false)
|
14
15
|
@form = form
|
15
|
-
@current_user = current_user
|
16
16
|
@private_user_to = private_user_to
|
17
17
|
@via_csv = via_csv
|
18
18
|
end
|
@@ -39,7 +39,7 @@ module Decidim
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
-
attr_reader :form, :private_user_to, :
|
42
|
+
attr_reader :form, :private_user_to, :user
|
43
43
|
|
44
44
|
def create_private_user
|
45
45
|
action = @via_csv ? "create_via_csv" : "create"
|
@@ -2,50 +2,33 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
|
-
# A command with all the business logic when creating a
|
6
|
-
class CreateScope < Decidim::
|
5
|
+
# A command with all the business logic when creating a scope.
|
6
|
+
class CreateScope < Decidim::Commands::CreateResource
|
7
|
+
fetch_form_attributes :name, :organization, :code, :scope_type
|
7
8
|
# Public: Initializes the command.
|
8
9
|
#
|
9
10
|
# form - A form object with the params.
|
10
|
-
#
|
11
|
-
def initialize(form,
|
12
|
-
|
13
|
-
@
|
11
|
+
# parent - A parent scope for the scope to be created
|
12
|
+
def initialize(form, parent = nil)
|
13
|
+
super(form)
|
14
|
+
@parent = parent
|
14
15
|
end
|
15
16
|
|
16
|
-
|
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?
|
17
|
+
protected
|
24
18
|
|
25
|
-
|
26
|
-
broadcast(:ok)
|
27
|
-
end
|
19
|
+
attr_reader :parent
|
28
20
|
|
29
|
-
|
21
|
+
def resource_class = Decidim::Scope
|
30
22
|
|
31
|
-
|
23
|
+
def attributes = super.merge({ parent: })
|
32
24
|
|
33
|
-
def
|
34
|
-
|
35
|
-
Scope,
|
36
|
-
form.current_user,
|
37
|
-
{
|
38
|
-
name: form.name,
|
39
|
-
organization: form.organization,
|
40
|
-
code: form.code,
|
41
|
-
scope_type: form.scope_type,
|
42
|
-
parent: @parent_scope
|
43
|
-
},
|
25
|
+
def extra_params
|
26
|
+
{
|
44
27
|
extra: {
|
45
|
-
parent_name:
|
28
|
+
parent_name: parent.try(:name),
|
46
29
|
scope_type_name: form.scope_type.try(:name)
|
47
30
|
}
|
48
|
-
|
31
|
+
}
|
49
32
|
end
|
50
33
|
end
|
51
34
|
end
|
@@ -3,41 +3,12 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when creating a scope type.
|
6
|
-
class CreateScopeType < Decidim::
|
7
|
-
|
8
|
-
#
|
9
|
-
# form - A form object with the params.
|
10
|
-
def initialize(form, user)
|
11
|
-
@form = form
|
12
|
-
@user = 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
|
-
return broadcast(:invalid) if form.invalid?
|
23
|
-
|
24
|
-
create_scope_type
|
25
|
-
broadcast(:ok)
|
26
|
-
end
|
6
|
+
class CreateScopeType < Decidim::Commands::CreateResource
|
7
|
+
fetch_form_attributes :name, :organization, :plural
|
27
8
|
|
28
9
|
private
|
29
10
|
|
30
|
-
|
31
|
-
|
32
|
-
def create_scope_type
|
33
|
-
Decidim.traceability.create!(
|
34
|
-
ScopeType,
|
35
|
-
@user,
|
36
|
-
name: form.name,
|
37
|
-
organization: form.organization,
|
38
|
-
plural: form.plural
|
39
|
-
)
|
40
|
-
end
|
11
|
+
def resource_class = Decidim::ScopeType
|
41
12
|
end
|
42
13
|
end
|
43
14
|
end
|
@@ -3,56 +3,15 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when creating a static page.
|
6
|
-
class CreateStaticPage < Decidim::
|
7
|
-
|
8
|
-
#
|
9
|
-
# form - A form object with the params.
|
10
|
-
def initialize(form)
|
11
|
-
@form = form
|
12
|
-
@page = nil
|
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
|
-
return broadcast(:invalid) if form.invalid?
|
23
|
-
|
24
|
-
create_page
|
25
|
-
update_organization_tos_version
|
26
|
-
broadcast(:ok)
|
27
|
-
end
|
6
|
+
class CreateStaticPage < Decidim::Commands::CreateResource
|
7
|
+
fetch_form_attributes :organization, :title, :slug, :weight, :topic, :content, :allow_public_access
|
28
8
|
|
29
|
-
|
9
|
+
protected
|
30
10
|
|
31
|
-
|
32
|
-
|
33
|
-
def create_page
|
34
|
-
@page = Decidim.traceability.create!(
|
35
|
-
StaticPage,
|
36
|
-
form.current_user,
|
37
|
-
attributes
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
def attributes
|
42
|
-
{
|
43
|
-
organization: form.organization,
|
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 resource_class = Decidim::StaticPage
|
53
12
|
|
54
|
-
def
|
55
|
-
UpdateOrganizationTosVersion.call(
|
13
|
+
def run_after_hooks
|
14
|
+
UpdateOrganizationTosVersion.call(form.organization, resource, form)
|
56
15
|
end
|
57
16
|
end
|
58
17
|
end
|
@@ -3,34 +3,12 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
5
|
# A command with all the business logic when creating a static page topic.
|
6
|
-
class CreateStaticPageTopic < Decidim::
|
7
|
-
|
8
|
-
#
|
9
|
-
# form - A form object with the params.
|
10
|
-
def initialize(form)
|
11
|
-
@form = form
|
12
|
-
end
|
6
|
+
class CreateStaticPageTopic < Decidim::Commands::CreateResource
|
7
|
+
fetch_form_attributes :title, :description, :show_in_footer, :weight, :organization
|
13
8
|
|
14
|
-
|
15
|
-
#
|
16
|
-
# - :ok when everything is valid.
|
17
|
-
# - :invalid if the form was not valid and we could not proceed.
|
18
|
-
#
|
19
|
-
# Returns nothing.
|
20
|
-
def call
|
21
|
-
return broadcast(:invalid) if @form.invalid?
|
9
|
+
protected
|
22
10
|
|
23
|
-
|
24
|
-
StaticPageTopic,
|
25
|
-
@form.current_user,
|
26
|
-
title: @form.title,
|
27
|
-
description: @form.description,
|
28
|
-
organization: @form.current_organization,
|
29
|
-
show_in_footer: @form.show_in_footer,
|
30
|
-
weight: @form.weight
|
31
|
-
)
|
32
|
-
broadcast(:ok)
|
33
|
-
end
|
11
|
+
def resource_class = Decidim::StaticPageTopic
|
34
12
|
end
|
35
13
|
end
|
36
14
|
end
|
@@ -4,19 +4,18 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
# Delivers the newsletter to its recipients.
|
6
6
|
class DeliverNewsletter < Decidim::Command
|
7
|
+
delegate :current_user, to: :form
|
7
8
|
# Initializes the command.
|
8
9
|
#
|
9
10
|
# newsletter - The newsletter to deliver.
|
10
11
|
# form - A form object with the params.
|
11
|
-
|
12
|
-
def initialize(newsletter, form, user)
|
12
|
+
def initialize(newsletter, form)
|
13
13
|
@newsletter = newsletter
|
14
14
|
@form = form
|
15
|
-
@user = user
|
16
15
|
end
|
17
16
|
|
18
17
|
def call
|
19
|
-
return broadcast(:invalid) if @form.send_to_all_users &&
|
18
|
+
return broadcast(:invalid) if @form.send_to_all_users && !current_user.admin?
|
20
19
|
return broadcast(:invalid) unless @form.valid?
|
21
20
|
return broadcast(:invalid) if @newsletter.sent?
|
22
21
|
return broadcast(:no_recipients) if recipients.blank?
|
@@ -36,7 +35,7 @@ module Decidim
|
|
36
35
|
Decidim.traceability.perform_action!(
|
37
36
|
"deliver",
|
38
37
|
@newsletter,
|
39
|
-
|
38
|
+
current_user
|
40
39
|
) do
|
41
40
|
NewsletterJob.perform_later(@newsletter, @form.as_json, recipients.map(&:id))
|
42
41
|
end
|