decidim-admin 0.15.2 → 0.16.0
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.
Potentially problematic release.
This version of decidim-admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/config/decidim_admin_manifest.js +1 -0
- data/app/assets/javascripts/decidim/admin/welcome_notification.js.es6 +32 -0
- data/app/assets/stylesheets/decidim/admin/modules/_forms.scss +21 -0
- data/app/commands/decidim/admin/create_attachment.rb +1 -1
- data/app/commands/decidim/admin/create_static_page.rb +3 -0
- data/app/commands/decidim/admin/create_static_page_topic.rb +36 -0
- data/app/commands/decidim/admin/destroy_static_page_topic.rb +40 -0
- data/app/commands/decidim/admin/officialize_user.rb +1 -1
- data/app/commands/decidim/admin/process_user_group_verification_csv.rb +42 -0
- data/app/commands/decidim/admin/publish_component.rb +1 -1
- data/app/commands/decidim/admin/update_help_sections.rb +26 -0
- data/app/commands/decidim/admin/update_organization.rb +10 -1
- data/app/commands/decidim/admin/update_static_page.rb +3 -0
- data/app/commands/decidim/admin/update_static_page_topic.rb +51 -0
- data/app/commands/decidim/admin/verify_user_group.rb +4 -2
- data/app/controllers/concerns/decidim/admin/user_groups.rb +24 -0
- data/app/controllers/decidim/admin/help_sections_controller.rb +52 -0
- data/app/controllers/decidim/admin/impersonations_controller.rb +1 -1
- data/app/controllers/decidim/admin/static_page_topics_controller.rb +73 -0
- data/app/controllers/decidim/admin/static_pages_controller.rb +4 -1
- data/app/controllers/decidim/admin/user_groups_controller.rb +4 -0
- data/app/controllers/decidim/admin/user_groups_csv_verifications_controller.rb +36 -0
- data/app/events/decidim/attachment_created_event.rb +7 -0
- data/app/forms/decidim/admin/help_section_form.rb +25 -0
- data/app/forms/decidim/admin/help_sections_form.rb +11 -0
- data/app/forms/decidim/admin/organization_form.rb +9 -0
- data/app/forms/decidim/admin/static_page_form.rb +16 -0
- data/app/forms/decidim/admin/static_page_topic_form.rb +19 -0
- data/app/forms/decidim/admin/user_group_csv_verification_form.rb +13 -0
- data/app/jobs/decidim/admin/verify_user_group_from_csv_job.rb +29 -0
- data/app/permissions/decidim/admin/permissions.rb +2 -0
- data/app/views/decidim/admin/help_sections/_form.html.erb +21 -0
- data/app/views/decidim/admin/help_sections/show.erb +1 -0
- data/app/views/decidim/admin/help_sections/update.html.erb +1 -0
- data/app/views/decidim/admin/officializations/index.html.erb +1 -1
- data/app/views/decidim/admin/organization/_form.html.erb +22 -0
- data/app/views/decidim/admin/static_page_topics/_form.html.erb +15 -0
- data/app/views/decidim/admin/static_page_topics/edit.html.erb +13 -0
- data/app/views/decidim/admin/static_page_topics/new.html.erb +13 -0
- data/app/views/decidim/admin/static_pages/_form.html.erb +12 -0
- data/app/views/decidim/admin/static_pages/_topic.html.erb +61 -0
- data/app/views/decidim/admin/static_pages/index.html.erb +6 -48
- data/app/views/decidim/admin/user_groups/index.html.erb +4 -1
- data/app/views/decidim/admin/user_groups_csv_verifications/new.html.erb +19 -0
- data/app/views/layouts/decidim/admin/pages.html.erb +1 -0
- data/app/views/layouts/decidim/admin/settings.html.erb +3 -0
- data/app/views/layouts/decidim/admin/users.html.erb +3 -2
- data/config/locales/ca.yml +56 -3
- data/config/locales/de.yml +56 -3
- data/config/locales/en.yml +56 -3
- data/config/locales/es-PY.yml +56 -3
- data/config/locales/es.yml +56 -3
- data/config/locales/eu.yml +56 -3
- data/config/locales/fi-pl.yml +56 -3
- data/config/locales/fi.yml +56 -3
- data/config/locales/fr.yml +56 -3
- data/config/locales/gl.yml +56 -3
- data/config/locales/hu.yml +56 -3
- data/config/locales/id-ID.yml +56 -3
- data/config/locales/it.yml +56 -3
- data/config/locales/nl.yml +56 -3
- data/config/locales/pl.yml +56 -3
- data/config/locales/pt-BR.yml +56 -3
- data/config/locales/pt.yml +56 -3
- data/config/locales/ru.yml +0 -3
- data/config/locales/sv.yml +56 -3
- data/config/locales/tr-TR.yml +56 -3
- data/config/locales/uk.yml +0 -3
- data/config/routes.rb +6 -0
- data/lib/decidim/admin/engine.rb +4 -1
- data/lib/decidim/admin/version.rb +1 -1
- metadata +32 -11
- data/app/events/decidim/participatory_process_step_activated_event.rb +0 -23
- data/app/events/decidim/participatory_process_step_changed_event.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 319f13954e9485d30b04176489e14580c36df8228c2b5981b3300599379c6a4f
|
4
|
+
data.tar.gz: e0861279a3252585971caae115060e4cab7451912b3a0a93efac8f203672a4cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff39ad46211f78e2743d94afca02d1b37bee664aee978c3f510b94e7094a0e10d5d89bf752ffd0087e58df63116b5ccc4fd6fae3601f7498cfcd9424fa80bf5d
|
7
|
+
data.tar.gz: 10035ee1834ec7d5bc8af8540fda203615adce5dd40b6ca30ca4843b798c248692f6861174a89df17b72387ecc37715bea0f2f9391bd6a35e17ab2dee1af3e04
|
@@ -0,0 +1,32 @@
|
|
1
|
+
(() => {
|
2
|
+
const $scope = $("#welcome-notification-details");
|
3
|
+
|
4
|
+
const $sendNotificationCheckbox = $(
|
5
|
+
"#organization_send_welcome_notification",
|
6
|
+
$scope
|
7
|
+
);
|
8
|
+
|
9
|
+
const $customizeCheckbox = $(
|
10
|
+
"#organization_customize_welcome_notification",
|
11
|
+
$scope
|
12
|
+
);
|
13
|
+
|
14
|
+
const toggleVisibility = () => {
|
15
|
+
if ($sendNotificationCheckbox.is(":checked")) {
|
16
|
+
$(".send-welcome-notification-details", $scope).show();
|
17
|
+
} else {
|
18
|
+
$(".send-welcome-notification-details", $scope).hide();
|
19
|
+
}
|
20
|
+
|
21
|
+
if ($customizeCheckbox.is(":checked")) {
|
22
|
+
$(".customize-welcome-notification-details", $scope).show();
|
23
|
+
} else {
|
24
|
+
$(".customize-welcome-notification-details", $scope).hide();
|
25
|
+
}
|
26
|
+
};
|
27
|
+
|
28
|
+
$($sendNotificationCheckbox).click(() => toggleVisibility());
|
29
|
+
$($customizeCheckbox).click(() => toggleVisibility());
|
30
|
+
|
31
|
+
toggleVisibility();
|
32
|
+
})();
|
@@ -1,4 +1,5 @@
|
|
1
1
|
$input-margin: 1.5rem;
|
2
|
+
$checkboxes-minimum-width: 200px;
|
2
3
|
|
3
4
|
button,
|
4
5
|
input,
|
@@ -94,3 +95,23 @@ textarea{
|
|
94
95
|
.is-custom-error-visible{
|
95
96
|
display: block;
|
96
97
|
}
|
98
|
+
|
99
|
+
.checkboxes{
|
100
|
+
margin-bottom: 1rem;
|
101
|
+
display: flex;
|
102
|
+
flex-wrap: wrap;
|
103
|
+
justify-content: space-between;
|
104
|
+
|
105
|
+
&::after{ /* Align last row to left */
|
106
|
+
min-width: $checkboxes-minimum-width;
|
107
|
+
content: "";
|
108
|
+
}
|
109
|
+
|
110
|
+
label{
|
111
|
+
min-width: $checkboxes-minimum-width;
|
112
|
+
|
113
|
+
input[type=checkbox]{
|
114
|
+
vertical-align: baseline;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
@@ -57,7 +57,7 @@ module Decidim
|
|
57
57
|
event: "decidim.events.attachments.attachment_created",
|
58
58
|
event_class: Decidim::AttachmentCreatedEvent,
|
59
59
|
resource: @attachment,
|
60
|
-
|
60
|
+
followers: @attachment.attached_to.followers
|
61
61
|
)
|
62
62
|
end
|
63
63
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic when creating a static page topic.
|
6
|
+
class CreateStaticPageTopic < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - A form object with the params.
|
10
|
+
def initialize(form)
|
11
|
+
@form = form
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes the command. Broadcasts these events:
|
15
|
+
#
|
16
|
+
# - :ok when everything is valid.
|
17
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
18
|
+
#
|
19
|
+
# Returns nothing.
|
20
|
+
def call
|
21
|
+
return broadcast(:invalid) if @form.invalid?
|
22
|
+
|
23
|
+
@topic = Decidim.traceability.create!(
|
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
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# This command deals with destroying a StaticPageTopic from the admin panel.
|
6
|
+
class DestroyStaticPageTopic < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# page - The StaticPageTopic to be destroyed.
|
10
|
+
def initialize(_topic, current_user)
|
11
|
+
@topic = page
|
12
|
+
@current_user = current_user
|
13
|
+
end
|
14
|
+
|
15
|
+
# Public: Executes the command.
|
16
|
+
#
|
17
|
+
# Broadcasts :ok if it got destroyed
|
18
|
+
def call
|
19
|
+
destroy_topic
|
20
|
+
broadcast(:ok)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :page, :current_user
|
26
|
+
|
27
|
+
def destroy_page
|
28
|
+
transaction do
|
29
|
+
Decidim.traceability.perform_action!(
|
30
|
+
"delete",
|
31
|
+
topic,
|
32
|
+
current_user
|
33
|
+
) do
|
34
|
+
topic.destroy!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "csv"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Admin
|
7
|
+
# A command with all the business logic when processing the CSV to verify
|
8
|
+
# user groups.
|
9
|
+
class ProcessUserGroupVerificationCsv < Rectify::Command
|
10
|
+
# Public: Initializes the command.
|
11
|
+
#
|
12
|
+
# form - the form object containing the uploaded file
|
13
|
+
def initialize(form)
|
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 wasn't valid and we couldn't proceed.
|
21
|
+
#
|
22
|
+
# Returns nothing.
|
23
|
+
def call
|
24
|
+
return broadcast(:invalid) unless @form.valid?
|
25
|
+
process_csv
|
26
|
+
broadcast(:ok)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def process_csv
|
32
|
+
verifier = @form.current_user
|
33
|
+
organization = @form.current_organization
|
34
|
+
|
35
|
+
CSV.foreach(@form.file.path) do |row|
|
36
|
+
email = row[0]
|
37
|
+
VerifyUserGroupFromCsvJob.perform_later(email, verifier, organization) if email.present?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -44,7 +44,7 @@ module Decidim
|
|
44
44
|
event: "decidim.events.components.component_published",
|
45
45
|
event_class: Decidim::ComponentPublishedEvent,
|
46
46
|
resource: component,
|
47
|
-
|
47
|
+
followers: component.participatory_space.followers
|
48
48
|
)
|
49
49
|
end
|
50
50
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# This command gets called when a content block is updated from the admin
|
6
|
+
# panel.
|
7
|
+
class UpdateHelpSections < Rectify::Command
|
8
|
+
def initialize(form, organization)
|
9
|
+
@form = form
|
10
|
+
@organization = organization
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
return broadcast(:invalid) unless @form.valid?
|
15
|
+
|
16
|
+
ActiveRecord::Base.transaction do
|
17
|
+
@form.sections.each do |section|
|
18
|
+
ContextualHelpSection.set_content(@organization, section.id, section.content)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
broadcast(:ok)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -49,7 +49,16 @@ module Decidim
|
|
49
49
|
instagram_handler: form.instagram_handler,
|
50
50
|
youtube_handler: form.youtube_handler,
|
51
51
|
github_handler: form.github_handler,
|
52
|
-
badges_enabled: form.badges_enabled
|
52
|
+
badges_enabled: form.badges_enabled,
|
53
|
+
user_groups_enabled: form.user_groups_enabled
|
54
|
+
}.merge(welcome_notification_attributes)
|
55
|
+
end
|
56
|
+
|
57
|
+
def welcome_notification_attributes
|
58
|
+
{
|
59
|
+
send_welcome_notification: form.send_welcome_notification,
|
60
|
+
welcome_notification_subject: form.customize_welcome_notification ? form.welcome_notification_subject : nil,
|
61
|
+
welcome_notification_body: form.customize_welcome_notification ? form.welcome_notification_body : nil
|
53
62
|
}
|
54
63
|
end
|
55
64
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic when updating a static page topic.
|
6
|
+
class UpdateStaticPageTopic < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
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 wasn't valid and we couldn't 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
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -8,9 +8,10 @@ module Decidim
|
|
8
8
|
#
|
9
9
|
# user_group - The user_group to verify
|
10
10
|
# current_user - the user performing the action
|
11
|
-
def initialize(user_group, current_user)
|
11
|
+
def initialize(user_group, current_user, via_csv = false)
|
12
12
|
@user_group = user_group
|
13
13
|
@current_user = current_user
|
14
|
+
@via_csv = via_csv
|
14
15
|
end
|
15
16
|
|
16
17
|
# Executes the command. Broadcasts these events:
|
@@ -27,8 +28,9 @@ module Decidim
|
|
27
28
|
private
|
28
29
|
|
29
30
|
def verify_user_group
|
31
|
+
action = @via_csv ? "verify_via_csv" : "verify"
|
30
32
|
Decidim.traceability.perform_action!(
|
31
|
-
|
33
|
+
action,
|
32
34
|
@user_group,
|
33
35
|
@current_user
|
34
36
|
) do
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Admin
|
7
|
+
# The UserGroups concern must be included in all controllers related
|
8
|
+
# to UserGroups feature. It adds a method to enforce that the feature
|
9
|
+
# is enabled.
|
10
|
+
module UserGroups
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
|
13
|
+
included do
|
14
|
+
delegate :user_groups_enabled?, to: :current_organization
|
15
|
+
|
16
|
+
helper_method :user_groups_enabled?
|
17
|
+
end
|
18
|
+
|
19
|
+
def enforce_user_groups_enabled
|
20
|
+
raise Decidim::ActionForbidden unless current_organization.user_groups_enabled?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# Controller that allows managing the user organization.
|
6
|
+
#
|
7
|
+
class HelpSectionsController < Decidim::Admin::ApplicationController
|
8
|
+
layout "decidim/admin/settings"
|
9
|
+
include TranslationsHelper
|
10
|
+
|
11
|
+
helper_method :sections
|
12
|
+
|
13
|
+
before_action do
|
14
|
+
enforce_permission_to :update, :help_sections
|
15
|
+
end
|
16
|
+
|
17
|
+
def show
|
18
|
+
@form = form(HelpSectionsForm).from_model(
|
19
|
+
OpenStruct.new(sections: sections)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
@form = form(HelpSectionsForm).from_params(
|
25
|
+
params[:help_sections]
|
26
|
+
)
|
27
|
+
|
28
|
+
UpdateHelpSections.call(@form, current_organization) do
|
29
|
+
on(:ok) do
|
30
|
+
flash[:notice] = t("help_sections.success", scope: "decidim.admin")
|
31
|
+
redirect_to action: :show
|
32
|
+
end
|
33
|
+
|
34
|
+
on(:invalid) do
|
35
|
+
flash.now[:alert] = t("help_sections.error", scope: "decidim.admin")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def sections
|
43
|
+
@sections ||= Decidim.participatory_space_manifests.map do |manifest|
|
44
|
+
OpenStruct.new(
|
45
|
+
id: manifest.name.to_s,
|
46
|
+
content: ContextualHelpSection.find_content(current_organization, manifest.name)
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|