decidim-core 0.20.1 → 0.21.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-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/fonts/decidim/Roboto-Regular.eot +0 -0
- data/app/assets/fonts/decidim/Roboto-Regular.svg +10520 -0
- data/app/assets/fonts/decidim/Roboto-Regular.ttf +0 -0
- data/app/assets/fonts/decidim/Roboto-Regular.woff +0 -0
- data/app/assets/fonts/decidim/Roboto-Regular.woff2 +0 -0
- data/app/assets/images/decidim/brands/google.svg +1 -0
- data/app/assets/javascripts/decidim.js.es6 +5 -0
- data/app/assets/javascripts/decidim/check_boxes_tree.js.es6 +190 -0
- data/app/assets/javascripts/decidim/core/bundle.js +1 -1
- data/app/assets/javascripts/decidim/core/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/delayed.js.es6 +26 -0
- data/app/assets/javascripts/decidim/diff_mode_dropdown.js.es6 +25 -4
- data/app/assets/javascripts/decidim/form_filter.component.js.es6 +86 -38
- data/app/assets/javascripts/decidim/form_filter.component.test.js +40 -6
- data/app/assets/javascripts/decidim/history.js.es6 +16 -1
- data/app/assets/javascripts/decidim/vizzs/orgchart.js.es6 +1 -1
- data/app/assets/stylesheets/decidim/_variables.scss +1 -1
- data/app/assets/stylesheets/decidim/extras/_results-per-page.scss +0 -1
- data/app/assets/stylesheets/decidim/modules/_buttons.scss +76 -3
- data/app/assets/stylesheets/decidim/modules/_comments.scss +78 -2
- data/app/assets/stylesheets/decidim/modules/_filters.scss +36 -2
- data/app/assets/stylesheets/decidim/modules/_layout.scss +13 -0
- data/app/assets/stylesheets/decidim/modules/_modules.scss +1 -0
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +11 -5
- data/app/assets/stylesheets/decidim/modules/_process-stats.scss +53 -0
- data/app/assets/stylesheets/decidim/modules/_status-labels.scss +5 -0
- data/app/assets/stylesheets/decidim/modules/_tags.scss +7 -1
- data/app/assets/stylesheets/decidim/modules/_typography.scss +49 -4
- data/app/assets/stylesheets/decidim/utils/_fontface.scss +10 -0
- data/app/assets/stylesheets/decidim/utils/_toggle-expand.scss +14 -0
- data/app/cells/decidim/activity/show.erb +1 -1
- data/app/cells/decidim/author/profile_inline.erb +2 -2
- data/app/cells/decidim/diff/attribute.erb +15 -5
- data/app/cells/decidim/diff/diff_mode_html.erb +31 -0
- data/app/cells/decidim/diff/diff_split.erb +1 -1
- data/app/cells/decidim/diff/diff_unified.erb +1 -1
- data/app/cells/decidim/diff/show.erb +1 -0
- data/app/cells/decidim/diff_cell.rb +21 -8
- data/app/cells/decidim/follow_button/show.erb +20 -7
- data/app/cells/decidim/navbar_admin_link/show.erb +6 -0
- data/app/cells/decidim/navbar_admin_link_cell.rb +43 -0
- data/app/cells/decidim/tags_cell.rb +2 -2
- data/app/commands/decidim/amendable/accept.rb +9 -4
- data/app/commands/decidim/amendable/publish_draft.rb +5 -0
- data/app/commands/decidim/amendable/reject.rb +5 -0
- data/app/commands/decidim/amendable/withdraw.rb +3 -12
- data/app/commands/decidim/create_registration.rb +5 -6
- data/app/controllers/concerns/decidim/use_organization_time_zone.rb +32 -0
- data/app/controllers/decidim/application_controller.rb +3 -0
- data/app/controllers/decidim/components/base_controller.rb +1 -0
- data/app/controllers/decidim/data_portability_controller.rb +12 -19
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -1
- data/app/controllers/decidim/devise/registrations_controller.rb +1 -0
- data/app/controllers/decidim/scopes_controller.rb +41 -7
- data/app/forms/decidim/registration_form.rb +5 -0
- data/app/functions/decidim/core/component_finder_base.rb +33 -0
- data/app/functions/decidim/core/component_list.rb +38 -0
- data/app/functions/decidim/core/component_list_base.rb +61 -0
- data/app/functions/decidim/core/needs_api_filter_and_order.rb +52 -0
- data/app/functions/decidim/core/participatory_space_finder.rb +11 -0
- data/app/functions/decidim/core/participatory_space_finder_base.rb +29 -0
- data/app/functions/decidim/core/participatory_space_list.rb +11 -0
- data/app/functions/decidim/core/participatory_space_list_base.rb +34 -0
- data/app/helpers/decidim/amendments_helper.rb +27 -1
- data/app/helpers/decidim/application_helper.rb +31 -3
- data/app/helpers/decidim/categories_helper.rb +26 -0
- data/app/helpers/decidim/check_boxes_tree_helper.rb +115 -0
- data/app/helpers/decidim/omniauth_helper.rb +6 -13
- data/app/helpers/decidim/resource_versions_helper.rb +29 -0
- data/app/helpers/decidim/rich_text_editor_helper.rb +22 -0
- data/app/helpers/decidim/sanitize_helper.rb +3 -1
- data/app/helpers/decidim/scopes_helper.rb +3 -2
- data/app/jobs/decidim/data_portability_export_job.rb +18 -10
- data/app/jobs/decidim/export_job.rb +1 -1
- data/app/mailers/decidim/export_mailer.rb +9 -5
- data/app/models/decidim/omniauth_provider.rb +28 -0
- data/app/models/decidim/organization.rb +41 -0
- data/app/models/decidim/participatory_space_role_config/admin.rb +8 -0
- data/app/models/decidim/participatory_space_role_config/base.rb +31 -0
- data/app/models/decidim/participatory_space_role_config/collaborator.rb +8 -0
- data/app/models/decidim/participatory_space_role_config/moderator.rb +11 -0
- data/app/models/decidim/participatory_space_role_config/null_object.rb +11 -0
- data/app/models/decidim/participatory_space_role_config/participatory_space_admin.rb +8 -0
- data/app/models/decidim/participatory_space_role_config/valuator.rb +11 -0
- data/app/models/decidim/scope.rb +4 -2
- data/app/models/decidim/user.rb +19 -3
- data/app/presenters/decidim/home_stats_presenter.rb +5 -2
- data/app/presenters/decidim/resource_locator_presenter.rb +9 -0
- data/app/serializers/decidim/exporters/participatory_space_components_serializer.rb +1 -1
- data/app/serializers/decidim/importers/participatory_space_components_importer.rb +14 -5
- data/app/services/decidim/data_portability_exporter.rb +72 -0
- data/app/services/decidim/resource_search.rb +29 -13
- data/app/services/decidim/zip_stream/zip_stream_writer.rb +56 -0
- data/app/types/decidim/core/amendment_type.rb +26 -0
- data/app/types/decidim/core/area_api_type.rb +16 -0
- data/app/types/decidim/core/area_type_type.rb +14 -0
- data/app/types/decidim/core/base_input_filter.rb +8 -0
- data/app/types/decidim/core/base_input_sort.rb +22 -0
- data/app/types/decidim/core/component_input_filter.rb +50 -0
- data/app/types/decidim/core/component_input_sort.rb +32 -0
- data/app/types/decidim/core/fingerprint_type.rb +15 -0
- data/app/types/decidim/core/has_hastaggable_input_filter.rb +15 -0
- data/app/types/decidim/core/has_localized_input_filter.rb +21 -0
- data/app/types/decidim/core/has_localized_input_sort.rb +21 -0
- data/app/types/decidim/core/has_publishable_input_filter.rb +34 -0
- data/app/types/decidim/core/has_publishable_input_sort.rb +13 -0
- data/app/types/decidim/core/participatory_space_input_filter.rb +26 -0
- data/app/types/decidim/core/participatory_space_input_sort.rb +14 -0
- data/app/types/decidim/core/participatory_space_link_type.rb +24 -0
- data/app/types/decidim/core/trace_version_type.rb +29 -0
- data/app/uploaders/decidim/data_portability_uploader.rb +2 -7
- data/app/validators/time_zone_validator.rb +10 -0
- data/app/views/decidim/amendments/_edit_form_fields.html.erb +5 -13
- data/app/views/decidim/amendments/preview_draft.html.erb +1 -1
- data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +10 -12
- data/app/views/decidim/devise/shared/_omniauth_buttons_mini.html.erb +6 -8
- data/app/views/decidim/export_mailer/data_portability_export.html.erb +2 -2
- data/app/views/decidim/scopes/picker.html.erb +7 -3
- data/app/views/decidim/shared/_check_boxes_tree.html.erb +54 -0
- data/app/views/decidim/shared/_extended_navigation_bar.html.erb +1 -1
- data/app/views/decidim/widgets/show.html.erb +4 -0
- data/app/views/layouts/decidim/_admin_links.html.erb +2 -0
- data/app/views/layouts/decidim/_wrapper.html.erb +4 -3
- data/app/views/layouts/decidim/widget.html.erb +1 -43
- data/config/initializers/browser.rb +5 -0
- data/config/initializers/devise.rb +0 -22
- data/config/initializers/omniauth.rb +50 -0
- data/config/locales/ar.yml +6 -3
- data/config/locales/ca.yml +15 -6
- data/config/locales/cs.yml +12 -3
- data/config/locales/de.yml +5 -3
- data/config/locales/el-GR.yml +0 -2
- data/config/locales/el.yml +153 -0
- data/config/locales/en.yml +16 -7
- data/config/locales/eo-UY.yml +2 -2
- data/config/locales/es-MX.yml +12 -3
- data/config/locales/es-PY.yml +12 -3
- data/config/locales/es.yml +15 -6
- data/config/locales/eu.yml +4 -3
- data/config/locales/fi-plain.yml +12 -3
- data/config/locales/fi.yml +12 -3
- data/config/locales/fr.yml +5 -3
- data/config/locales/gl.yml +4 -3
- data/config/locales/hu.yml +12 -3
- data/config/locales/id-ID.yml +4 -3
- data/config/locales/it.yml +11 -3
- data/config/locales/nl.yml +8 -3
- data/config/locales/no.yml +12 -3
- data/config/locales/pl.yml +4 -3
- data/config/locales/pt-BR.yml +4 -3
- data/config/locales/pt.yml +4 -3
- data/config/locales/ru.yml +5 -3
- data/config/locales/sv.yml +5 -3
- data/config/locales/tr-TR.yml +4 -3
- data/config/locales/uk.yml +1 -3
- data/db/migrate/20191113092826_add_omniauth_settings_to_decidim_organization.rb +7 -0
- data/db/migrate/20191113144432_add_rich_text_editor_in_public_views_to_organizations.rb +10 -0
- data/db/migrate/20191118123154_add_admin_terms_of_use_body_field_to_organization.rb +9 -0
- data/db/migrate/20200107142226_add_organization_timezone.rb +7 -0
- data/db/seeds.rb +2 -1
- data/lib/decidim/amendable.rb +7 -4
- data/lib/decidim/api/amendable_entity_interface.rb +18 -0
- data/lib/decidim/api/amendable_interface.rb +18 -0
- data/lib/decidim/api/attachable_interface.rb +1 -1
- data/lib/decidim/api/categorizable_interface.rb +1 -1
- data/lib/decidim/api/coauthorable_interface.rb +29 -0
- data/lib/decidim/api/fingerprint_interface.rb +13 -0
- data/lib/decidim/api/participatory_space_interface.rb +9 -9
- data/lib/decidim/api/participatory_space_resourceable_interface.rb +21 -0
- data/lib/decidim/api/scopable_interface.rb +1 -1
- data/lib/decidim/api/timestamps_interface.rb +21 -0
- data/lib/decidim/api/traceable_interface.rb +14 -0
- data/lib/decidim/coauthorable.rb +9 -2
- data/lib/decidim/component_manifest.rb +1 -1
- data/lib/decidim/content_processor.rb +4 -2
- data/lib/decidim/content_renderers/link_renderer.rb +1 -1
- data/lib/decidim/core.rb +3 -3
- data/lib/decidim/core/api.rb +7 -0
- data/lib/decidim/core/test.rb +1 -0
- data/lib/decidim/core/test/factories.rb +16 -0
- data/lib/decidim/core/test/shared_examples/amendable_interface_examples.rb +14 -0
- data/lib/decidim/core/test/shared_examples/amendable_proposals_interface_examples.rb +50 -0
- data/lib/decidim/core/test/shared_examples/authorable_interface_examples.rb +3 -0
- data/lib/decidim/core/test/shared_examples/coauthorable_interface_examples.rb +60 -0
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +8 -8
- data/lib/decidim/core/test/shared_examples/fingerprintable_interface_examples.rb +17 -0
- data/lib/decidim/core/test/shared_examples/follows_examples.rb +16 -0
- data/lib/decidim/core/test/shared_examples/input_filter_examples.rb +118 -0
- data/lib/decidim/core/test/shared_examples/input_sort_examples.rb +105 -0
- data/lib/decidim/core/test/shared_examples/participatory_space_resourcable_interface_examples.rb +43 -0
- data/lib/decidim/core/test/shared_examples/rich_text_editor_examples.rb +59 -0
- data/lib/decidim/core/test/shared_examples/timestamps_interface_examples.rb +21 -0
- data/lib/decidim/core/test/shared_examples/traceable_interface_examples.rb +47 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/deprecations.rb +19 -0
- data/lib/decidim/diffy_extension.rb +26 -0
- data/lib/decidim/exporters/export_manifest.rb +6 -2
- data/lib/decidim/filter_form_builder.rb +25 -7
- data/lib/decidim/form_builder.rb +2 -2
- data/lib/decidim/has_settings.rb +10 -4
- data/lib/decidim/participatory_space_manifest.rb +20 -0
- data/lib/decidim/participatory_space_resourceable.rb +35 -1
- data/lib/decidim/query_extensions.rb +9 -23
- data/lib/decidim/scopable.rb +10 -0
- data/lib/tasks/decidim_data_portability_tasks.rake +66 -5
- data/lib/tasks/decidim_metrics_tasks.rake +18 -7
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.el.js +14 -0
- metadata +142 -16
- data/app/models/decidim/participatory_process_user_role.rb +0 -32
- data/app/views/layouts/decidim/_edit_link.html.erb +0 -8
- data/lib/decidim/data_portability_file_reader.rb +0 -56
- data/lib/decidim/data_portability_file_zipper.rb +0 -67
@@ -3,18 +3,6 @@
|
|
3
3
|
module Decidim
|
4
4
|
# Helper that provides methods to enable or disable omniauth buttons
|
5
5
|
module OmniauthHelper
|
6
|
-
# Public: returns true if the social provider is enabled
|
7
|
-
def social_provider_enabled?(provider)
|
8
|
-
Rails.application.secrets.dig(:omniauth, provider.to_sym, :enabled)
|
9
|
-
end
|
10
|
-
|
11
|
-
# Public: returns true if any provider is enabled
|
12
|
-
def any_social_provider_enabled?
|
13
|
-
User.omniauth_providers.any? do |provider|
|
14
|
-
social_provider_enabled? provider
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
6
|
# Public: normalize providers names to they can be used for buttons
|
19
7
|
# and icons.
|
20
8
|
def normalize_provider_name(provider)
|
@@ -23,7 +11,7 @@ module Decidim
|
|
23
11
|
|
24
12
|
# Public: icon for omniauth buttons
|
25
13
|
def oauth_icon(provider)
|
26
|
-
info =
|
14
|
+
info = current_organization.enabled_omniauth_providers[provider.to_sym]
|
27
15
|
|
28
16
|
if info
|
29
17
|
icon_path = info[:icon_path]
|
@@ -35,5 +23,10 @@ module Decidim
|
|
35
23
|
name ||= normalize_provider_name(provider)
|
36
24
|
icon(name)
|
37
25
|
end
|
26
|
+
|
27
|
+
# Public: pretty print provider name
|
28
|
+
def provider_name(provider)
|
29
|
+
provider.to_s.gsub(/_|-/, " ").camelize
|
30
|
+
end
|
38
31
|
end
|
39
32
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# Helper to print resource versions.
|
5
|
+
module ResourceVersionsHelper
|
6
|
+
# Displays the localized version for the given resource.
|
7
|
+
#
|
8
|
+
# resource - the Resource that has the version to display.
|
9
|
+
# options - An optional hash of options
|
10
|
+
# * class: A string of extra css classes
|
11
|
+
#
|
12
|
+
# Returns a String.
|
13
|
+
def resource_version(resource, options = {})
|
14
|
+
return unless resource.respond_to?(:amendable?) && resource.amendable?
|
15
|
+
|
16
|
+
html = %(<strong class="text-uppercase">#{localized_version("version", resource.versions_count)}</strong> #{localized_version("of_versions", resource.versions_count)})
|
17
|
+
|
18
|
+
html += %( #{link_to(localized_version("see_other_versions"), options[:versions_path])}) if options[:versions_path]
|
19
|
+
|
20
|
+
"<div class='tech-info #{options[:class]}'>#{html}</div>".html_safe
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def localized_version(string, count = nil)
|
26
|
+
I18n.t(string, scope: "decidim.proposals.collaborative_drafts.show", number: count)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# Helper related to organization' setting :rich_text_editor_in_public_views.
|
5
|
+
module RichTextEditorHelper
|
6
|
+
def self.included(base)
|
7
|
+
base.include Decidim::SanitizeHelper
|
8
|
+
end
|
9
|
+
|
10
|
+
delegate :rich_text_editor_in_public_views?, to: :current_organization
|
11
|
+
|
12
|
+
def text_editor_for(form, attribute, options = {})
|
13
|
+
if rich_text_editor_in_public_views?
|
14
|
+
options[:lines] ||= 25
|
15
|
+
form.editor attribute, options
|
16
|
+
else
|
17
|
+
options[:rows] ||= 10
|
18
|
+
form.text_area attribute, options
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -3,7 +3,9 @@
|
|
3
3
|
module Decidim
|
4
4
|
# Helper that provides methods to render order selector and links
|
5
5
|
module SanitizeHelper
|
6
|
-
|
6
|
+
def self.included(base)
|
7
|
+
base.include ActionView::Helpers::SanitizeHelper
|
8
|
+
end
|
7
9
|
|
8
10
|
# Public: It sanitizes a user-inputted string with the
|
9
11
|
# `Decidim::UserInputScrubber` scrubber, so that video embeds work
|
@@ -78,10 +78,11 @@ module Decidim
|
|
78
78
|
form.scopes_picker name, options do |scope|
|
79
79
|
{
|
80
80
|
url: decidim.scopes_picker_path(
|
81
|
-
root: try(:current_participatory_space)
|
81
|
+
root: try(:current_participatory_space).try(:scope),
|
82
82
|
current: scope&.id,
|
83
83
|
title: I18n.t("decidim.scopes.prompt"),
|
84
|
-
global_value: "global"
|
84
|
+
global_value: "global",
|
85
|
+
max_depth: try(:current_participatory_space).try(:scope_type_max_depth)
|
85
86
|
),
|
86
87
|
text: scope_name_for_picker(scope, I18n.t("decidim.scopes.prompt"))
|
87
88
|
}
|
@@ -4,18 +4,26 @@ module Decidim
|
|
4
4
|
class DataPortabilityExportJob < ApplicationJob
|
5
5
|
queue_as :default
|
6
6
|
|
7
|
-
def perform(user,
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def perform(user, export_format = ::Decidim::DataPortabilityExporter::DEFAULT_EXPORT_FORMAT)
|
8
|
+
filename = "#{SecureRandom.urlsafe_base64}.zip"
|
9
|
+
path = Rails.root.join("tmp/#{filename}")
|
10
|
+
password = SecureRandom.urlsafe_base64
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
export_data << [klass.model_name.name.parameterize.pluralize, Decidim::Exporters.find_exporter(format).new(klass.user_collection(user), klass.export_serializer).export]
|
15
|
-
export_images << [klass.model_name.name.parameterize.pluralize, klass.data_portability_images(user).flatten] unless klass.data_portability_images(user).nil?
|
16
|
-
end
|
12
|
+
generate_zip_file(user, path, password, export_format)
|
13
|
+
save_or_upload_file(path)
|
17
14
|
|
18
|
-
ExportMailer.data_portability_export(user,
|
15
|
+
ExportMailer.data_portability_export(user, filename, password).deliver_later
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def generate_zip_file(user, path, password, export_format)
|
21
|
+
DataPortabilityExporter.new(user, path, password, export_format).export
|
22
|
+
end
|
23
|
+
|
24
|
+
# Saves to file system or uploads to storage service depending on the configuration.
|
25
|
+
def save_or_upload_file(path)
|
26
|
+
DataPortabilityUploader.new.store!(File.open(path, "rb"))
|
19
27
|
end
|
20
28
|
end
|
21
29
|
end
|
@@ -9,7 +9,7 @@ module Decidim
|
|
9
9
|
manifest.name == name.to_sym
|
10
10
|
end
|
11
11
|
|
12
|
-
collection = export_manifest.collection.call(component)
|
12
|
+
collection = export_manifest.collection.call(component, user)
|
13
13
|
serializer = export_manifest.serializer
|
14
14
|
|
15
15
|
export_data = Decidim::Exporters.find_exporter(format).new(collection, serializer).export
|
@@ -26,15 +26,19 @@ module Decidim
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
# Public: Sends a notification email with a link to retrieve
|
30
|
+
# the result of a data_portability export in a zipped file.
|
31
|
+
#
|
32
|
+
# user - The user to be notified.
|
33
|
+
#
|
34
|
+
# Returns nothing.
|
35
|
+
def data_portability_export(user, filename, password)
|
30
36
|
@user = user
|
31
37
|
@organization = user.organization
|
32
|
-
|
33
|
-
|
34
|
-
file_zipper.make_zip
|
38
|
+
@filename = filename
|
39
|
+
@password = password
|
35
40
|
|
36
41
|
with_user(user) do
|
37
|
-
@token = file_zipper.token
|
38
42
|
mail(to: "#{user.name} <#{user.email}>", subject: I18n.t("decidim.export_mailer.subject", name: user.name))
|
39
43
|
end
|
40
44
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class OmniauthProvider
|
5
|
+
def self.available
|
6
|
+
Rails.application.secrets[:omniauth] || {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.enabled
|
10
|
+
available.select do |_provider, settings|
|
11
|
+
settings[:enabled] == true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.extract_provider_key(enabled_setting_key)
|
16
|
+
enabled_setting_key.gsub("omniauth_settings_", "")
|
17
|
+
.gsub("_enabled", "").to_sym
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.extract_setting_key(setting_key, provider)
|
21
|
+
setting_key.gsub("omniauth_settings_#{provider}_", "").to_sym
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.value_defined?(value)
|
25
|
+
value.is_a?(String) && value.present?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -31,6 +31,7 @@ module Decidim
|
|
31
31
|
|
32
32
|
validates :name, :host, uniqueness: true
|
33
33
|
validates :reference_prefix, presence: true
|
34
|
+
validates :time_zone, presence: true, time_zone: true
|
34
35
|
validates :default_locale, inclusion: { in: :available_locales }
|
35
36
|
|
36
37
|
mount_uploader :official_img_header, Decidim::OfficialImageHeaderUploader
|
@@ -78,6 +79,11 @@ module Decidim
|
|
78
79
|
multi_translation("decidim.welcome_notification.default_body", available_locales)
|
79
80
|
end
|
80
81
|
|
82
|
+
def admin_terms_of_use_body
|
83
|
+
self[:admin_terms_of_use_body] ||
|
84
|
+
multi_translation("decidim.admin_terms_of_use.default_body", available_locales)
|
85
|
+
end
|
86
|
+
|
81
87
|
def sign_up_enabled?
|
82
88
|
users_registration_mode_enabled?
|
83
89
|
end
|
@@ -96,5 +102,40 @@ module Decidim
|
|
96
102
|
def open_data_file_path
|
97
103
|
"#{host}-open-data.zip"
|
98
104
|
end
|
105
|
+
|
106
|
+
def enabled_omniauth_providers
|
107
|
+
return Decidim::OmniauthProvider.enabled if omniauth_settings.nil?
|
108
|
+
|
109
|
+
Decidim::OmniauthProvider.enabled.merge(tenant_enabled_providers)
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
|
114
|
+
def tenant_enabled_providers
|
115
|
+
tenant_enabled_providers_keys = omniauth_settings.map do |k, v|
|
116
|
+
next unless k.match?(/omniauth_settings_.*_enabled/) && v == true
|
117
|
+
|
118
|
+
Decidim::OmniauthProvider.extract_provider_key(k)
|
119
|
+
end.compact.uniq
|
120
|
+
|
121
|
+
Hash[tenant_enabled_providers_keys.map do |k|
|
122
|
+
[k, omniauth_provider_settings(k)]
|
123
|
+
end]
|
124
|
+
end
|
125
|
+
|
126
|
+
def omniauth_provider_settings(provider)
|
127
|
+
provider_settings = {}
|
128
|
+
|
129
|
+
omniauth_settings.each do |key, value|
|
130
|
+
next unless key.to_s.include?(provider.to_s)
|
131
|
+
|
132
|
+
value = Decidim::AttributeEncryptor.decrypt(value) if Decidim::OmniauthProvider.value_defined?(value)
|
133
|
+
setting_key = Decidim::OmniauthProvider.extract_setting_key(key, provider)
|
134
|
+
|
135
|
+
provider_settings[setting_key] = value
|
136
|
+
end
|
137
|
+
|
138
|
+
provider_settings
|
139
|
+
end
|
99
140
|
end
|
100
141
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatorySpaceRoleConfig
|
5
|
+
class Base
|
6
|
+
def initialize(user_role)
|
7
|
+
@user_role = user_role
|
8
|
+
end
|
9
|
+
|
10
|
+
# Checks whether the given manifest name is accepted for this role.
|
11
|
+
#
|
12
|
+
# Returns a boolean.
|
13
|
+
def component_is_accessible?(manifest_name)
|
14
|
+
return true if accepted_components == [:all]
|
15
|
+
|
16
|
+
accepted_components.include?(manifest_name.to_sym)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Public: Lists the names of the accepted components for this role.
|
20
|
+
#
|
21
|
+
# Returns an Array of Symbols.
|
22
|
+
def accepted_components
|
23
|
+
[:all]
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :user_role
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/app/models/decidim/scope.rb
CHANGED
@@ -42,8 +42,10 @@ module Decidim
|
|
42
42
|
# Scope to return only the top level scopes.
|
43
43
|
#
|
44
44
|
# Returns an ActiveRecord::Relation.
|
45
|
-
def self.top_level
|
46
|
-
where parent_id: nil
|
45
|
+
def self.top_level(organization_id = nil)
|
46
|
+
query = where parent_id: nil
|
47
|
+
query = query.where(decidim_organization_id: organization_id) if organization_id
|
48
|
+
query
|
47
49
|
end
|
48
50
|
|
49
51
|
def self.log_presenter_class_for(_log)
|
data/app/models/decidim/user.rb
CHANGED
@@ -11,8 +11,6 @@ module Decidim
|
|
11
11
|
include Decidim::Searchable
|
12
12
|
include Decidim::ActsAsAuthor
|
13
13
|
|
14
|
-
OMNIAUTH_PROVIDERS = [:facebook, :twitter, :google_oauth2, (:developer if Rails.env.development?)].compact
|
15
|
-
|
16
14
|
class Roles
|
17
15
|
def self.all
|
18
16
|
Decidim.config.user_roles
|
@@ -22,7 +20,7 @@ module Decidim
|
|
22
20
|
devise :invitable, :database_authenticatable, :registerable, :confirmable, :timeoutable,
|
23
21
|
:recoverable, :rememberable, :trackable, :lockable,
|
24
22
|
:decidim_validatable, :decidim_newsletterable,
|
25
|
-
:omniauthable, omniauth_providers:
|
23
|
+
:omniauthable, omniauth_providers: Decidim::OmniauthProvider.available.keys,
|
26
24
|
request_keys: [:env], reset_password_keys: [:decidim_organization_id, :email],
|
27
25
|
confirmation_keys: [:decidim_organization_id, :email]
|
28
26
|
|
@@ -82,6 +80,12 @@ module Decidim
|
|
82
80
|
# Returns a String.
|
83
81
|
attr_accessor :invitation_instructions
|
84
82
|
|
83
|
+
# Returns the user corresponding to the given +email+ if it exists and has pending invitations,
|
84
|
+
# otherwise returns nil.
|
85
|
+
def self.has_pending_invitations?(organization_id, email)
|
86
|
+
invitation_not_accepted.find_by(decidim_organization_id: organization_id, email: email)
|
87
|
+
end
|
88
|
+
|
85
89
|
# Returns the presenter for this author, to be used in the views.
|
86
90
|
# Required by ActsAsAuthor.
|
87
91
|
def presenter
|
@@ -166,6 +170,10 @@ module Decidim
|
|
166
170
|
accepted_tos_version.to_i >= organization.tos_version.to_i
|
167
171
|
end
|
168
172
|
|
173
|
+
def admin_terms_accepted?
|
174
|
+
return true if admin_terms_accepted_at
|
175
|
+
end
|
176
|
+
|
169
177
|
# Whether this user can be verified against some authorization or not.
|
170
178
|
def verifiable?
|
171
179
|
confirmed? || managed? || being_impersonated?
|
@@ -183,6 +191,14 @@ module Decidim
|
|
183
191
|
@interested_scopes ||= organization.scopes.where(id: interested_scopes_ids)
|
184
192
|
end
|
185
193
|
|
194
|
+
# Caches a Decidim::DataPortabilityUploader with the retrieved file.
|
195
|
+
def data_portability_file(filename)
|
196
|
+
@data_portability_file ||= DataPortabilityUploader.new.tap do |uploader|
|
197
|
+
uploader.retrieve_from_store!(filename)
|
198
|
+
uploader.cache!(filename)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
186
202
|
protected
|
187
203
|
|
188
204
|
# Overrides devise email required validation.
|