decidim-admin 0.20.0 → 0.23.1.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.
Potentially problematic release.
This version of decidim-admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/app/assets/javascripts/decidim/admin/application.js.es6 +8 -0
- data/app/assets/javascripts/decidim/admin/budget_rule_toggler.component.js.es6 +52 -0
- data/app/assets/javascripts/decidim/admin/bundle.js +26 -32
- data/app/assets/javascripts/decidim/admin/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/admin/choose_language.js +12 -0
- data/app/assets/javascripts/decidim/admin/dynamic_fields.component.js.es6 +24 -5
- data/app/assets/javascripts/decidim/admin/form.js.es6 +24 -10
- data/app/assets/javascripts/decidim/admin/gallery.js.es6 +5 -0
- data/app/assets/javascripts/decidim/admin/newsletters.js.es6 +12 -0
- data/app/assets/javascripts/decidim/admin/officializations.js.es6 +20 -0
- data/app/assets/javascripts/decidim/admin/scope_picker_enabler.component.js.es6 +14 -0
- data/app/assets/stylesheets/decidim/admin/_decidim.scss +2 -0
- data/app/assets/stylesheets/decidim/admin/_variables.scss +2 -2
- data/app/assets/stylesheets/decidim/admin/extra/_action-icon.scss +6 -0
- data/app/assets/stylesheets/decidim/admin/extra/_cards.scss +11 -0
- data/app/assets/stylesheets/decidim/admin/extra/_newsletter-templates-gallery.scss +3 -0
- data/app/assets/stylesheets/decidim/admin/extra/_organization-appearance.scss +141 -0
- data/app/assets/stylesheets/decidim/admin/extra/_show_email.scss +31 -0
- data/app/assets/stylesheets/decidim/admin/extra/_title_bar.scss +4 -0
- data/app/assets/stylesheets/decidim/admin/modules/_buttons.scss +15 -1
- data/app/assets/stylesheets/decidim/admin/modules/_callouts.scss +11 -0
- data/app/assets/stylesheets/decidim/admin/modules/_cards.scss +13 -2
- data/app/assets/stylesheets/decidim/admin/modules/_filters.scss +78 -1
- data/app/assets/stylesheets/decidim/admin/modules/_forms.scss +16 -2
- data/app/assets/stylesheets/decidim/admin/modules/_import_result.scss +10 -0
- data/app/assets/stylesheets/decidim/admin/modules/_layout.scss +1 -1
- data/app/assets/stylesheets/decidim/admin/modules/_loading-spinner.scss +19 -0
- data/app/assets/stylesheets/decidim/admin/modules/_main-nav.scss +0 -1
- data/app/assets/stylesheets/decidim/admin/modules/_modules.scss +5 -1
- data/app/assets/stylesheets/decidim/admin/modules/_process-header.scss +0 -1
- data/app/assets/stylesheets/decidim/admin/modules/_secondary-nav.scss +5 -2
- data/app/assets/stylesheets/decidim/admin/modules/_table-list.scss +23 -7
- data/app/assets/stylesheets/decidim/admin/modules/_tabs.scss +7 -0
- data/app/assets/stylesheets/decidim/admin/modules/_users_statistics.scss +18 -0
- data/app/assets/stylesheets/decidim/admin/utils/_mixins.scss +42 -0
- data/app/assets/stylesheets/decidim/admin/utils/_settings.scss +4 -1
- data/app/cells/decidim/admin/content_block/show.erb +2 -2
- data/app/cells/decidim/admin/results_per_page/show.erb +16 -0
- data/app/cells/decidim/admin/results_per_page_cell.rb +14 -0
- data/app/commands/decidim/admin/create_attachment.rb +2 -2
- data/app/commands/decidim/admin/create_newsletter.rb +34 -9
- data/app/commands/decidim/admin/deliver_newsletter.rb +1 -1
- data/app/commands/decidim/admin/destroy_share_token.rb +46 -0
- data/app/commands/decidim/admin/reorder_content_blocks.rb +1 -1
- data/app/commands/decidim/admin/update_component.rb +27 -3
- data/app/commands/decidim/admin/update_content_block.rb +25 -1
- data/app/commands/decidim/admin/update_newsletter.rb +31 -9
- data/app/commands/decidim/admin/update_organization.rb +15 -1
- data/app/commands/decidim/admin/update_organization_appearance.rb +3 -1
- data/app/controllers/concerns/decidim/admin/filterable.rb +152 -0
- data/app/controllers/concerns/decidim/admin/officializations/filterable.rb +31 -0
- data/app/controllers/concerns/decidim/admin/paginable.rb +20 -0
- data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +8 -2
- data/app/controllers/decidim/admin/admin_terms_controller.rb +20 -0
- data/app/controllers/decidim/admin/application_controller.rb +3 -0
- data/app/controllers/decidim/admin/authorization_workflows_controller.rb +6 -0
- data/app/controllers/decidim/admin/components/base_controller.rb +5 -1
- data/app/controllers/decidim/admin/components_controller.rb +30 -23
- data/app/controllers/decidim/admin/concerns/has_private_users.rb +4 -0
- data/app/controllers/decidim/admin/dashboard_controller.rb +33 -1
- data/app/controllers/decidim/admin/metrics_controller.rb +22 -0
- data/app/controllers/decidim/admin/newsletter_templates_controller.rb +41 -0
- data/app/controllers/decidim/admin/newsletters_controller.rb +43 -4
- data/app/controllers/decidim/admin/officializations_controller.rb +15 -6
- data/app/controllers/decidim/admin/organization_appearance_controller.rb +1 -0
- data/app/controllers/decidim/admin/organization_controller.rb +4 -3
- data/app/controllers/decidim/admin/organization_homepage_content_blocks_controller.rb +2 -1
- data/app/controllers/decidim/admin/share_tokens_controller.rb +30 -0
- data/app/forms/decidim/admin/attachment_form.rb +3 -0
- data/app/forms/decidim/admin/component_form.rb +5 -22
- data/app/forms/decidim/admin/newsletter_form.rb +15 -3
- data/app/forms/decidim/admin/organization_appearance_form.rb +7 -4
- data/app/forms/decidim/admin/organization_form.rb +27 -0
- data/app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb +14 -0
- data/app/forms/decidim/admin/participatory_space_private_user_form.rb +8 -2
- data/app/frontend/components/autocomplete.component.test.tsx +2 -1
- data/app/frontend/components/autocomplete.component.tsx +29 -0
- data/app/helpers/decidim/admin/admin_terms_helper.rb +47 -0
- data/app/helpers/decidim/admin/application_helper.rb +2 -0
- data/app/helpers/decidim/admin/dashboard_helper.rb +25 -0
- data/app/helpers/decidim/admin/filterable_helper.rb +129 -0
- data/app/helpers/decidim/admin/icon_link_helper.rb +1 -1
- data/app/helpers/decidim/admin/newsletters_helper.rb +20 -0
- data/app/helpers/decidim/admin/paginable/per_page_helper.rb +22 -0
- data/app/helpers/decidim/admin/resource_scope_helper.rb +43 -0
- data/app/helpers/decidim/admin/scopes_helper.rb +6 -0
- data/app/helpers/decidim/admin/settings_helper.rb +56 -47
- data/app/helpers/decidim/admin/uploader_image_dimensions_helper.rb +30 -0
- data/app/helpers/decidim/admin/user_roles_helper.rb +19 -0
- data/app/models/decidim/admin/fake_newsletter.rb +49 -0
- data/app/permissions/decidim/admin/permissions.rb +30 -7
- data/app/presenters/decidim/admin/dashboard_metric_charts_presenter.rb +57 -0
- data/app/queries/decidim/admin/active_users_counter.rb +35 -0
- data/app/queries/decidim/admin/newsletter_recipients.rb +20 -9
- data/app/views/decidim/admin/admin_terms/show.html.erb +26 -0
- data/app/views/decidim/admin/attachment_collections/index.html.erb +1 -1
- data/app/views/decidim/admin/authorization_workflows/index.html.erb +1 -0
- data/app/views/decidim/admin/categories/index.html.erb +1 -1
- data/app/views/decidim/admin/components/_component.html.erb +40 -33
- data/app/views/decidim/admin/components/_form.html.erb +4 -0
- data/app/views/decidim/admin/components/_settings_fields.html.erb +2 -2
- data/app/views/decidim/admin/components/index.html.erb +11 -8
- data/app/views/decidim/admin/dashboard/show.html.erb +49 -9
- data/app/views/decidim/admin/exports/_dropdown.html.erb +6 -2
- data/app/views/decidim/admin/impersonatable_users/index.html.erb +2 -2
- data/app/views/decidim/admin/metrics/_metrics.html.erb +21 -0
- data/app/views/decidim/admin/metrics/index.html.erb +7 -0
- data/app/views/decidim/admin/newsletter_templates/index.html.erb +28 -0
- data/app/views/decidim/admin/newsletter_templates/show.html.erb +12 -0
- data/app/views/decidim/admin/newsletters/_form.html.erb +1 -7
- data/app/views/decidim/admin/newsletters/edit.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/index.html.erb +9 -3
- data/app/views/decidim/admin/newsletters/new.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +4 -4
- data/app/views/decidim/admin/officializations/_show_email_modal.html.erb +31 -0
- data/app/views/decidim/admin/officializations/index.html.erb +9 -41
- data/app/views/decidim/admin/officializations/show_email.html.erb +2 -0
- data/app/views/decidim/admin/organization/_form.html.erb +37 -0
- data/app/views/decidim/admin/organization_appearance/_form.html.erb +2 -72
- data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +23 -0
- data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +38 -0
- data/app/views/decidim/admin/organization_appearance/form/_minimap.html.erb +46 -0
- data/app/views/decidim/admin/resource_permissions/_options_form.html.erb +1 -1
- data/app/views/decidim/admin/share_tokens/_share_tokens.html.erb +57 -0
- data/app/views/decidim/admin/shared/_filters.html.erb +40 -0
- data/app/views/decidim/admin/shared/_gallery.html.erb +21 -0
- data/app/views/decidim/admin/static_pages/_form.html.erb +1 -1
- data/app/views/decidim/admin/user_groups/index.html.erb +4 -4
- data/app/views/decidim/admin/users_statistics/_users_count.html.erb +39 -0
- data/app/views/layouts/decidim/admin/_application.html.erb +2 -1
- data/app/views/layouts/decidim/admin/_header.html.erb +3 -0
- data/app/views/layouts/decidim/admin/_title_bar.html.erb +20 -10
- data/app/views/layouts/decidim/admin/newsletters.erb +1 -1
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +57 -49
- data/config/locales/bg-BG.yml +16 -0
- data/config/locales/bg.yml +135 -0
- data/config/locales/ca.yml +130 -50
- data/config/locales/cs.yml +184 -104
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +145 -47
- data/config/locales/el-GR.yml +1 -0
- data/config/locales/el.yml +819 -0
- data/config/locales/en.yml +127 -48
- data/config/locales/eo-UY.yml +0 -1
- data/config/locales/eo.yml +51 -0
- data/config/locales/es-MX.yml +128 -48
- data/config/locales/es-PY.yml +128 -48
- data/config/locales/es.yml +128 -48
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +21 -47
- data/config/locales/fi-plain.yml +128 -48
- data/config/locales/fi.yml +141 -61
- data/config/locales/fr-CA.yml +849 -0
- data/config/locales/fr.yml +128 -48
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +21 -47
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +112 -59
- data/config/locales/id-ID.yml +21 -47
- data/config/locales/is-IS.yml +534 -0
- data/config/locales/is.yml +568 -0
- data/config/locales/it.yml +133 -83
- data/config/locales/ja-JP.yml +855 -0
- data/config/locales/ja.yml +849 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +799 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +103 -48
- data/config/locales/no.yml +603 -32
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +364 -238
- data/config/locales/pt-BR.yml +22 -48
- data/config/locales/pt.yml +334 -237
- data/config/locales/ro-RO.yml +814 -0
- data/config/locales/ru.yml +20 -46
- data/config/locales/sk-SK.yml +823 -0
- data/config/locales/sk.yml +806 -0
- data/config/locales/sl.yml +166 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +590 -0
- data/config/locales/sv.yml +134 -55
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +21 -47
- data/config/locales/uk.yml +19 -48
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +849 -0
- data/config/locales/zh-TW.yml +1 -0
- data/config/routes.rb +20 -3
- data/db/migrate/20191118112040_add_accepted_admin_terms_at_field_to_users.rb +7 -0
- data/lib/decidim/admin.rb +17 -0
- data/lib/decidim/admin/engine.rb +12 -9
- data/lib/decidim/admin/form_builder.rb +7 -2
- data/lib/decidim/admin/test.rb +2 -0
- data/lib/decidim/admin/test/filterable_examples.rb +129 -0
- data/lib/decidim/admin/test/manage_attachment_collections_examples.rb +1 -1
- data/lib/decidim/admin/test/manage_component_permissions_examples.rb +15 -15
- data/lib/decidim/admin/test/manage_paginated_collection_examples.rb +22 -0
- data/lib/decidim/admin/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.serializejson.js +344 -0
- metadata +101 -31
- data/app/commands/decidim/admin/create_oauth_application.rb +0 -36
- data/app/commands/decidim/admin/destroy_oauth_application.rb +0 -39
- data/app/commands/decidim/admin/update_oauth_application.rb +0 -39
- data/app/controllers/decidim/admin/oauth_applications_controller.rb +0 -90
- data/app/forms/decidim/admin/oauth_application_form.rb +0 -32
- data/app/views/decidim/admin/oauth_applications/_form.html.erb +0 -19
- data/app/views/decidim/admin/oauth_applications/edit.html.erb +0 -13
- data/app/views/decidim/admin/oauth_applications/index.html.erb +0 -40
- data/app/views/decidim/admin/oauth_applications/new.html.erb +0 -13
- data/app/views/decidim/admin/oauth_applications/show.html.erb +0 -27
@@ -32,6 +32,12 @@ module Decidim
|
|
32
32
|
Option.new(scope_type.id, translated_attribute(scope_type.name))
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
def organization_scope_depths(organization = current_organization)
|
37
|
+
organization.scope_types.map do |scope_type|
|
38
|
+
Option.new(scope_type.id, translated_attribute(scope_type.name))
|
39
|
+
end.reverse
|
40
|
+
end
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
@@ -5,11 +5,15 @@ module Decidim
|
|
5
5
|
# This class contains helpers needed in order for component settings to
|
6
6
|
# properly render.
|
7
7
|
module SettingsHelper
|
8
|
+
include Decidim::ScopesHelper
|
9
|
+
|
8
10
|
TYPES = {
|
9
11
|
boolean: :check_box,
|
10
12
|
integer: :number_field,
|
11
13
|
string: :text_field,
|
12
|
-
text: :text_area
|
14
|
+
text: :text_area,
|
15
|
+
scope: :scope_field,
|
16
|
+
enum: :collection_radio_buttons
|
13
17
|
}.freeze
|
14
18
|
|
15
19
|
# Public: Renders a form field that matches a settings attribute's
|
@@ -22,41 +26,61 @@ module Decidim
|
|
22
26
|
# options - Extra options to be passed to the field helper.
|
23
27
|
#
|
24
28
|
# Returns a rendered form field.
|
25
|
-
def settings_attribute_input(form, attribute, name, options = {})
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
def settings_attribute_input(form, attribute, name, i18n_scope, options = {})
|
30
|
+
form_method = form_method_for_attribute(attribute)
|
31
|
+
|
32
|
+
container_class = "#{name}_container"
|
33
|
+
if options[:readonly]
|
34
|
+
container_class += " readonly_container"
|
35
|
+
help_text = text_for_setting(name, "readonly", i18n_scope)
|
32
36
|
end
|
33
|
-
|
37
|
+
help_text ||= text_for_setting(name, "help", i18n_scope)
|
38
|
+
help_text_options = help_text ? { help_text: help_text } : {}
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
40
|
+
options = { label: t(name, scope: i18n_scope) }
|
41
|
+
.merge(help_text_options)
|
42
|
+
.merge(extra_options_for_type(form_method))
|
43
|
+
.merge(options)
|
44
|
+
|
45
|
+
content_tag(:div, class: container_class) do
|
46
|
+
if attribute.translated?
|
47
|
+
options[:tabs_id] = "#{options.delete(:tabs_prefix)}-#{name}-tabs"
|
48
|
+
form.send(:translated, form_method, name, options)
|
49
|
+
elsif form_method == :collection_radio_buttons
|
50
|
+
render_enum_form_field(form, attribute, name, i18n_scope, options)
|
51
|
+
elsif form_method == :scope_field
|
52
|
+
scopes_picker_field(form, name)
|
53
|
+
else
|
54
|
+
form.send(form_method, name, options)
|
55
|
+
end
|
56
|
+
end.html_safe
|
39
57
|
end
|
40
58
|
|
41
59
|
private
|
42
60
|
|
43
|
-
# Returns a radio buttons collection input for the
|
44
|
-
|
45
|
-
|
46
|
-
html = label_tag(:amendments_visibility) do
|
61
|
+
# Returns a radio buttons collection input for the given attribute
|
62
|
+
def render_enum_form_field(form, attribute, name, i18n_scope, options)
|
63
|
+
html = label_tag(name) do
|
47
64
|
concat options[:label]
|
48
65
|
concat tag(:br)
|
49
|
-
concat form.collection_radio_buttons(
|
50
|
-
|
66
|
+
concat form.collection_radio_buttons(name,
|
67
|
+
build_enum_choices(name, i18n_scope, attribute.build_choices),
|
51
68
|
:last,
|
52
69
|
:first,
|
53
|
-
{ checked: form.object.
|
54
|
-
|
70
|
+
{ checked: form.object.send(name) },
|
71
|
+
options) { |b| b.label { b.radio_button + b.text } }
|
55
72
|
end
|
56
|
-
html << content_tag(:p,
|
57
|
-
html
|
73
|
+
html << content_tag(:p, options[:help_text], class: "help-text") if options[:help_text]
|
74
|
+
html
|
58
75
|
end
|
59
76
|
|
77
|
+
# Returns a translation or nil. If nil, ZURB Foundation won't add the help_text.
|
78
|
+
def text_for_setting(name, suffix, i18n_scope)
|
79
|
+
key = "#{i18n_scope}.#{name}_#{suffix}"
|
80
|
+
return t(key) if I18n.exists?(key)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Returns the FormBuilder's method used to render
|
60
84
|
def form_method_for_attribute(attribute)
|
61
85
|
return :editor if attribute.type.to_sym == :text && attribute.editor?
|
62
86
|
|
@@ -65,35 +89,20 @@ module Decidim
|
|
65
89
|
|
66
90
|
# Handles special cases.
|
67
91
|
# Returns an empty Hash or a Hash with extra HTML options.
|
68
|
-
def
|
69
|
-
case
|
70
|
-
when :
|
71
|
-
|
72
|
-
when :amendment_creation_enabled,
|
73
|
-
:amendment_reaction_enabled,
|
74
|
-
:amendment_promotion_enabled
|
75
|
-
amendments_extra_options
|
92
|
+
def extra_options_for_type(input_type)
|
93
|
+
case input_type
|
94
|
+
when :text_area
|
95
|
+
{ rows: 6 }
|
76
96
|
else
|
77
97
|
{}
|
78
98
|
end
|
79
99
|
end
|
80
100
|
|
81
|
-
#
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
{
|
88
|
-
class: "participatory_texts_disabled",
|
89
|
-
help_text: help_text_for_component_setting(:participatory_texts_disabled, :global, :proposals)
|
90
|
-
}
|
91
|
-
end
|
92
|
-
|
93
|
-
# Marks component_step_settings related to amendments with a CSS class,
|
94
|
-
# so they can be identified in "decidim/admin/form.js".
|
95
|
-
def amendments_extra_options
|
96
|
-
{ class: "amendments_step_settings" }
|
101
|
+
# Build options for enum attributes
|
102
|
+
def build_enum_choices(name, i18n_scope, choices)
|
103
|
+
choices.map do |choice|
|
104
|
+
[t("#{name}_choices.#{choice}", scope: i18n_scope), choice]
|
105
|
+
end
|
97
106
|
end
|
98
107
|
end
|
99
108
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# This class contains helpers needed to obtain information about
|
6
|
+
# image dimensions from the processors defined in the specific image's Uploader class
|
7
|
+
module UploaderImageDimensionsHelper
|
8
|
+
# Find the dimensions info of a model's image field and get the first value for dimensions ([w, h])
|
9
|
+
#
|
10
|
+
# model - The model to which the image belongs (An instance of `ActiveRecord`)
|
11
|
+
# image_name - The attribute name for the image (either a `symbol` or a `string`)
|
12
|
+
#
|
13
|
+
# Returns an integer array with [width, height]
|
14
|
+
def image_dimensions(model, image_name)
|
15
|
+
versions = model.send(image_name).dimensions_info
|
16
|
+
[:small, :medium, :default].map { |v| versions.dig(v, :dimensions) }.compact.first
|
17
|
+
end
|
18
|
+
|
19
|
+
# Find the first value for the processed image width
|
20
|
+
def image_width(model, image_name)
|
21
|
+
image_dimensions(model, image_name)[0]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Find the first value for the processed image height
|
25
|
+
def image_height(model, image_name)
|
26
|
+
image_dimensions(model, image_name)[1]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
module UserRolesHelper
|
6
|
+
def user_role_config
|
7
|
+
return @user_role_config if @user_role_config
|
8
|
+
|
9
|
+
space = current_participatory_space
|
10
|
+
@user_role_config = if current_user.admin?
|
11
|
+
space.user_role_config_for(current_user, :organization_admin)
|
12
|
+
else
|
13
|
+
role = space.user_roles.find_by(user: current_user)
|
14
|
+
space.user_role_config_for(current_user, role&.role)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# This class is used to generate fake newsletters and data to preview
|
6
|
+
# newsletter templates.
|
7
|
+
class FakeNewsletter
|
8
|
+
def initialize(organization, manifest)
|
9
|
+
@organization = organization
|
10
|
+
@manifest = manifest
|
11
|
+
end
|
12
|
+
|
13
|
+
def id
|
14
|
+
1
|
15
|
+
end
|
16
|
+
|
17
|
+
def template
|
18
|
+
@template ||= Decidim::ContentBlock.new(
|
19
|
+
in_preview: true,
|
20
|
+
manifest_name: manifest.name,
|
21
|
+
scope_name: :newsletter_template,
|
22
|
+
settings: manifest.settings.attributes.inject({}) do |acc, (name, attrs)|
|
23
|
+
value = if attrs.preview.respond_to?(:call)
|
24
|
+
attrs.preview.call
|
25
|
+
else
|
26
|
+
attrs.preview
|
27
|
+
end
|
28
|
+
|
29
|
+
acc.update(name => value)
|
30
|
+
end
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def subject
|
35
|
+
organization.available_locales.inject({}) do |acc, locale|
|
36
|
+
acc.update(locale => "Lorem ipsum")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def sent_at
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
attr_reader :organization, :manifest
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -16,15 +16,22 @@ module Decidim
|
|
16
16
|
return permission_action
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
if user_manager?
|
20
|
+
begin
|
21
|
+
allow! if user_manager_permissions.allowed?
|
22
|
+
rescue Decidim::PermissionAction::PermissionNotSetError
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
end
|
20
26
|
|
21
|
-
allow! if user_can_enter_space_area?
|
27
|
+
allow! if user_can_enter_space_area?(require_admin_terms_accepted: true)
|
22
28
|
|
23
29
|
read_admin_dashboard_action?
|
24
30
|
apply_newsletter_permissions_for_admin!
|
25
31
|
|
26
|
-
if user.admin?
|
32
|
+
if user.admin? && admin_terms_accepted?
|
27
33
|
allow! if read_admin_log_action?
|
34
|
+
allow! if read_metrics_action?
|
28
35
|
allow! if static_page_action?
|
29
36
|
allow! if organization_action?
|
30
37
|
allow! if user_action?
|
@@ -38,13 +45,13 @@ module Decidim
|
|
38
45
|
allow! if permission_action.subject == :scope_type
|
39
46
|
allow! if permission_action.subject == :area
|
40
47
|
allow! if permission_action.subject == :area_type
|
41
|
-
allow! if permission_action.subject == :oauth_application
|
42
48
|
allow! if permission_action.subject == :user_group
|
43
49
|
allow! if permission_action.subject == :officialization
|
44
50
|
allow! if permission_action.subject == :authorization
|
45
51
|
allow! if permission_action.subject == :authorization_workflow
|
46
52
|
allow! if permission_action.subject == :static_page_topic
|
47
53
|
allow! if permission_action.subject == :help_sections
|
54
|
+
allow! if permission_action.subject == :share_token
|
48
55
|
end
|
49
56
|
|
50
57
|
permission_action
|
@@ -66,6 +73,7 @@ module Decidim
|
|
66
73
|
end
|
67
74
|
|
68
75
|
def apply_newsletter_permissions_for_admin!
|
76
|
+
return unless admin_terms_accepted?
|
69
77
|
return unless permission_action.subject == :newsletter
|
70
78
|
return allow! if user.admin?
|
71
79
|
return unless space_allows_admin_access?
|
@@ -89,6 +97,11 @@ module Decidim
|
|
89
97
|
end
|
90
98
|
end
|
91
99
|
|
100
|
+
def read_metrics_action?
|
101
|
+
permission_action.subject == :metrics &&
|
102
|
+
permission_action.action == :read
|
103
|
+
end
|
104
|
+
|
92
105
|
def read_admin_log_action?
|
93
106
|
permission_action.subject == :admin_log &&
|
94
107
|
permission_action.action == :read
|
@@ -157,15 +170,19 @@ module Decidim
|
|
157
170
|
@organization ||= context.fetch(:organization, nil) || context.fetch(:current_organization, nil)
|
158
171
|
end
|
159
172
|
|
160
|
-
def user_can_enter_space_area?
|
173
|
+
def user_can_enter_space_area?(**args)
|
161
174
|
return unless permission_action.action == :enter &&
|
162
175
|
permission_action.subject == :space_area
|
163
176
|
|
164
|
-
space_allows_admin_access_to_current_action?
|
177
|
+
space_allows_admin_access_to_current_action?(args)
|
165
178
|
end
|
166
179
|
|
167
|
-
def space_allows_admin_access_to_current_action?
|
180
|
+
def space_allows_admin_access_to_current_action?(require_admin_terms_accepted: false)
|
168
181
|
Decidim.participatory_space_manifests.any? do |manifest|
|
182
|
+
if manifest.name != :initiatives && require_admin_terms_accepted
|
183
|
+
next unless admin_terms_accepted?
|
184
|
+
end
|
185
|
+
|
169
186
|
new_permission_action = Decidim::PermissionAction.new(
|
170
187
|
action: permission_action.action,
|
171
188
|
scope: permission_action.scope,
|
@@ -181,6 +198,12 @@ module Decidim
|
|
181
198
|
Decidim::Admin::UserManagerPermissions.new(user, permission_action, context).permissions
|
182
199
|
end
|
183
200
|
|
201
|
+
def admin_terms_accepted?
|
202
|
+
return unless permission_action.scope == :admin
|
203
|
+
|
204
|
+
user&.admin_terms_accepted?
|
205
|
+
end
|
206
|
+
|
184
207
|
def available_authorization_handlers?
|
185
208
|
user.organization.available_authorization_handlers.any?
|
186
209
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
class DashboardMetricChartsPresenter < Decidim::MetricChartsPresenter
|
6
|
+
attribute :summary, Boolean
|
7
|
+
|
8
|
+
def render_not_highlighted(metrics)
|
9
|
+
safe_join(
|
10
|
+
metrics.map do |metric|
|
11
|
+
render_metrics_data(metric.metric_name, klass: not_highlighted_classes, graph_klass: "small")
|
12
|
+
end
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def highlighted_metrics
|
17
|
+
return super unless summary?
|
18
|
+
|
19
|
+
Decidim.metrics_registry.filtered(
|
20
|
+
highlight: true,
|
21
|
+
scope: "home"
|
22
|
+
).select do |registry|
|
23
|
+
%w(users proposals).include? registry.metric_name
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def not_highlighted_metrics
|
28
|
+
return super unless summary?
|
29
|
+
|
30
|
+
Decidim.metrics_registry.filtered(
|
31
|
+
highlight: false,
|
32
|
+
scope: "home"
|
33
|
+
).select do |registry|
|
34
|
+
%w(comments meetings accepted_proposals results).include? registry.metric_name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def highlighted_classes
|
41
|
+
return "cell medium-6" if summary?
|
42
|
+
|
43
|
+
"cell medium-4"
|
44
|
+
end
|
45
|
+
|
46
|
+
def not_highlighted_classes
|
47
|
+
return "cell medium-3" if summary?
|
48
|
+
|
49
|
+
"cell medium-2"
|
50
|
+
end
|
51
|
+
|
52
|
+
def not_highlighted_wrapper_classes
|
53
|
+
"grid-x grid-margin-x"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# Counts active users making a distinction between whether they are admins or participants
|
6
|
+
class ActiveUsersCounter < Rectify::Query
|
7
|
+
# Initializes the class.
|
8
|
+
#
|
9
|
+
# @param organization [Organization] Current organization
|
10
|
+
# @param date [Date] Period time to make users count check
|
11
|
+
# @param admin [boolean] Possible values : t for Admin or f for participant
|
12
|
+
def initialize(organization:, date:, admin: false)
|
13
|
+
@organization = organization
|
14
|
+
@date = date
|
15
|
+
@admin = admin
|
16
|
+
end
|
17
|
+
|
18
|
+
# Count the user's number who have logged in since given date
|
19
|
+
#
|
20
|
+
# Returns an ActiveRecord::Relation
|
21
|
+
def query
|
22
|
+
return Decidim::User.none unless organization && date
|
23
|
+
|
24
|
+
query = Decidim::User.left_outer_joins(:organization).where(decidim_organizations: { id: organization.id })
|
25
|
+
query = query.where("#{Decidim::User.table_name}.current_sign_in_at >= ?", date)
|
26
|
+
query = query.where(admin: admin)
|
27
|
+
query
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :organization, :date, :admin
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|