decidim-admin 0.26.5 → 0.27.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/cells/decidim/admin/attachments_privacy_warning/show.erb +3 -0
- data/app/cells/decidim/admin/attachments_privacy_warning_cell.rb +19 -0
- data/app/commands/decidim/admin/block_user.rb +1 -1
- data/app/commands/decidim/admin/close_session_managed_user.rb +1 -1
- data/app/commands/decidim/admin/create_area.rb +1 -1
- data/app/commands/decidim/admin/create_area_type.rb +6 -3
- data/app/commands/decidim/admin/create_attachment.rb +14 -6
- data/app/commands/decidim/admin/create_attachment_collection.rb +13 -4
- data/app/commands/decidim/admin/create_category.rb +6 -4
- data/app/commands/decidim/admin/create_component.rb +1 -1
- data/app/commands/decidim/admin/create_import.rb +4 -5
- data/app/commands/decidim/admin/create_import_example.rb +1 -1
- data/app/commands/decidim/admin/create_newsletter.rb +1 -1
- data/app/commands/decidim/admin/create_participatory_space_private_user.rb +1 -1
- data/app/commands/decidim/admin/create_scope.rb +1 -1
- data/app/commands/decidim/admin/create_scope_type.rb +6 -3
- data/app/commands/decidim/admin/create_static_page.rb +1 -1
- data/app/commands/decidim/admin/create_static_page_topic.rb +1 -1
- data/app/commands/decidim/admin/deliver_newsletter.rb +6 -6
- data/app/commands/decidim/admin/destroy_area.rb +1 -1
- data/app/commands/decidim/admin/destroy_category.rb +6 -3
- data/app/commands/decidim/admin/destroy_component.rb +1 -1
- data/app/commands/decidim/admin/destroy_newsletter.rb +1 -1
- data/app/commands/decidim/admin/destroy_participatory_space_private_user.rb +1 -1
- data/app/commands/decidim/admin/destroy_scope.rb +1 -1
- data/app/commands/decidim/admin/destroy_share_token.rb +1 -1
- data/app/commands/decidim/admin/destroy_static_page.rb +1 -1
- data/app/commands/decidim/admin/destroy_static_page_topic.rb +1 -1
- data/app/commands/decidim/admin/hide_resource.rb +2 -2
- data/app/commands/decidim/admin/impersonate_user.rb +1 -1
- data/app/commands/decidim/admin/invite_admin.rb +1 -1
- data/app/commands/decidim/admin/officialize_user.rb +1 -1
- data/app/commands/decidim/admin/process_participatory_space_private_user_import_csv.rb +7 -3
- data/app/commands/decidim/admin/process_user_group_verification_csv.rb +8 -4
- data/app/commands/decidim/admin/promote_managed_user.rb +1 -1
- data/app/commands/decidim/admin/publish_component.rb +1 -1
- data/app/commands/decidim/admin/reject_user_group.rb +1 -1
- data/app/commands/decidim/admin/remove_admin.rb +1 -1
- data/app/commands/decidim/admin/reorder_content_blocks.rb +1 -1
- data/app/commands/decidim/admin/transfer_user.rb +1 -1
- data/app/commands/decidim/admin/unblock_user.rb +2 -2
- data/app/commands/decidim/admin/unhide_resource.rb +1 -1
- data/app/commands/decidim/admin/unofficialize_user.rb +1 -1
- data/app/commands/decidim/admin/unpublish_component.rb +1 -1
- data/app/commands/decidim/admin/unreport_resource.rb +1 -1
- data/app/commands/decidim/admin/unreport_user.rb +1 -1
- data/app/commands/decidim/admin/update_area.rb +1 -1
- data/app/commands/decidim/admin/update_area_type.rb +8 -3
- data/app/commands/decidim/admin/update_attachment.rb +4 -3
- data/app/commands/decidim/admin/update_attachment_collection.rb +8 -3
- data/app/commands/decidim/admin/update_category.rb +9 -5
- data/app/commands/decidim/admin/update_component.rb +8 -5
- data/app/commands/decidim/admin/update_component_permissions.rb +9 -6
- data/app/commands/decidim/admin/update_content_block.rb +1 -1
- data/app/commands/decidim/admin/update_external_domain_whitelist.rb +6 -3
- data/app/commands/decidim/admin/update_help_sections.rb +17 -3
- data/app/commands/decidim/admin/update_newsletter.rb +1 -1
- data/app/commands/decidim/admin/update_organization.rb +1 -1
- data/app/commands/decidim/admin/update_organization_appearance.rb +1 -1
- data/app/commands/decidim/admin/update_organization_tos_version.rb +1 -1
- data/app/commands/decidim/admin/update_resource_permissions.rb +2 -2
- data/app/commands/decidim/admin/update_scope.rb +1 -1
- data/app/commands/decidim/admin/update_scope_type.rb +8 -3
- data/app/commands/decidim/admin/update_static_page.rb +1 -1
- data/app/commands/decidim/admin/update_static_page_topic.rb +1 -1
- data/app/commands/decidim/admin/update_user_groups.rb +1 -1
- data/app/commands/decidim/admin/verify_user_group.rb +1 -1
- data/app/controllers/concerns/decidim/admin/filterable.rb +1 -1
- data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +3 -1
- data/app/controllers/decidim/admin/application_controller.rb +1 -0
- data/app/controllers/decidim/admin/area_types_controller.rb +6 -3
- data/app/controllers/decidim/admin/block_user_controller.rb +3 -3
- data/app/controllers/decidim/admin/categories_controller.rb +3 -3
- data/app/controllers/decidim/admin/component_permissions_controller.rb +1 -1
- data/app/controllers/decidim/admin/components/base_controller.rb +1 -0
- data/app/controllers/decidim/admin/components_controller.rb +1 -1
- data/app/controllers/decidim/admin/concerns/has_attachment_collections.rb +6 -3
- data/app/controllers/decidim/admin/concerns/has_attachments.rb +6 -3
- data/app/controllers/decidim/admin/concerns/has_private_users_csv_import.rb +7 -0
- data/app/controllers/decidim/admin/dashboard_controller.rb +4 -3
- data/app/controllers/decidim/admin/exports_controller.rb +4 -1
- data/app/controllers/decidim/admin/help_sections_controller.rb +1 -1
- data/app/controllers/decidim/admin/metrics_controller.rb +2 -1
- data/app/controllers/decidim/admin/moderations_controller.rb +9 -7
- data/app/controllers/decidim/admin/newsletter_templates_controller.rb +1 -1
- data/app/controllers/decidim/admin/newsletters_controller.rb +1 -1
- data/app/controllers/decidim/admin/organization_controller.rb +3 -4
- data/app/controllers/decidim/admin/organization_external_domain_whitelist_controller.rb +1 -1
- data/app/controllers/decidim/admin/reminders_controller.rb +61 -0
- data/app/controllers/decidim/admin/resource_permissions_controller.rb +3 -3
- data/app/controllers/decidim/admin/scope_types_controller.rb +6 -3
- data/app/controllers/decidim/admin/static_pages_controller.rb +1 -7
- data/app/forms/decidim/admin/block_user_form.rb +2 -2
- data/app/forms/decidim/admin/category_form.rb +1 -2
- data/app/forms/decidim/admin/component_form.rb +16 -7
- data/app/forms/decidim/admin/import_example_form.rb +1 -5
- data/app/forms/decidim/admin/import_form.rb +7 -10
- data/app/forms/decidim/admin/managed_user_promotion_form.rb +1 -1
- data/app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb +7 -4
- data/app/forms/decidim/admin/permission_form.rb +9 -8
- data/app/forms/decidim/admin/permissions_form.rb +1 -10
- data/app/forms/decidim/admin/user_group_csv_verification_form.rb +2 -2
- data/app/helpers/decidim/admin/bulk_actions_helper.rb +6 -5
- data/app/helpers/decidim/admin/moderations/reports_helper.rb +11 -2
- data/app/helpers/decidim/admin/reminders_helper.rb +12 -0
- data/app/helpers/decidim/admin/settings_helper.rb +11 -57
- data/app/models/decidim/admin/fake_newsletter.rb +0 -20
- data/app/packs/entrypoints/decidim_admin.js +3 -6
- data/app/packs/src/decidim/admin/admin_autocomplete.js +82 -0
- data/app/packs/src/decidim/admin/application.js +0 -16
- data/app/packs/src/decidim/admin/choose_language.js +9 -11
- data/app/packs/src/decidim/admin/dynamic_fields.component.js +0 -1
- data/app/packs/stylesheets/decidim/admin/_decidim.scss +0 -1
- data/app/packs/stylesheets/decidim/admin/modules/_autocomplete.scss +5 -0
- data/app/packs/stylesheets/decidim/admin/modules/_forms.scss +0 -6
- data/app/packs/stylesheets/decidim/admin/modules/_import_result.scss +10 -0
- data/app/packs/stylesheets/decidim/admin/modules/_modules.scss +3 -0
- data/app/packs/stylesheets/decidim/admin/modules/_upload_modal.scss +42 -0
- data/app/permissions/decidim/admin/permissions.rb +3 -32
- data/app/presenters/decidim/admin/dashboard_metric_charts_presenter.rb +3 -1
- data/app/queries/decidim/admin/active_users_counter.rb +1 -1
- data/app/queries/decidim/admin/newsletter_recipients.rb +2 -2
- data/app/queries/decidim/admin/user_filter.rb +1 -1
- data/app/queries/decidim/admin/user_groups_evaluation.rb +1 -1
- data/app/views/decidim/admin/attachments/index.html.erb +1 -0
- data/app/views/decidim/admin/categories/_form.html.erb +0 -4
- data/app/views/decidim/admin/categories/show.html.erb +1 -2
- data/app/views/decidim/admin/dashboard/show.html.erb +1 -1
- data/app/views/decidim/admin/imports/new.html.erb +1 -1
- data/app/views/decidim/admin/moderated_users/index.html.erb +1 -1
- data/app/views/decidim/admin/moderations/index.html.erb +4 -8
- data/app/views/decidim/admin/moderations/reports/index.html.erb +1 -5
- data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +5 -4
- 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 +20 -1
- data/app/views/decidim/admin/reminders/new.html.erb +21 -0
- data/app/views/decidim/admin/resource_permissions/edit.html.erb +1 -1
- data/app/views/decidim/admin/shared/_gallery.html.erb +6 -1
- data/app/views/decidim/admin/shared/_js-callout.html.erb +6 -0
- data/app/views/decidim/admin/users_statistics/_users_count.html.erb +2 -2
- data/app/views/layouts/decidim/admin/_application.html.erb +2 -0
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +28 -21
- data/config/locales/bg.yml +1 -0
- data/config/locales/ca.yml +27 -21
- data/config/locales/cs.yml +41 -33
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +23 -18
- data/config/locales/el.yml +2 -5
- data/config/locales/en.yml +22 -17
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +25 -19
- data/config/locales/es-PY.yml +25 -19
- data/config/locales/es.yml +27 -21
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +12 -35
- data/config/locales/fi-plain.yml +26 -20
- data/config/locales/fi.yml +28 -22
- data/config/locales/fr-CA.yml +25 -19
- data/config/locales/fr.yml +39 -33
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +17 -4
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +16 -188
- data/config/locales/id-ID.yml +2 -7
- data/config/locales/is-IS.yml +3 -8
- data/config/locales/it.yml +8 -6
- data/config/locales/ja.yml +23 -18
- data/config/locales/ko.yml +1 -0
- data/config/locales/lb.yml +2 -5
- data/config/locales/lt.yml +13 -141
- data/config/locales/lv.yml +2 -4
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +4 -67
- data/config/locales/no.yml +13 -10
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +21 -6
- data/config/locales/pt-BR.yml +4 -7
- data/config/locales/pt.yml +2 -5
- data/config/locales/ro-RO.yml +12 -27
- data/config/locales/ru.yml +2 -7
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +2 -4
- data/config/locales/sl.yml +1 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +1 -10
- data/config/locales/sv.yml +24 -18
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +2 -5
- data/config/locales/uk.yml +2 -6
- data/config/locales/val-ES.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +2 -4
- data/config/locales/zh-TW.yml +1 -0
- data/lib/decidim/admin/engine.rb +1 -12
- data/lib/decidim/admin/import/importer.rb +9 -7
- data/lib/decidim/admin/import/readers/json.rb +1 -1
- data/lib/decidim/admin/test/commands/create_attachment_collection_examples.rb +15 -2
- data/lib/decidim/admin/test/commands/create_category_examples.rb +16 -6
- data/lib/decidim/admin/test/commands/destroy_category_examples.rb +29 -1
- data/lib/decidim/admin/test/commands/update_attachment_collection_examples.rb +15 -2
- data/lib/decidim/admin/test/commands/update_category_examples.rb +16 -6
- data/lib/decidim/admin/test/filters_participatory_space_user_roles_examples.rb +4 -4
- data/lib/decidim/admin/test/filters_participatory_space_users_examples.rb +4 -4
- data/lib/decidim/admin/test/forms/category_form_examples.rb +1 -21
- data/lib/decidim/admin/test/manage_attachments_examples.rb +9 -2
- data/lib/decidim/admin/test/manage_categories_examples.rb +0 -10
- data/lib/decidim/admin/test/manage_component_permissions_examples.rb +0 -2
- data/lib/decidim/admin/test/manage_moderations_examples.rb +27 -79
- data/lib/decidim/admin/version.rb +1 -1
- metadata +22 -19
- data/app/packs/src/decidim/admin/autocomplete.component.js +0 -146
- data/app/packs/src/decidim/admin/autocomplete.component.test.js +0 -19
- data/app/packs/stylesheets/decidim/admin/components/_autocomplete_select.component.scss +0 -19
- data/config/locales/gn-PY.yml +0 -1
- data/config/locales/ka-GE.yml +0 -1
- data/config/locales/lo-LA.yml +0 -1
- data/config/locales/oc-FR.yml +0 -1
|
@@ -31,7 +31,7 @@ module Decidim
|
|
|
31
31
|
enforce_permission_to :create, :attachment_collection
|
|
32
32
|
@form = form(AttachmentCollectionForm).from_params(params, collection_for: collection_for)
|
|
33
33
|
|
|
34
|
-
CreateAttachmentCollection.call(@form, collection_for) do
|
|
34
|
+
CreateAttachmentCollection.call(@form, collection_for, current_user) do
|
|
35
35
|
on(:ok) do
|
|
36
36
|
flash[:notice] = I18n.t("attachment_collections.create.success", scope: "decidim.admin")
|
|
37
37
|
redirect_to action: :index
|
|
@@ -56,7 +56,7 @@ module Decidim
|
|
|
56
56
|
enforce_permission_to :update, :attachment_collection, attachment_collection: @attachment_collection
|
|
57
57
|
@form = form(AttachmentCollectionForm).from_params(params, collection_for: collection_for)
|
|
58
58
|
|
|
59
|
-
UpdateAttachmentCollection.call(@attachment_collection, @form) do
|
|
59
|
+
UpdateAttachmentCollection.call(@attachment_collection, @form, current_user) do
|
|
60
60
|
on(:ok) do
|
|
61
61
|
flash[:notice] = I18n.t("attachment_collections.update.success", scope: "decidim.admin")
|
|
62
62
|
redirect_to action: :index
|
|
@@ -78,7 +78,10 @@ module Decidim
|
|
|
78
78
|
def destroy
|
|
79
79
|
@attachment_collection = collection.find(params[:id])
|
|
80
80
|
enforce_permission_to :destroy, :attachment_collection, attachment_collection: @attachment_collection
|
|
81
|
-
|
|
81
|
+
|
|
82
|
+
Decidim.traceability.perform_action!("delete", @attachment_collection, current_user) do
|
|
83
|
+
@attachment_collection.destroy!
|
|
84
|
+
end
|
|
82
85
|
|
|
83
86
|
flash[:notice] = I18n.t("attachment_collections.destroy.success", scope: "decidim.admin")
|
|
84
87
|
|
|
@@ -31,7 +31,7 @@ module Decidim
|
|
|
31
31
|
enforce_permission_to :create, :attachment, attached_to: attached_to
|
|
32
32
|
@form = form(::Decidim::Admin::AttachmentForm).from_params(params, attached_to: attached_to)
|
|
33
33
|
|
|
34
|
-
CreateAttachment.call(@form, attached_to) do
|
|
34
|
+
CreateAttachment.call(@form, attached_to, current_user) do
|
|
35
35
|
on(:ok) do
|
|
36
36
|
flash[:notice] = I18n.t("attachments.create.success", scope: "decidim.admin")
|
|
37
37
|
redirect_to action: :index
|
|
@@ -56,7 +56,7 @@ module Decidim
|
|
|
56
56
|
enforce_permission_to :update, :attachment, attachment: attachment
|
|
57
57
|
@form = form(::Decidim::Admin::AttachmentForm).from_params(attachment_params, attached_to: attached_to)
|
|
58
58
|
|
|
59
|
-
UpdateAttachment.call(@attachment, @form) do
|
|
59
|
+
UpdateAttachment.call(@attachment, @form, current_user) do
|
|
60
60
|
on(:ok) do
|
|
61
61
|
flash[:notice] = I18n.t("attachments.update.success", scope: "decidim.admin")
|
|
62
62
|
redirect_to action: :index
|
|
@@ -78,7 +78,10 @@ module Decidim
|
|
|
78
78
|
def destroy
|
|
79
79
|
@attachment = collection.find(params[:id])
|
|
80
80
|
enforce_permission_to :destroy, :attachment, attachment: attachment
|
|
81
|
-
|
|
81
|
+
|
|
82
|
+
Decidim.traceability.perform_action!("delete", @attachment, current_user) do
|
|
83
|
+
@attachment.destroy!
|
|
84
|
+
end
|
|
82
85
|
|
|
83
86
|
flash[:notice] = I18n.t("attachments.destroy.success", scope: "decidim.admin")
|
|
84
87
|
|
|
@@ -18,6 +18,7 @@ module Decidim
|
|
|
18
18
|
def new
|
|
19
19
|
enforce_permission_to :csv_import, :space_private_user
|
|
20
20
|
@form = form(ParticipatorySpacePrivateUserCsvImportForm).from_params({}, privatable_to: privatable_to)
|
|
21
|
+
@count = Decidim::ParticipatorySpacePrivateUser.by_participatory_space(privatable_to).count
|
|
21
22
|
render template: "decidim/admin/participatory_space_private_users_csv_imports/new"
|
|
22
23
|
end
|
|
23
24
|
|
|
@@ -38,6 +39,12 @@ module Decidim
|
|
|
38
39
|
end
|
|
39
40
|
end
|
|
40
41
|
|
|
42
|
+
def destroy_all
|
|
43
|
+
enforce_permission_to :csv_import, :space_private_user
|
|
44
|
+
Decidim::ParticipatorySpacePrivateUser.by_participatory_space(privatable_to).delete_all
|
|
45
|
+
redirect_to new_participatory_space_private_users_csv_imports_path
|
|
46
|
+
end
|
|
47
|
+
|
|
41
48
|
# Public: Returns a String or Object that will be passed to `redirect_to` after
|
|
42
49
|
# importing private users. By default it redirects to the privatable_to.
|
|
43
50
|
#
|
|
@@ -27,7 +27,8 @@ module Decidim
|
|
|
27
27
|
def metrics_presenter
|
|
28
28
|
@metrics_presenter ||= Decidim::Admin::DashboardMetricChartsPresenter.new(
|
|
29
29
|
summary: true,
|
|
30
|
-
organization: current_organization
|
|
30
|
+
organization: current_organization,
|
|
31
|
+
view_context: view_context
|
|
31
32
|
)
|
|
32
33
|
end
|
|
33
34
|
|
|
@@ -37,10 +38,10 @@ module Decidim
|
|
|
37
38
|
last_month = Time.zone.today.prev_month
|
|
38
39
|
|
|
39
40
|
{
|
|
40
|
-
|
|
41
|
+
total_admins_last_day: users_count(last_day, true),
|
|
41
42
|
total_admins_last_week: users_count(last_week, true),
|
|
42
43
|
total_admins_last_month: users_count(last_month, true),
|
|
43
|
-
|
|
44
|
+
total_participants_last_day: users_count(last_day, false),
|
|
44
45
|
total_participants_last_week: users_count(last_week, false),
|
|
45
46
|
total_participants_last_month: users_count(last_month, false)
|
|
46
47
|
}
|
|
@@ -9,7 +9,10 @@ module Decidim
|
|
|
9
9
|
def create
|
|
10
10
|
enforce_permission_to :export, :component_data, component: component
|
|
11
11
|
name = params[:id]
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
Decidim.traceability.perform_action!("export_component", component, current_user, { name: name, format: params[:format] || default_format }) do
|
|
14
|
+
ExportJob.perform_later(current_user, component, name, params[:format] || default_format, params[:resource_id].presence)
|
|
15
|
+
end
|
|
13
16
|
|
|
14
17
|
flash[:notice] = t("decidim.admin.exports.notice")
|
|
15
18
|
|
|
@@ -25,7 +25,7 @@ module Decidim
|
|
|
25
25
|
params[:help_sections]
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
-
UpdateHelpSections.call(@form, current_organization) do
|
|
28
|
+
UpdateHelpSections.call(@form, current_organization, current_user) do
|
|
29
29
|
on(:ok) do
|
|
30
30
|
flash[:notice] = t("help_sections.success", scope: "decidim.admin")
|
|
31
31
|
redirect_to action: :show
|
|
@@ -14,7 +14,8 @@ module Decidim
|
|
|
14
14
|
def metrics_presenter
|
|
15
15
|
@metrics_presenter ||= Decidim::Admin::DashboardMetricChartsPresenter.new(
|
|
16
16
|
summary: false,
|
|
17
|
-
organization: current_organization
|
|
17
|
+
organization: current_organization,
|
|
18
|
+
view_context: view_context
|
|
18
19
|
)
|
|
19
20
|
end
|
|
20
21
|
end
|
|
@@ -67,16 +67,18 @@ module Decidim
|
|
|
67
67
|
|
|
68
68
|
private
|
|
69
69
|
|
|
70
|
+
def ransack_params
|
|
71
|
+
query_params[:q] || { s: "created_at desc" }
|
|
72
|
+
end
|
|
73
|
+
|
|
70
74
|
# Private: This method is used by the `Filterable` concern as the base query
|
|
71
75
|
# without applying filtering and/or sorting options.
|
|
72
76
|
def collection
|
|
73
|
-
@collection ||=
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
end
|
|
79
|
-
end
|
|
77
|
+
@collection ||= if params[:hidden]
|
|
78
|
+
participatory_space_moderations.hidden
|
|
79
|
+
else
|
|
80
|
+
participatory_space_moderations.not_hidden
|
|
81
|
+
end
|
|
80
82
|
end
|
|
81
83
|
|
|
82
84
|
# Private: Returns a collection of `Moderation` filtered and/or sorted by
|
|
@@ -15,7 +15,7 @@ module Decidim
|
|
|
15
15
|
def show; end
|
|
16
16
|
|
|
17
17
|
def preview
|
|
18
|
-
email = NewsletterMailer.newsletter(current_user, fake_newsletter
|
|
18
|
+
email = NewsletterMailer.newsletter(current_user, fake_newsletter)
|
|
19
19
|
Premailer::Rails::Hook.perform(email)
|
|
20
20
|
render html: email.html_part.body.decoded.html_safe
|
|
21
21
|
end
|
|
@@ -28,7 +28,7 @@ module Decidim
|
|
|
28
28
|
def preview
|
|
29
29
|
enforce_permission_to :read, :newsletter, newsletter: newsletter
|
|
30
30
|
|
|
31
|
-
email = NewsletterMailer.newsletter(current_user, newsletter
|
|
31
|
+
email = NewsletterMailer.newsletter(current_user, newsletter)
|
|
32
32
|
Premailer::Rails::Hook.perform(email)
|
|
33
33
|
render html: email.html_part.body.decoded.html_safe
|
|
34
34
|
end
|
|
@@ -15,7 +15,6 @@ module Decidim
|
|
|
15
15
|
def update
|
|
16
16
|
enforce_permission_to :update, :organization, organization: current_organization
|
|
17
17
|
@form = form(OrganizationForm).from_params(params)
|
|
18
|
-
@form.id = current_organization.id
|
|
19
18
|
|
|
20
19
|
UpdateOrganization.call(current_organization, @form) do
|
|
21
20
|
on(:ok) do
|
|
@@ -31,11 +30,11 @@ module Decidim
|
|
|
31
30
|
end
|
|
32
31
|
|
|
33
32
|
def users
|
|
34
|
-
search(current_organization.users
|
|
33
|
+
search(current_organization.users)
|
|
35
34
|
end
|
|
36
35
|
|
|
37
36
|
def user_entities
|
|
38
|
-
search(current_organization.user_entities
|
|
37
|
+
search(current_organization.user_entities)
|
|
39
38
|
end
|
|
40
39
|
|
|
41
40
|
private
|
|
@@ -52,7 +51,7 @@ module Decidim
|
|
|
52
51
|
query.where("email ILIKE ?", "%#{term}%")
|
|
53
52
|
)
|
|
54
53
|
end
|
|
55
|
-
render json: query.all.collect { |u| { value: u.id, label: "#{u.name} (@#{u.nickname})" } }
|
|
54
|
+
render json: query.all.collect { |u| { value: u.id, label: "#{u.name} (@#{u.nickname}) #{u.email}" } }
|
|
56
55
|
else
|
|
57
56
|
render json: []
|
|
58
57
|
end
|
|
@@ -16,7 +16,7 @@ module Decidim
|
|
|
16
16
|
enforce_permission_to :update, :organization, organization: current_organization
|
|
17
17
|
@form = form(OrganizationExternalDomainWhitelistForm).from_params(params)
|
|
18
18
|
|
|
19
|
-
UpdateExternalDomainWhitelist.call(@form, current_organization) do
|
|
19
|
+
UpdateExternalDomainWhitelist.call(@form, current_organization, current_user) do
|
|
20
20
|
on(:ok) do
|
|
21
21
|
flash[:notice] = t("domain_whitelist.update.success", scope: "decidim.admin")
|
|
22
22
|
redirect_to edit_organization_external_domain_whitelist_path
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Admin
|
|
5
|
+
class RemindersController < Admin::ApplicationController
|
|
6
|
+
include Decidim::ComponentPathHelper
|
|
7
|
+
|
|
8
|
+
helper_method :reminder_manifest
|
|
9
|
+
|
|
10
|
+
def new
|
|
11
|
+
enforce_permission_to :create, :reminder
|
|
12
|
+
|
|
13
|
+
@form = reminder_form_from_params(name: reminder_manifest.name)
|
|
14
|
+
render :new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def create
|
|
18
|
+
enforce_permission_to :create, :reminder
|
|
19
|
+
|
|
20
|
+
@form = reminder_form_from_params(params)
|
|
21
|
+
|
|
22
|
+
command_class.call(@form) do
|
|
23
|
+
on(:ok) do |reminders_queued|
|
|
24
|
+
flash[:notice] = t("decidim.admin.reminders.create.success", count: reminders_queued)
|
|
25
|
+
redirect_to manage_component_path(current_component)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
on(:invalid) do
|
|
29
|
+
flash.now[:alert] = t("decidim.admin.reminders.create.error")
|
|
30
|
+
render :new
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def reminder_form_from_params(params)
|
|
38
|
+
form(reminder_manifest.form_class).from_params(
|
|
39
|
+
params,
|
|
40
|
+
current_component: current_component
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def reminder_manifest
|
|
45
|
+
@reminder_manifest ||= Decidim.reminders_registry.for(reminder_name)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def reminder_name
|
|
49
|
+
params[:name]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def command_class
|
|
53
|
+
reminder_manifest.command_class
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def current_component
|
|
57
|
+
@current_component ||= current_participatory_space.components.find(params[:component_id])
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -47,8 +47,8 @@ module Decidim
|
|
|
47
47
|
def permission_forms
|
|
48
48
|
actions.inject({}) do |result, action|
|
|
49
49
|
form = PermissionForm.new(
|
|
50
|
-
authorization_handlers: authorizations_for(action),
|
|
51
|
-
|
|
50
|
+
authorization_handlers: authorizations_for(action).keys,
|
|
51
|
+
authorization_handlers_options: options_for(action)
|
|
52
52
|
)
|
|
53
53
|
|
|
54
54
|
result.update(action => form)
|
|
@@ -83,7 +83,7 @@ module Decidim
|
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
def manifest_name
|
|
86
|
-
@manifest_name ||= resource.
|
|
86
|
+
@manifest_name ||= resource.manifest.name
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
def permissions
|
|
@@ -21,7 +21,7 @@ module Decidim
|
|
|
21
21
|
enforce_permission_to :create, :scope_type
|
|
22
22
|
@form = form(ScopeTypeForm).from_params(params)
|
|
23
23
|
|
|
24
|
-
CreateScopeType.call(@form) do
|
|
24
|
+
CreateScopeType.call(@form, current_user) do
|
|
25
25
|
on(:ok) do
|
|
26
26
|
flash[:notice] = I18n.t("scope_types.create.success", scope: "decidim.admin")
|
|
27
27
|
redirect_to scope_types_path
|
|
@@ -43,7 +43,7 @@ module Decidim
|
|
|
43
43
|
enforce_permission_to :update, :scope_type, scope_type: scope_type
|
|
44
44
|
@form = form(ScopeTypeForm).from_params(params)
|
|
45
45
|
|
|
46
|
-
UpdateScopeType.call(scope_type, @form) do
|
|
46
|
+
UpdateScopeType.call(scope_type, @form, current_user) do
|
|
47
47
|
on(:ok) do
|
|
48
48
|
flash[:notice] = I18n.t("scope_types.update.success", scope: "decidim.admin")
|
|
49
49
|
redirect_to scope_types_path
|
|
@@ -58,7 +58,10 @@ module Decidim
|
|
|
58
58
|
|
|
59
59
|
def destroy
|
|
60
60
|
enforce_permission_to :destroy, :scope_type, scope_type: scope_type
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
Decidim.traceability.perform_action!("delete", scope_type, current_user) do
|
|
63
|
+
scope_type.destroy!
|
|
64
|
+
end
|
|
62
65
|
|
|
63
66
|
flash[:notice] = I18n.t("scope_types.destroy.success", scope: "decidim.admin")
|
|
64
67
|
|
|
@@ -82,13 +82,7 @@ module Decidim
|
|
|
82
82
|
form_params = params.to_unsafe_hash
|
|
83
83
|
form_params["static_page"] ||= {}
|
|
84
84
|
form_params["static_page"]["organization"] = current_organization
|
|
85
|
-
form_params["static_page"]["allow_public_access"] ||=
|
|
86
|
-
if page
|
|
87
|
-
page.allow_public_access
|
|
88
|
-
else
|
|
89
|
-
false
|
|
90
|
-
end
|
|
91
|
-
end
|
|
85
|
+
form_params["static_page"]["allow_public_access"] ||= page ? page.allow_public_access : false
|
|
92
86
|
|
|
93
87
|
return form_params unless page
|
|
94
88
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module Admin
|
|
5
|
-
# A form object used to
|
|
5
|
+
# A form object used to officialize users from the admin dashboard.
|
|
6
6
|
class BlockUserForm < Form
|
|
7
7
|
attribute :user_id, Integer
|
|
8
8
|
attribute :justification, String
|
|
@@ -15,7 +15,7 @@ module Decidim
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def user
|
|
18
|
-
@user ||= Decidim::
|
|
18
|
+
@user ||= Decidim::User.find_by(
|
|
19
19
|
id: user_id,
|
|
20
20
|
organization: current_organization
|
|
21
21
|
)
|
|
@@ -9,12 +9,11 @@ module Decidim
|
|
|
9
9
|
|
|
10
10
|
translatable_attribute :name, String
|
|
11
11
|
attribute :weight, Integer, default: 0
|
|
12
|
-
translatable_attribute :description, String
|
|
13
12
|
attribute :parent_id, Integer
|
|
14
13
|
|
|
15
14
|
mimic :category
|
|
16
15
|
|
|
17
|
-
validates :name,
|
|
16
|
+
validates :name, translatable_presence: true
|
|
18
17
|
validates :parent_id, inclusion: { in: :parent_categories_ids }, allow_blank: true
|
|
19
18
|
|
|
20
19
|
delegate :current_participatory_space, to: :context, prefix: false
|
|
@@ -21,10 +21,12 @@ module Decidim
|
|
|
21
21
|
|
|
22
22
|
attribute :settings, Object
|
|
23
23
|
attribute :default_step_settings, Object
|
|
24
|
-
attribute
|
|
24
|
+
attribute(:step_settings, { String => Object })
|
|
25
25
|
|
|
26
26
|
attribute :share_tokens, Array[ShareToken]
|
|
27
27
|
|
|
28
|
+
validate :validate_settings, :validate_step_settings
|
|
29
|
+
|
|
28
30
|
def settings?
|
|
29
31
|
settings.manifest.attributes.any?
|
|
30
32
|
end
|
|
@@ -39,13 +41,20 @@ module Decidim
|
|
|
39
41
|
|
|
40
42
|
private
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
def validate_settings
|
|
45
|
+
return unless errors.empty? && settings_errors_empty? # Preserves errors from custom validation methods
|
|
46
|
+
|
|
47
|
+
attributes.each do |key, value|
|
|
48
|
+
next unless value.respond_to?(:valid?)
|
|
49
|
+
|
|
50
|
+
errors.add(key, :invalid) unless value.valid?
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def validate_step_settings
|
|
55
|
+
return unless step_settings.respond_to?(:attributes)
|
|
45
56
|
|
|
46
|
-
|
|
47
|
-
step_settings.each_value.select { |attribute| attribute.respond_to?(:valid?) }
|
|
48
|
-
).all?(&:valid?)
|
|
57
|
+
errors.add(:step_settings, :invalid) unless step_settings.attributes.values.all? { |v| !v.respond_to?(:valid?) || v.valid? }
|
|
49
58
|
end
|
|
50
59
|
|
|
51
60
|
def settings_errors_empty?
|
|
@@ -5,9 +5,10 @@ module Decidim
|
|
|
5
5
|
class ImportForm < Form
|
|
6
6
|
ACCEPTED_MIME_TYPES = Decidim::Admin::Import::Readers::ACCEPTED_MIME_TYPES
|
|
7
7
|
include Decidim::HasUploadValidations
|
|
8
|
+
include Decidim::ProcessesFileLocally
|
|
8
9
|
|
|
9
10
|
attribute :name, String
|
|
10
|
-
attribute :file
|
|
11
|
+
attribute :file, Decidim::Attributes::Blob
|
|
11
12
|
|
|
12
13
|
validates :file, presence: true
|
|
13
14
|
validates :name, presence: true
|
|
@@ -16,7 +17,7 @@ module Decidim
|
|
|
16
17
|
validate :verify_import, if: -> { file.present? && accepted_mime_type? && !importer.invalid_file? }
|
|
17
18
|
|
|
18
19
|
def importer
|
|
19
|
-
@importer ||= importer_for(
|
|
20
|
+
@importer ||= importer_for(file, mime_type)
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
private
|
|
@@ -44,15 +45,11 @@ module Decidim
|
|
|
44
45
|
def verify_import
|
|
45
46
|
return if importer.verify
|
|
46
47
|
|
|
47
|
-
importer.errors.each do |
|
|
48
|
-
errors.add(:file, message)
|
|
48
|
+
importer.errors.each do |error|
|
|
49
|
+
errors.add(:file, error.message)
|
|
49
50
|
end
|
|
50
51
|
end
|
|
51
52
|
|
|
52
|
-
def file_path
|
|
53
|
-
file&.path
|
|
54
|
-
end
|
|
55
|
-
|
|
56
53
|
def mime_type
|
|
57
54
|
file&.content_type
|
|
58
55
|
end
|
|
@@ -61,9 +58,9 @@ module Decidim
|
|
|
61
58
|
manifest.creator
|
|
62
59
|
end
|
|
63
60
|
|
|
64
|
-
def importer_for(
|
|
61
|
+
def importer_for(path, mime_type)
|
|
65
62
|
Import::ImporterFactory.build(
|
|
66
|
-
|
|
63
|
+
path,
|
|
67
64
|
mime_type,
|
|
68
65
|
context: importer_context,
|
|
69
66
|
creator: creator_class
|
|
@@ -7,7 +7,7 @@ module Decidim
|
|
|
7
7
|
class ManagedUserPromotionForm < Form
|
|
8
8
|
attribute :email, String
|
|
9
9
|
|
|
10
|
-
validates :email, presence: true,
|
|
10
|
+
validates :email, presence: true, "valid_email_2/email": { disposable: true }
|
|
11
11
|
validate :unique_email
|
|
12
12
|
|
|
13
13
|
private
|
|
@@ -8,19 +8,22 @@ module Decidim
|
|
|
8
8
|
#
|
|
9
9
|
class ParticipatorySpacePrivateUserCsvImportForm < Form
|
|
10
10
|
include Decidim::HasUploadValidations
|
|
11
|
+
include Decidim::ProcessesFileLocally
|
|
11
12
|
|
|
12
|
-
attribute :file
|
|
13
|
+
attribute :file, Decidim::Attributes::Blob
|
|
13
14
|
attribute :user_name, String
|
|
14
15
|
attribute :email, String
|
|
15
16
|
|
|
16
|
-
validates :file, presence: true
|
|
17
|
+
validates :file, presence: true, file_content_type: { allow: ["text/csv"] }
|
|
17
18
|
validate :validate_csv
|
|
18
19
|
|
|
19
20
|
def validate_csv
|
|
20
21
|
return if file.blank?
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
process_file_locally(file) do |file_path|
|
|
24
|
+
CSV.foreach(file_path) do |_email, user_name|
|
|
25
|
+
errors.add(:user_name, :invalid) unless user_name.match?(UserBaseEntity::REGEXP_NAME)
|
|
26
|
+
end
|
|
24
27
|
end
|
|
25
28
|
end
|
|
26
29
|
end
|
|
@@ -4,15 +4,21 @@ module Decidim
|
|
|
4
4
|
module Admin
|
|
5
5
|
# This form handles permissions for a particular action in the admin panel.
|
|
6
6
|
class PermissionForm < Form
|
|
7
|
-
attribute :authorization_handlers,
|
|
8
|
-
attribute
|
|
7
|
+
attribute :authorization_handlers, Array[String]
|
|
8
|
+
attribute(:authorization_handlers_options, { String => Object })
|
|
9
|
+
|
|
10
|
+
def authorization_handlers
|
|
11
|
+
handlers = super || []
|
|
12
|
+
|
|
13
|
+
handlers.index_with { |name| { "options" => authorization_handler_options(name) } }
|
|
14
|
+
end
|
|
9
15
|
|
|
10
16
|
def authorization_handlers_names
|
|
11
17
|
authorization_handlers.keys.map(&:to_s)
|
|
12
18
|
end
|
|
13
19
|
|
|
14
20
|
def authorization_handler_options(handler_name)
|
|
15
|
-
|
|
21
|
+
authorization_handlers_options&.dig(handler_name.to_s) || {}
|
|
16
22
|
end
|
|
17
23
|
|
|
18
24
|
def manifest(handler_name)
|
|
@@ -33,11 +39,6 @@ module Decidim
|
|
|
33
39
|
def options_manifest(handler_name)
|
|
34
40
|
manifest(handler_name).options
|
|
35
41
|
end
|
|
36
|
-
|
|
37
|
-
def find_handler(handler_name)
|
|
38
|
-
authorization_handlers[handler_name.to_s] ||
|
|
39
|
-
authorization_handlers[handler_name.to_sym]
|
|
40
|
-
end
|
|
41
42
|
end
|
|
42
43
|
end
|
|
43
44
|
end
|
|
@@ -7,16 +7,7 @@ module Decidim
|
|
|
7
7
|
class PermissionsForm < Form
|
|
8
8
|
mimic :component_permissions
|
|
9
9
|
|
|
10
|
-
attribute
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
# Overriding Rectify::Form#form_attributes_valid? to preserve errors from custom method validations.
|
|
15
|
-
def form_attributes_valid?
|
|
16
|
-
return false unless errors.empty? && permissions.each_value.map(&:errors).all?(&:empty?)
|
|
17
|
-
|
|
18
|
-
super && permissions.values.all?(&:valid?)
|
|
19
|
-
end
|
|
10
|
+
attribute(:permissions, { String => PermissionForm })
|
|
20
11
|
end
|
|
21
12
|
end
|
|
22
13
|
end
|
|
@@ -7,9 +7,9 @@ module Decidim
|
|
|
7
7
|
class UserGroupCsvVerificationForm < Form
|
|
8
8
|
include Decidim::HasUploadValidations
|
|
9
9
|
|
|
10
|
-
attribute :file
|
|
10
|
+
attribute :file, Decidim::Attributes::Blob
|
|
11
11
|
|
|
12
|
-
validates :file, presence: true
|
|
12
|
+
validates :file, presence: true, file_content_type: { allow: ["text/csv"] }
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -3,10 +3,6 @@
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module Admin
|
|
5
5
|
module BulkActionsHelper
|
|
6
|
-
def proposal_find(id)
|
|
7
|
-
Decidim::Proposals::Proposal.find(id)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
6
|
# Public: Generates a select field with the categories. Only leaf categories can be set as selected.
|
|
11
7
|
#
|
|
12
8
|
# categories - A collection of categories.
|
|
@@ -14,8 +10,9 @@ module Decidim
|
|
|
14
10
|
# Returns a String.
|
|
15
11
|
def bulk_categories_select(collection)
|
|
16
12
|
categories = bulk_categories_for_select collection
|
|
13
|
+
disabled = bulk_disabled_categories_for collection
|
|
17
14
|
prompt = t("decidim.proposals.admin.proposals.index.change_category")
|
|
18
|
-
select(:category, :id, options_for_select(categories, selected: []), prompt: prompt)
|
|
15
|
+
select(:category, :id, options_for_select(categories, selected: [], disabled: disabled), prompt: prompt)
|
|
19
16
|
end
|
|
20
17
|
|
|
21
18
|
def bulk_categories_for_select(scope)
|
|
@@ -38,6 +35,10 @@ module Decidim
|
|
|
38
35
|
end
|
|
39
36
|
end
|
|
40
37
|
|
|
38
|
+
def bulk_disabled_categories_for(scope)
|
|
39
|
+
scope.first_class.joins(:subcategories).pluck(:id)
|
|
40
|
+
end
|
|
41
|
+
|
|
41
42
|
# Public: Generates a select field with the components.
|
|
42
43
|
#
|
|
43
44
|
# siblings - A collection of components.
|