decidim-admin 0.6.8 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim-admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/decidim/admin/modules/_table-list.scss +1 -0
- data/app/commands/decidim/admin/close_session_managed_user.rb +1 -1
- data/app/commands/decidim/admin/reject_user_group.rb +1 -1
- data/app/commands/decidim/admin/update_feature.rb +1 -1
- data/app/commands/decidim/admin/update_organization.rb +5 -26
- data/app/commands/decidim/admin/update_organization_appearance.rb +72 -0
- data/app/commands/decidim/admin/verify_user_group.rb +1 -1
- data/app/controllers/decidim/admin/organization_appearance_controller.rb +32 -0
- data/app/controllers/decidim/admin/organization_controller.rb +1 -15
- data/app/controllers/decidim/admin/scopes_controller.rb +2 -2
- data/app/controllers/decidim/admin/static_pages_controller.rb +1 -1
- data/app/forms/decidim/admin/organization_appearance_form.rb +41 -0
- data/app/forms/decidim/admin/organization_form.rb +0 -23
- data/app/forms/decidim/admin/scope_form.rb +3 -2
- data/app/forms/decidim/admin/static_page_form.rb +2 -1
- data/app/jobs/decidim/admin/newsletter_delivery_job.rb +2 -0
- data/app/models/decidim/admin/abilities/admin_ability.rb +2 -1
- data/app/views/decidim/admin/exports/_dropdown.html.erb +2 -2
- data/app/views/decidim/admin/organization/_form.html.erb +0 -45
- data/app/views/decidim/admin/organization/edit.html.erb +1 -1
- data/app/views/decidim/admin/organization_appearance/_form.html.erb +78 -0
- data/app/views/decidim/admin/organization_appearance/edit.html.erb +7 -0
- data/app/views/layouts/decidim/admin/_title_bar.html.erb +1 -1
- data/app/views/layouts/decidim/admin/settings.html.erb +4 -1
- data/config/locales/ca.yml +25 -8
- data/config/locales/en.yml +22 -5
- data/config/locales/es.yml +24 -7
- data/config/locales/eu.yml +37 -20
- data/config/locales/fi.yml +36 -19
- data/config/locales/fr.yml +30 -13
- data/config/locales/it.yml +22 -5
- data/config/locales/nl.yml +22 -5
- data/config/locales/pl.yml +22 -5
- data/config/locales/ru.yml +468 -0
- data/config/locales/uk.yml +61 -44
- data/config/routes.rb +3 -1
- data/lib/decidim/admin/engine.rb +1 -1
- data/lib/decidim/admin/version.rb +10 -0
- metadata +19 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1eef3366bf3923dc3a182dd47ded1793fc4e45f
|
4
|
+
data.tar.gz: 3703c4263bd73e9636c2b6b6299667483282def8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 952ea7070267a85a63cfd0d2b5622d4743eade8be84d749e6e21131a4ae7f1d58157a481c05dfaf4d5b1730dcff9def21a373879a55f8cbb4333ed8b73c5f0dc
|
7
|
+
data.tar.gz: 76a770ac9c0585b06043ce084326d5cf0d614bf400f06ea70f520a666ea8d3194333c4889557055ba647b46c886519c46add8219e34f07586826470c8400c76a
|
@@ -23,15 +23,8 @@ module Decidim
|
|
23
23
|
def call
|
24
24
|
return broadcast(:invalid) if form.invalid?
|
25
25
|
|
26
|
-
update_organization
|
27
|
-
|
28
|
-
if @organization.valid?
|
29
|
-
broadcast(:ok, @organization)
|
30
|
-
else
|
31
|
-
form.errors.add(:official_img_header, @organization.errors[:official_img_header]) if @organization.errors.include? :official_img_header
|
32
|
-
form.errors.add(:official_img_footer, @organization.errors[:official_img_footer]) if @organization.errors.include? :official_img_footer
|
33
|
-
broadcast(:invalid)
|
34
|
-
end
|
26
|
+
return broadcast(:ok, @organization) if update_organization
|
27
|
+
broadcast(:invalid)
|
35
28
|
end
|
36
29
|
|
37
30
|
private
|
@@ -46,27 +39,13 @@ module Decidim
|
|
46
39
|
def attributes
|
47
40
|
{
|
48
41
|
name: form.name,
|
42
|
+
default_locale: form.default_locale,
|
43
|
+
reference_prefix: form.reference_prefix,
|
49
44
|
twitter_handler: form.twitter_handler,
|
50
45
|
facebook_handler: form.facebook_handler,
|
51
46
|
instagram_handler: form.instagram_handler,
|
52
47
|
youtube_handler: form.youtube_handler,
|
53
|
-
github_handler: form.github_handler
|
54
|
-
description: form.description,
|
55
|
-
welcome_text: form.welcome_text,
|
56
|
-
homepage_image: form.homepage_image,
|
57
|
-
remove_homepage_image: form.remove_homepage_image,
|
58
|
-
logo: form.logo,
|
59
|
-
remove_logo: form.remove_logo,
|
60
|
-
favicon: form.favicon,
|
61
|
-
remove_favicon: form.remove_favicon,
|
62
|
-
default_locale: form.default_locale,
|
63
|
-
official_img_header: form.official_img_header,
|
64
|
-
remove_official_img_header: form.remove_official_img_header,
|
65
|
-
official_img_footer: form.official_img_footer,
|
66
|
-
remove_official_img_footer: form.remove_official_img_footer,
|
67
|
-
official_url: form.official_url,
|
68
|
-
header_snippets: form.header_snippets,
|
69
|
-
show_statistics: form.show_statistics
|
48
|
+
github_handler: form.github_handler
|
70
49
|
}
|
71
50
|
end
|
72
51
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic for updating the current
|
6
|
+
# organization appearance.
|
7
|
+
class UpdateOrganizationAppearance < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# organization - The Organization that will be updated.
|
11
|
+
# form - A form object with the params.
|
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 wasn't valid and we couldn't proceed.
|
21
|
+
#
|
22
|
+
# Returns nothing.
|
23
|
+
def call
|
24
|
+
return broadcast(:invalid) if form.invalid?
|
25
|
+
|
26
|
+
update_organization
|
27
|
+
|
28
|
+
if @organization.valid?
|
29
|
+
broadcast(:ok, @organization)
|
30
|
+
else
|
31
|
+
form.errors.add(:official_img_header, @organization.errors[:official_img_header]) if @organization.errors.include? :official_img_header
|
32
|
+
form.errors.add(:official_img_footer, @organization.errors[:official_img_footer]) if @organization.errors.include? :official_img_footer
|
33
|
+
broadcast(:invalid)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
attr_reader :form, :organization
|
40
|
+
|
41
|
+
def update_organization
|
42
|
+
@organization.assign_attributes(attributes)
|
43
|
+
@organization.save! if @organization.valid?
|
44
|
+
end
|
45
|
+
|
46
|
+
def attributes
|
47
|
+
{
|
48
|
+
cta_button_path: form.cta_button_path,
|
49
|
+
cta_button_text: form.cta_button_text,
|
50
|
+
description: form.description,
|
51
|
+
welcome_text: form.welcome_text,
|
52
|
+
homepage_image: form.homepage_image,
|
53
|
+
remove_homepage_image: form.remove_homepage_image,
|
54
|
+
logo: form.logo,
|
55
|
+
remove_logo: form.remove_logo,
|
56
|
+
favicon: form.favicon,
|
57
|
+
remove_favicon: form.remove_favicon,
|
58
|
+
official_img_header: form.official_img_header,
|
59
|
+
remove_official_img_header: form.remove_official_img_header,
|
60
|
+
official_img_footer: form.official_img_footer,
|
61
|
+
remove_official_img_footer: form.remove_official_img_footer,
|
62
|
+
official_url: form.official_url,
|
63
|
+
show_statistics: form.show_statistics
|
64
|
+
}.tap do |attributes|
|
65
|
+
if Decidim.enable_html_header_snippets
|
66
|
+
attributes[:header_snippets] = form.header_snippets
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# Controller that allows managing the appearance of the organization.
|
6
|
+
class OrganizationAppearanceController < Decidim::Admin::ApplicationController
|
7
|
+
layout "decidim/admin/settings"
|
8
|
+
|
9
|
+
def edit
|
10
|
+
authorize! :update, current_organization
|
11
|
+
@form = form(OrganizationAppearanceForm).from_model(current_organization)
|
12
|
+
end
|
13
|
+
|
14
|
+
def update
|
15
|
+
authorize! :update, current_organization
|
16
|
+
@form = form(OrganizationAppearanceForm).from_params(params)
|
17
|
+
|
18
|
+
UpdateOrganizationAppearance.call(current_organization, @form) do
|
19
|
+
on(:ok) do
|
20
|
+
flash[:notice] = I18n.t("organization.update.success", scope: "decidim.admin")
|
21
|
+
redirect_to edit_organization_appearance_path
|
22
|
+
end
|
23
|
+
|
24
|
+
on(:invalid) do
|
25
|
+
flash.now[:alert] = I18n.t("organization.update.error", scope: "decidim.admin")
|
26
|
+
render :edit
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -14,7 +14,7 @@ module Decidim
|
|
14
14
|
|
15
15
|
def update
|
16
16
|
authorize! :update, current_organization
|
17
|
-
@form = form(OrganizationForm).from_params(
|
17
|
+
@form = form(OrganizationForm).from_params(params)
|
18
18
|
|
19
19
|
UpdateOrganization.call(current_organization, @form) do
|
20
20
|
on(:ok) do
|
@@ -28,20 +28,6 @@ module Decidim
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def organization_params
|
35
|
-
params[:organization] ||= {}
|
36
|
-
params[:organization][:id] ||= current_organization.id
|
37
|
-
{
|
38
|
-
homepage_image: current_organization.homepage_image,
|
39
|
-
logo: current_organization.logo,
|
40
|
-
favicon: current_organization.favicon,
|
41
|
-
official_img_header: current_organization.official_img_header,
|
42
|
-
official_img_footer: current_organization.official_img_footer
|
43
|
-
}.merge(params[:organization].to_unsafe_h)
|
44
|
-
end
|
45
31
|
end
|
46
32
|
end
|
47
33
|
end
|
@@ -73,12 +73,12 @@ module Decidim
|
|
73
73
|
|
74
74
|
def parent_scope
|
75
75
|
return @parent_scope if defined?(@parent_scope)
|
76
|
-
@parent_scope = scope ? scope.parent : organization_scopes.
|
76
|
+
@parent_scope = scope ? scope.parent : organization_scopes.find_by(id: params[:scope_id])
|
77
77
|
end
|
78
78
|
|
79
79
|
def scope
|
80
80
|
return @scope if defined?(@scope)
|
81
|
-
@scope = organization_scopes.
|
81
|
+
@scope = organization_scopes.find_by(id: params[:id])
|
82
82
|
end
|
83
83
|
|
84
84
|
def children_scopes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A form object used to update the current organization appearance from the admin
|
6
|
+
# dashboard.
|
7
|
+
#
|
8
|
+
class OrganizationAppearanceForm < Form
|
9
|
+
include TranslatableAttributes
|
10
|
+
|
11
|
+
mimic :organization_appearance
|
12
|
+
|
13
|
+
attribute :homepage_image
|
14
|
+
attribute :remove_homepage_image
|
15
|
+
attribute :logo
|
16
|
+
attribute :remove_logo
|
17
|
+
attribute :favicon
|
18
|
+
attribute :remove_favicon
|
19
|
+
attribute :official_img_header
|
20
|
+
attribute :remove_official_img_header
|
21
|
+
attribute :official_img_footer
|
22
|
+
attribute :remove_official_img_footer
|
23
|
+
attribute :official_url
|
24
|
+
attribute :show_statistics, Boolean
|
25
|
+
attribute :header_snippets, String
|
26
|
+
attribute :cta_button_path, String
|
27
|
+
|
28
|
+
translatable_attribute :cta_button_text, String
|
29
|
+
translatable_attribute :description, String
|
30
|
+
translatable_attribute :welcome_text, String
|
31
|
+
|
32
|
+
validates :cta_button_path, format: { with: %r{\A[a-zA-Z]+[a-zA-Z0-9-/]+\z} }, allow_blank: true
|
33
|
+
validates :official_img_header,
|
34
|
+
:official_img_footer,
|
35
|
+
:homepage_image,
|
36
|
+
:logo,
|
37
|
+
file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } },
|
38
|
+
file_content_type: { allow: ["image/jpeg", "image/png"] }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -18,34 +18,11 @@ module Decidim
|
|
18
18
|
attribute :youtube_handler, String
|
19
19
|
attribute :github_handler, String
|
20
20
|
attribute :default_locale, String
|
21
|
-
attribute :homepage_image
|
22
|
-
attribute :remove_homepage_image
|
23
|
-
attribute :logo
|
24
|
-
attribute :remove_logo
|
25
|
-
attribute :favicon
|
26
|
-
attribute :remove_favicon
|
27
|
-
attribute :official_url
|
28
|
-
attribute :official_img_header
|
29
|
-
attribute :remove_official_img_header
|
30
|
-
attribute :official_img_footer
|
31
|
-
attribute :remove_official_img_footer
|
32
|
-
attribute :show_statistics
|
33
|
-
attribute :header_snippets, String
|
34
|
-
|
35
|
-
translatable_attribute :description, String
|
36
|
-
translatable_attribute :welcome_text, String
|
37
21
|
|
38
22
|
validates :name, presence: true
|
39
23
|
validates :default_locale, presence: true
|
40
24
|
validates :default_locale, inclusion: { in: :available_locales }
|
41
25
|
|
42
|
-
validates :official_img_header,
|
43
|
-
file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } },
|
44
|
-
file_content_type: { allow: ["image/jpeg", "image/png"] }
|
45
|
-
validates :official_img_footer,
|
46
|
-
file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } },
|
47
|
-
file_content_type: { allow: ["image/jpeg", "image/png"] }
|
48
|
-
|
49
26
|
private
|
50
27
|
|
51
28
|
def available_locales
|
@@ -21,13 +21,14 @@ module Decidim
|
|
21
21
|
alias organization current_organization
|
22
22
|
|
23
23
|
def scope_type
|
24
|
-
Decidim::ScopeType.
|
24
|
+
Decidim::ScopeType.find_by(id: scope_type_id) if scope_type_id
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def code_uniqueness
|
30
|
-
return unless organization
|
30
|
+
return unless organization
|
31
|
+
return unless organization.scopes.where(code: code).where.not(id: id).any?
|
31
32
|
|
32
33
|
errors.add(:code, :taken)
|
33
34
|
end
|
@@ -27,7 +27,8 @@ module Decidim
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def slug_uniqueness
|
30
|
-
return unless organization
|
30
|
+
return unless organization
|
31
|
+
return unless organization.static_pages.where(slug: slug).where.not(id: id).any?
|
31
32
|
|
32
33
|
errors.add(:slug, :taken)
|
33
34
|
end
|
@@ -10,9 +10,11 @@ module Decidim
|
|
10
10
|
def perform(user, newsletter)
|
11
11
|
NewsletterMailer.newsletter(user, newsletter).deliver_now
|
12
12
|
|
13
|
+
# rubocop:disable Rails/SkipsModelValidations
|
13
14
|
newsletter.with_lock do
|
14
15
|
newsletter.increment!(:total_deliveries)
|
15
16
|
end
|
17
|
+
# rubocop:enable Rails/SkipsModelValidations
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -50,7 +50,8 @@ module Decidim
|
|
50
50
|
private
|
51
51
|
|
52
52
|
def empty_available_authorizations?
|
53
|
-
|
53
|
+
return unless @context[:current_organization]
|
54
|
+
@context[:current_organization].available_authorizations.empty?
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
<div class="dropdown-pane" id="export-dropdown" data-dropdown data-auto-focus="true" data-close-on-click="true">
|
3
3
|
<ul class="vertical menu add-features">
|
4
4
|
<% feature.manifest.export_manifests.each do |manifest| %>
|
5
|
-
<% %w{
|
6
|
-
<li class="exports--format--<%= format %> exports--<%= manifest.name %>"><%= link_to t("decidim.admin.exports.export_as", name: t("decidim.#{feature.manifest.name}.admin.exports.#{manifest.name}"), export_format: format.upcase), exports_path(feature, id: manifest.name, format: format), method: :post %></li>
|
5
|
+
<% %w{CSV JSON Excel}.each do |format| %>
|
6
|
+
<li class="exports--format--<%= format.downcase %> exports--<%= manifest.name %>"><%= link_to t("decidim.admin.exports.export_as", name: t("decidim.#{feature.manifest.name}.admin.exports.#{manifest.name}"), export_format: format.upcase), exports_path(feature, id: manifest.name, format: format), method: :post %></li>
|
7
7
|
<% end %>
|
8
8
|
<% end %>
|
9
9
|
</ul>
|
@@ -28,57 +28,12 @@
|
|
28
28
|
</div>
|
29
29
|
</div>
|
30
30
|
|
31
|
-
<div class="row column">
|
32
|
-
<%= form.translated :editor, :description %>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div class="row column">
|
36
|
-
<%= form.translated :text_area, :welcome_text %>
|
37
|
-
</div>
|
38
|
-
|
39
31
|
<div class="row column">
|
40
32
|
<%= form.collection_select :default_locale, localized_locales(current_organization.available_locales), :id, :name %>
|
41
33
|
</div>
|
42
34
|
|
43
|
-
<div class="row">
|
44
|
-
<div class="columns xlarge-4">
|
45
|
-
<%= form.upload :homepage_image %>
|
46
|
-
</div>
|
47
|
-
|
48
|
-
<div class="columns xlarge-4">
|
49
|
-
<%= form.upload :logo %>
|
50
|
-
</div>
|
51
|
-
|
52
|
-
<div class="columns xlarge-4">
|
53
|
-
<%= form.upload :favicon %>
|
54
|
-
</div>
|
55
|
-
</div>
|
56
|
-
|
57
|
-
<div class="row">
|
58
|
-
<div class="columns xlarge-6">
|
59
|
-
<%= form.upload :official_img_header %>
|
60
|
-
</div>
|
61
|
-
|
62
|
-
<div class="columns xlarge-6">
|
63
|
-
<%= form.upload :official_img_footer %>
|
64
|
-
</div>
|
65
|
-
</div>
|
66
|
-
|
67
35
|
<div class="row">
|
68
36
|
<div class="columns xlarge-6">
|
69
37
|
<%= form.text_field :reference_prefix %>
|
70
38
|
</div>
|
71
|
-
|
72
|
-
<div class="columns xlarge-6">
|
73
|
-
<%= form.text_field :official_url %>
|
74
|
-
</div>
|
75
|
-
</div>
|
76
|
-
|
77
|
-
<div class="row column">
|
78
|
-
<%= form.check_box :show_statistics %>
|
79
|
-
</div>
|
80
|
-
|
81
|
-
<div class="row column">
|
82
|
-
<%= form.text_area :header_snippets %>
|
83
|
-
<p class="help-text"><%= t(".header_snippets_help") %></p>
|
84
39
|
</div>
|