decidim-system 0.22.0 → 0.23.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-system might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/system/application.js.es6 +1 -0
- data/app/assets/stylesheets/decidim/system/_forms.scss +36 -0
- data/app/assets/stylesheets/decidim/system/application.scss +1 -0
- data/app/commands/decidim/system/create_oauth_application.rb +37 -0
- data/app/commands/decidim/system/destroy_oauth_application.rb +39 -0
- data/app/commands/decidim/system/register_organization.rb +2 -1
- data/app/commands/decidim/system/update_oauth_application.rb +39 -0
- data/app/commands/decidim/system/update_organization.rb +4 -0
- data/app/controllers/decidim/system/oauth_applications_controller.rb +84 -0
- data/app/controllers/decidim/system/organizations_controller.rb +1 -0
- data/app/forms/decidim/system/file_upload_settings_form.rb +70 -0
- data/app/forms/decidim/system/oauth_application_form.rb +35 -0
- data/app/forms/decidim/system/update_organization_form.rb +3 -1
- data/app/views/decidim/system/oauth_applications/_form.html.erb +26 -0
- data/app/views/decidim/system/oauth_applications/edit.html.erb +13 -0
- data/app/views/decidim/system/oauth_applications/index.html.erb +41 -0
- data/app/views/decidim/system/oauth_applications/new.html.erb +13 -0
- data/app/views/decidim/system/oauth_applications/show.html.erb +27 -0
- data/app/views/decidim/system/organizations/_file_upload_settings.erb +56 -0
- data/app/views/decidim/system/organizations/edit.html.erb +1 -0
- data/app/views/decidim/system/organizations/new.html.erb +1 -0
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/bg.yml +8 -0
- data/config/locales/ca.yml +74 -2
- data/config/locales/cs.yml +74 -2
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +28 -2
- data/config/locales/el.yml +0 -3
- data/config/locales/en.yml +74 -2
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +74 -2
- data/config/locales/es-PY.yml +74 -2
- data/config/locales/es.yml +74 -2
- data/config/locales/et.yml +1 -0
- data/config/locales/fi-plain.yml +74 -2
- data/config/locales/fi.yml +74 -2
- data/config/locales/fr-CA.yml +74 -2
- data/config/locales/fr.yml +74 -2
- data/config/locales/hr.yml +1 -0
- data/config/locales/is.yml +55 -0
- data/config/locales/it.yml +0 -3
- data/config/locales/ja.yml +173 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/{lv-LV.yml → lv.yml} +0 -3
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +0 -3
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +62 -23
- data/config/locales/pt.yml +0 -3
- data/config/locales/ro-RO.yml +0 -3
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sv.yml +42 -3
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +173 -0
- data/config/locales/zh-TW.yml +1 -0
- data/config/routes.rb +2 -0
- data/lib/decidim/system/engine.rb +5 -0
- data/lib/decidim/system/version.rb +1 -1
- metadata +41 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5faf98a3152e536e389d9fb86ae7e604b2bc56bada412fdb799fa4371544839e
|
4
|
+
data.tar.gz: 3a94d7d2a997d7996ac5869cdc589770b2925eaf409f4c5c8029eeea616a1fb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76c65b21024ee256684a009fe7791662f1099165baaa2c35ca68c8e1bc9ef8a6ad284a5f6b432fd3a07eea2e46f5cec0adf29c84ae05ae09bec27a32d467bd97
|
7
|
+
data.tar.gz: 417789586417f17361ba78e29fe554c7c121d8a178aba6cdb5470ff3bfaa9440fa52757f2d71f9ee9263e8b498477d0b7808c52a543b60b8d8676fd3686ce178
|
@@ -0,0 +1,36 @@
|
|
1
|
+
@import "tagsinput";
|
2
|
+
|
3
|
+
$tag-padding: .25rem;
|
4
|
+
$tag-margin: .2rem;
|
5
|
+
|
6
|
+
.input__tag{
|
7
|
+
background-color: rgba($medium-gray, .5);
|
8
|
+
border-radius: $input-radius;
|
9
|
+
padding: $tag-padding;
|
10
|
+
display: inline-block;
|
11
|
+
cursor: pointer;
|
12
|
+
-webkit-user-select: none;
|
13
|
+
-moz-user-select: none;
|
14
|
+
-ms-user-select: none;
|
15
|
+
user-select: none;
|
16
|
+
}
|
17
|
+
|
18
|
+
// Override defaults
|
19
|
+
.bootstrap-tagsinput{
|
20
|
+
margin-bottom: $form-spacing;
|
21
|
+
|
22
|
+
// Use foundation precalculated methods to get accurate form css properties
|
23
|
+
$height: ($input-font-size * unitless-calc($input-line-height)) + (get-side($input-padding, 'top') + get-side($input-padding, 'bottom'));
|
24
|
+
$tag-line-height: rem-calc(22);
|
25
|
+
$span-height: ($input-font-size * unitless-calc($tag-line-height)) + (get-side($tag-padding, 'top') + get-side($tag-padding, 'bottom')) - rem-calc(1);
|
26
|
+
|
27
|
+
width: 100%;
|
28
|
+
min-height: $height;
|
29
|
+
padding-bottom: $tag-margin / 4;
|
30
|
+
|
31
|
+
.tag{
|
32
|
+
color: inherit;
|
33
|
+
margin-right: 0; // fix whitespace
|
34
|
+
margin-bottom: $tag-margin;
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module System
|
5
|
+
# Creates an OAuthApplication.
|
6
|
+
class CreateOAuthApplication < Rectify::Command
|
7
|
+
# Initializes the command.
|
8
|
+
#
|
9
|
+
# form - The source fo data for this OAuthApplication.
|
10
|
+
def initialize(form)
|
11
|
+
@form = form
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
return broadcast(:invalid) unless @form.valid?
|
16
|
+
|
17
|
+
@application = Decidim.traceability.create!(
|
18
|
+
OAuthApplication,
|
19
|
+
@form.current_user,
|
20
|
+
organization: @form.current_organization,
|
21
|
+
name: @form.name,
|
22
|
+
decidim_organization_id: @form.decidim_organization_id,
|
23
|
+
organization_name: @form.organization_name,
|
24
|
+
organization_url: @form.organization_url,
|
25
|
+
organization_logo: @form.organization_logo,
|
26
|
+
redirect_uri: @form.redirect_uri,
|
27
|
+
scopes: "public"
|
28
|
+
)
|
29
|
+
|
30
|
+
broadcast(:ok, @application)
|
31
|
+
rescue ActiveRecord::RecordInvalid
|
32
|
+
@form.errors.add(:organization_logo, @application.errors[:organization_logo]) if @application.errors.include? :organization_logo
|
33
|
+
broadcast(:invalid)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module System
|
5
|
+
# This command deals with destroying an application from the admin panel.
|
6
|
+
class DestroyOAuthApplication < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# application - The OAuthApplication to be destroyed.
|
10
|
+
# user - The user that destroys the application.
|
11
|
+
def initialize(application, current_user)
|
12
|
+
@application = application
|
13
|
+
@current_user = current_user
|
14
|
+
end
|
15
|
+
|
16
|
+
# Public: Executes the command.
|
17
|
+
#
|
18
|
+
# Broadcasts :ok if it got destroyed
|
19
|
+
def call
|
20
|
+
destroy_application
|
21
|
+
broadcast(:ok)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :application, :current_user
|
27
|
+
|
28
|
+
def destroy_application
|
29
|
+
Decidim.traceability.perform_action!(
|
30
|
+
"delete",
|
31
|
+
application,
|
32
|
+
current_user
|
33
|
+
) do
|
34
|
+
application.destroy!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -59,7 +59,8 @@ module Decidim
|
|
59
59
|
default_locale: form.default_locale,
|
60
60
|
omniauth_settings: form.encrypted_omniauth_settings,
|
61
61
|
smtp_settings: form.encrypted_smtp_settings,
|
62
|
-
send_welcome_notification: true
|
62
|
+
send_welcome_notification: true,
|
63
|
+
file_upload_settings: form.file_upload_settings.final
|
63
64
|
)
|
64
65
|
end
|
65
66
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module System
|
5
|
+
# Updates the OAuth application given form data.
|
6
|
+
class UpdateOAuthApplication < Rectify::Command
|
7
|
+
# Initializes the command.
|
8
|
+
#
|
9
|
+
# application - The OAuthApplication to update.
|
10
|
+
# form - The form object containing the data to update.
|
11
|
+
# user - The user that updates the application.
|
12
|
+
def initialize(application, form, user)
|
13
|
+
@application = application
|
14
|
+
@form = form
|
15
|
+
@user = user
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
return broadcast(:invalid) unless @form.valid?
|
20
|
+
|
21
|
+
@application = Decidim.traceability.update!(
|
22
|
+
@application,
|
23
|
+
@user,
|
24
|
+
name: @form.name,
|
25
|
+
decidim_organization_id: @form.decidim_organization_id,
|
26
|
+
organization_name: @form.organization_name,
|
27
|
+
organization_url: @form.organization_url,
|
28
|
+
organization_logo: @form.organization_logo,
|
29
|
+
redirect_uri: @form.redirect_uri
|
30
|
+
)
|
31
|
+
|
32
|
+
broadcast(:ok, @application)
|
33
|
+
rescue ActiveRecord::RecordInvalid
|
34
|
+
@form.errors.add(:organization_logo, @application.errors[:organization_logo]) if @application.errors.include? :organization_logo
|
35
|
+
broadcast(:invalid)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -27,6 +27,9 @@ module Decidim
|
|
27
27
|
save_organization
|
28
28
|
end
|
29
29
|
|
30
|
+
# Ensure the runtime settings are updated
|
31
|
+
OrganizationSettings.reload(organization)
|
32
|
+
|
30
33
|
broadcast(:ok)
|
31
34
|
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
|
32
35
|
broadcast(:invalid)
|
@@ -49,6 +52,7 @@ module Decidim
|
|
49
52
|
organization.users_registration_mode = form.users_registration_mode
|
50
53
|
organization.omniauth_settings = form.encrypted_omniauth_settings
|
51
54
|
organization.smtp_settings = form.encrypted_smtp_settings
|
55
|
+
organization.file_upload_settings = form.file_upload_settings.final
|
52
56
|
|
53
57
|
organization.save!
|
54
58
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module System
|
5
|
+
# Controller that allows managing OAuth applications at the admin panel.
|
6
|
+
#
|
7
|
+
class OAuthApplicationsController < Decidim::System::ApplicationController
|
8
|
+
helper Decidim::Admin::AttributesDisplayHelper
|
9
|
+
|
10
|
+
def index
|
11
|
+
@oauth_applications = collection.page(params[:page]).per(15)
|
12
|
+
end
|
13
|
+
|
14
|
+
def show
|
15
|
+
@oauth_application = collection.find(params[:id])
|
16
|
+
end
|
17
|
+
|
18
|
+
def new
|
19
|
+
@form = form(OAuthApplicationForm).instance
|
20
|
+
end
|
21
|
+
|
22
|
+
def create
|
23
|
+
@form = form(OAuthApplicationForm).from_params(params)
|
24
|
+
|
25
|
+
CreateOAuthApplication.call(@form) do
|
26
|
+
on(:ok) do
|
27
|
+
flash[:notice] = I18n.t("oauth_applications.create.success", scope: "decidim.system")
|
28
|
+
redirect_to action: :index
|
29
|
+
end
|
30
|
+
|
31
|
+
on(:invalid) do
|
32
|
+
flash.now[:alert] = I18n.t("oauth_applications.create.error", scope: "decidim.system")
|
33
|
+
render :new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def edit
|
39
|
+
@oauth_application = collection.find(params[:id])
|
40
|
+
@form = form(OAuthApplicationForm).from_model(@oauth_application)
|
41
|
+
end
|
42
|
+
|
43
|
+
def update
|
44
|
+
@oauth_application = collection.find(params[:id])
|
45
|
+
@form = form(OAuthApplicationForm).from_params({ organization_logo: @oauth_application.organization_logo }.merge(params.to_unsafe_h))
|
46
|
+
|
47
|
+
UpdateOAuthApplication.call(@oauth_application, @form, current_user) do
|
48
|
+
on(:ok) do |_application|
|
49
|
+
flash[:notice] = I18n.t("oauth_applications.update.success", scope: "decidim.system")
|
50
|
+
redirect_to action: :index
|
51
|
+
end
|
52
|
+
|
53
|
+
on(:invalid) do |application|
|
54
|
+
@oauth_application = application
|
55
|
+
flash.now[:error] = I18n.t("oauth_applications.update.error", scope: "decidim.system")
|
56
|
+
render action: :edit
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def destroy
|
62
|
+
@oauth_application = collection.find(params[:id])
|
63
|
+
|
64
|
+
DestroyOAuthApplication.call(@oauth_application, current_user) do
|
65
|
+
on(:ok) do
|
66
|
+
flash[:notice] = I18n.t("oauth_applications.destroy.success", scope: "decidim.system")
|
67
|
+
redirect_to action: :index
|
68
|
+
end
|
69
|
+
|
70
|
+
on(:invalid) do
|
71
|
+
flash.now[:error] = I18n.t("oauth_applications.destroy.error", scope: "decidim.system")
|
72
|
+
redirect_to :back
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def collection
|
80
|
+
@collection ||= Decidim::OAuthApplication.all.includes([:organization])
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module System
|
5
|
+
# A form object used to update organization file upload settings from the
|
6
|
+
# system dashboard.
|
7
|
+
#
|
8
|
+
class FileUploadSettingsForm < Form
|
9
|
+
include JsonbAttributes
|
10
|
+
|
11
|
+
mimic :organization_file_uploads
|
12
|
+
|
13
|
+
attribute :allowed_file_extensions, Hash[Symbol => String]
|
14
|
+
attribute :allowed_content_types, Hash[Symbol => String]
|
15
|
+
attribute :maximum_file_size, Hash[Symbol => Float]
|
16
|
+
|
17
|
+
def map_model(settings_hash)
|
18
|
+
settings_hash = begin
|
19
|
+
if settings_hash.is_a?(Hash)
|
20
|
+
default_settings.deep_merge(settings_hash.deep_stringify_keys)
|
21
|
+
else
|
22
|
+
default_settings
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
attribute_set.each do |attr|
|
27
|
+
key = attr.name.to_s
|
28
|
+
next unless settings_hash.has_key?(key)
|
29
|
+
|
30
|
+
# For the view, the array values need to be in comma separated format
|
31
|
+
# in order for them to work correctly with the tags inputs.
|
32
|
+
value = Rectify::FormAttribute.new(attr).value_from(
|
33
|
+
settings_hash[key]
|
34
|
+
)
|
35
|
+
value.each do |k, v|
|
36
|
+
value[k] = v.join(",") if v.is_a?(Array)
|
37
|
+
end
|
38
|
+
|
39
|
+
self[key] = value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# This turns the attributes passed from the view into the final
|
44
|
+
# configuration array. Due to the UI component used for the array values,
|
45
|
+
# those values need to be handled as a single comma separated string in
|
46
|
+
# the view layer. Before we save those attributes, they need to be
|
47
|
+
# converted into arrays which is what this method does.
|
48
|
+
def final
|
49
|
+
csv_attributes = [:allowed_file_extensions, :allowed_content_types]
|
50
|
+
attributes.tap do |attr|
|
51
|
+
csv_attributes.each do |key|
|
52
|
+
attr[key] = csv_array_setting(attr[key])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def default_settings
|
60
|
+
Decidim::OrganizationSettings.default(:upload)
|
61
|
+
end
|
62
|
+
|
63
|
+
def csv_array_setting(original)
|
64
|
+
original.map do |key, value|
|
65
|
+
[key, value.split(",")]
|
66
|
+
end.to_h
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module System
|
5
|
+
# The form that validates the data to construct a valid OAuthApplication.
|
6
|
+
class OAuthApplicationForm < Decidim::Form
|
7
|
+
include Decidim::HasUploadValidations
|
8
|
+
|
9
|
+
mimic :oauth_application
|
10
|
+
|
11
|
+
attribute :name, String
|
12
|
+
attribute :decidim_organization_id, Integer
|
13
|
+
attribute :organization_name, String
|
14
|
+
attribute :organization_url, String
|
15
|
+
attribute :organization_logo
|
16
|
+
attribute :redirect_uri, String
|
17
|
+
|
18
|
+
validates :name, :redirect_uri, :decidim_organization_id, :organization_name, :organization_url, :organization_logo, presence: true
|
19
|
+
validates :organization_logo, passthru: { to: Decidim::OAuthApplication }
|
20
|
+
validate :redirect_uri_is_ssl
|
21
|
+
|
22
|
+
alias organization current_organization
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def redirect_uri_is_ssl
|
27
|
+
return if redirect_uri.blank?
|
28
|
+
|
29
|
+
uri = URI.parse(redirect_uri)
|
30
|
+
|
31
|
+
errors.add(:redirect_uri, :must_be_ssl) if uri.host != "localhost" && uri.scheme != "https"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -29,8 +29,9 @@ module Decidim
|
|
29
29
|
[:authentication, String],
|
30
30
|
[:enable_starttls_auto, Boolean]
|
31
31
|
]
|
32
|
+
attribute :file_upload_settings, FileUploadSettingsForm
|
32
33
|
|
33
|
-
OMNIATH_PROVIDERS_ATTRIBUTES = Decidim::
|
34
|
+
OMNIATH_PROVIDERS_ATTRIBUTES = Decidim::OmniauthProvider.available.keys.map do |provider|
|
34
35
|
Rails.application.secrets.dig(:omniauth, provider).keys.map do |setting|
|
35
36
|
if setting == :enabled
|
36
37
|
["omniauth_settings_#{provider}_enabled".to_sym, Boolean]
|
@@ -53,6 +54,7 @@ module Decidim
|
|
53
54
|
self.omniauth_settings = Hash[(model.omniauth_settings || []).map do |k, v|
|
54
55
|
[k, Decidim::OmniauthProvider.value_defined?(v) ? Decidim::AttributeEncryptor.decrypt(v) : v]
|
55
56
|
end]
|
57
|
+
self.file_upload_settings = FileUploadSettingsForm.from_model(model.file_upload_settings)
|
56
58
|
end
|
57
59
|
|
58
60
|
def clean_secondary_hosts
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<div class="row column">
|
2
|
+
<%= form.text_field :name %>
|
3
|
+
</div>
|
4
|
+
|
5
|
+
<div class="row column">
|
6
|
+
<%= form.text_field :redirect_uri %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="row column">
|
10
|
+
<%= form.select :decidim_organization_id,
|
11
|
+
Decidim::Organization.pluck(:name, :id),
|
12
|
+
{ include_blank: t(".select_organization") },
|
13
|
+
{ multiple: false } %>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div class="row column">
|
17
|
+
<%= form.text_field :organization_name %>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<div class="row column">
|
21
|
+
<%= form.text_field :organization_url %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class="row column">
|
25
|
+
<%= form.upload :organization_logo %>
|
26
|
+
</div>
|