decidim-core 0.10.1 → 0.11.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -11
- data/app/assets/images/decidim/icons.svg +25 -6
- data/app/assets/javascripts/decidim/account_form.js.es6 +8 -8
- data/app/assets/javascripts/decidim/append_elements.js.es6 +1 -1
- data/app/assets/javascripts/decidim/append_redirect_url_to_modals.js.es6 +5 -5
- data/app/assets/javascripts/decidim/data_picker.js.es6 +10 -10
- data/app/assets/javascripts/decidim/editor.js.es6 +37 -22
- data/app/assets/javascripts/decidim/filters.js.es6 +1 -1
- data/app/assets/javascripts/decidim/form_filter.component.js.es6 +15 -15
- data/app/assets/javascripts/decidim/form_filter.component.test.js +29 -29
- data/app/assets/javascripts/decidim/impersonation.js.es6 +3 -3
- data/app/assets/javascripts/decidim/input_mentions.js.es6 +100 -0
- data/app/assets/javascripts/decidim/input_tags.js.es6 +12 -0
- data/app/assets/javascripts/decidim/{map.js.es6.erb → map.js.es6} +9 -9
- data/app/assets/javascripts/decidim/notifications.js.es6 +10 -10
- data/app/assets/javascripts/decidim/orders.js.es6 +5 -5
- data/app/assets/javascripts/decidim/user_registrations.js.es6 +4 -4
- data/app/assets/javascripts/decidim/widget.js.es6 +1 -1
- data/app/assets/javascripts/decidim.js.es6 +10 -0
- data/app/assets/stylesheets/decidim/application.scss.erb +1 -1
- data/app/assets/stylesheets/decidim/modules/_author-avatar.scss +39 -0
- data/app/assets/stylesheets/decidim/modules/_cards.scss +158 -3
- data/app/assets/stylesheets/decidim/modules/_definition-data.scss +6 -0
- data/app/assets/stylesheets/decidim/modules/_extra.scss +1 -3
- data/app/assets/stylesheets/decidim/modules/_icons.scss +14 -6
- data/app/assets/stylesheets/decidim/modules/_inline-filters.scss +61 -0
- data/app/assets/stylesheets/decidim/modules/_input-mentions.scss +124 -0
- data/app/assets/stylesheets/decidim/modules/_input-tags.scss +55 -0
- data/app/assets/stylesheets/decidim/modules/_modules.scss +3 -0
- data/app/assets/stylesheets/decidim/modules/_status-labels.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_typography.scss +16 -0
- data/app/assets/stylesheets/decidim/utils/_helpers.scss +29 -0
- data/app/assets/stylesheets/decidim/utils/_mixins.scss +6 -0
- data/app/cells/decidim/author_box/show.erb +10 -0
- data/app/cells/decidim/author_box_cell.rb +21 -0
- data/app/cells/decidim/card/show.erb +17 -0
- data/app/cells/decidim/card_cell.rb +29 -0
- data/app/cells/decidim/profile/profile_inline.erb +21 -0
- data/app/cells/decidim/profile/show.erb +13 -0
- data/app/cells/decidim/profile_cell.rb +17 -0
- data/app/commands/decidim/create_omniauth_registration.rb +3 -2
- data/app/commands/decidim/create_report.rb +1 -1
- data/app/commands/decidim/invite_user.rb +2 -0
- data/app/constraints/decidim/current_component.rb +41 -0
- data/app/controllers/concerns/decidim/action_authorization.rb +3 -3
- data/app/controllers/concerns/decidim/devise_controllers.rb +2 -1
- data/app/controllers/concerns/decidim/filter_resource.rb +1 -1
- data/app/controllers/concerns/decidim/form_factory.rb +1 -1
- data/app/controllers/concerns/decidim/impersonate_users.rb +6 -2
- data/app/controllers/concerns/decidim/needs_authorization.rb +2 -2
- data/app/controllers/concerns/decidim/participatory_space_context.rb +15 -0
- data/app/controllers/concerns/decidim/settings.rb +5 -5
- data/app/controllers/decidim/application_controller.rb +2 -1
- data/app/controllers/decidim/{features → components}/base_controller.rb +16 -8
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +3 -1
- data/app/controllers/decidim/devise/registrations_controller.rb +1 -3
- data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +16 -0
- data/app/controllers/decidim/doorkeeper/credentials_controller.rb +46 -0
- data/app/controllers/decidim/doorkeeper/token_info_controller.rb +9 -0
- data/app/controllers/decidim/doorkeeper/tokens_controller.rb +9 -0
- data/app/controllers/decidim/widgets_controller.rb +1 -1
- data/app/forms/decidim/follow_form.rb +1 -1
- data/app/forms/decidim/form.rb +1 -1
- data/app/forms/decidim/omniauth_registration_form.rb +1 -0
- data/app/forms/decidim/registration_form.rb +5 -5
- data/app/helpers/decidim/card_helper.rb +16 -0
- data/app/helpers/decidim/component_path_helper.rb +36 -0
- data/app/helpers/decidim/icon_helper.rb +7 -7
- data/app/helpers/decidim/messaging/conversation_helper.rb +4 -3
- data/app/helpers/decidim/paginate_helper.rb +1 -1
- data/app/helpers/decidim/resource_helper.rb +2 -2
- data/app/jobs/decidim/export_job.rb +3 -3
- data/app/mailers/decidim/messaging/conversation_mailer.rb +0 -2
- data/app/middleware/decidim/current_organization.rb +2 -2
- data/app/models/decidim/abilities/admin_ability.rb +1 -1
- data/app/models/decidim/abilities/everyone_ability.rb +1 -1
- data/app/models/decidim/abilities/participatory_process_admin_ability.rb +2 -2
- data/app/models/decidim/abilities/participatory_process_collaborator_ability.rb +2 -2
- data/app/models/decidim/action_log.rb +7 -5
- data/app/models/decidim/area.rb +7 -0
- data/app/models/decidim/authorization.rb +14 -0
- data/app/models/decidim/{feature.rb → component.rb} +15 -15
- data/app/models/decidim/moderation.rb +1 -1
- data/app/models/decidim/oauth_application.rb +24 -0
- data/app/models/decidim/organization.rb +5 -0
- data/app/models/decidim/participatory_space_link.rb +20 -0
- data/app/models/decidim/participatory_space_private_user.rb +19 -0
- data/app/models/decidim/user.rb +7 -0
- data/app/presenters/decidim/admin_log/area_presenter.rb +38 -0
- data/app/presenters/decidim/admin_log/{feature_presenter.rb → component_presenter.rb} +5 -5
- data/app/presenters/decidim/admin_log/newsletter_resource_presenter.rb +1 -1
- data/app/presenters/decidim/admin_log/oauth_application_presenter.rb +50 -0
- data/app/presenters/decidim/admin_log/oauth_application_resource_presenter.rb +18 -0
- data/app/presenters/decidim/home_stats_presenter.rb +7 -7
- data/app/presenters/decidim/log/value_types/area_presenter.rb +1 -1
- data/app/presenters/decidim/log/value_types/area_type_presenter.rb +28 -0
- data/app/presenters/decidim/log/value_types/currency_presenter.rb +20 -0
- data/app/presenters/decidim/log/value_types/scope_presenter.rb +1 -1
- data/app/presenters/decidim/log/value_types/scope_type_presenter.rb +1 -1
- data/app/presenters/decidim/resource_locator_presenter.rb +3 -3
- data/app/services/decidim/action_authorizer.rb +9 -9
- data/app/services/decidim/action_logger.rb +9 -7
- data/app/services/decidim/email_notification_generator.rb +1 -1
- data/app/services/decidim/notification_generator_for_recipient.rb +1 -1
- data/app/services/decidim/resource_search.rb +8 -8
- data/app/services/decidim/settings_change.rb +5 -5
- data/app/services/decidim/static_map_generator.rb +1 -1
- data/app/types/decidim/core/attachment_type.rb +14 -0
- data/app/types/decidim/core/category_type.rb +16 -0
- data/app/types/decidim/core/coordinates_type.rb +19 -0
- data/app/types/decidim/core/scope_api_type.rb +16 -0
- data/app/uploaders/decidim/oauth_application_logo_uploader.rb +9 -0
- data/app/validators/geocoding_validator.rb +2 -2
- data/app/views/decidim/account/delete.html.erb +7 -7
- data/app/views/decidim/application/_collection.html.erb +1 -1
- data/app/views/decidim/application/_document.html.erb +1 -1
- data/app/views/decidim/application/_photos.html.erb +1 -1
- data/app/views/decidim/devise/invitations/edit.html.erb +1 -1
- data/app/views/decidim/devise/omniauth_registrations/new.html.erb +1 -1
- data/app/views/decidim/devise/registrations/new.html.erb +1 -1
- data/app/views/decidim/devise/sessions/new.html.erb +2 -2
- data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +1 -1
- data/app/views/decidim/devise/shared/_omniauth_buttons_mini.html.erb +1 -1
- data/app/views/decidim/doorkeeper/authorizations/new.html.erb +58 -0
- data/app/views/decidim/messaging/conversations/_show.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/index.html.erb +1 -1
- data/app/views/decidim/notifications/index.html.erb +1 -1
- data/app/views/decidim/notifications_settings/show.html.erb +2 -2
- data/app/views/decidim/own_user_groups/index.html.erb +3 -3
- data/app/views/decidim/scopes/_scopes_picker_input.html.erb +4 -4
- data/app/views/decidim/scopes/picker.html.erb +3 -3
- data/app/views/decidim/shared/_action_authorization_modal.html.erb +1 -1
- data/app/views/decidim/shared/_author.html.erb +1 -1
- data/app/views/decidim/shared/_author_reference.html.erb +1 -12
- data/app/views/decidim/shared/{_feature_announcement.html.erb → _component_announcement.html.erb} +2 -2
- data/app/views/decidim/shared/_embed_modal.html.erb +1 -1
- data/app/views/decidim/shared/_flag_modal.html.erb +5 -5
- data/app/views/decidim/shared/_login_modal.html.erb +3 -3
- data/app/views/decidim/shared/_private_participatory_space.html.erb +5 -0
- data/app/views/decidim/shared/_share_modal.html.erb +1 -1
- data/app/views/decidim/shared/_tags.html.erb +1 -1
- data/app/views/decidim/shared/_version_author.html.erb +1 -1
- data/app/views/decidim/widgets/_data_picker.html.erb +4 -4
- data/app/views/devise/mailer/confirmation_instructions.html.erb +3 -3
- data/app/views/devise/mailer/invite_private_user.html.erb +17 -0
- data/app/views/devise/mailer/invite_private_user.text.erb +15 -0
- data/app/views/devise/mailer/password_change.html.erb +2 -2
- data/app/views/devise/mailer/reset_password_instructions.html.erb +5 -5
- data/app/views/kaminari/decidim/_first_page.html.erb +2 -3
- data/app/views/kaminari/decidim/_gap.html.erb +2 -3
- data/app/views/kaminari/decidim/_last_page.html.erb +2 -3
- data/app/views/kaminari/decidim/_next_page.html.erb +2 -3
- data/app/views/kaminari/decidim/_page.html.erb +2 -3
- data/app/views/kaminari/decidim/_paginator.html.erb +1 -2
- data/app/views/kaminari/decidim/_prev_page.html.erb +2 -3
- data/app/views/layouts/decidim/_application.html.erb +4 -4
- data/app/views/layouts/decidim/_component_authorization_modals.html.erb +5 -0
- data/app/views/layouts/decidim/_cookie_warning.html.erb +2 -2
- data/app/views/layouts/decidim/_head.html.erb +4 -4
- data/app/views/layouts/decidim/_impersonation_warning.html.erb +4 -4
- data/app/views/layouts/decidim/_language_chooser.html.erb +1 -1
- data/app/views/layouts/decidim/_social_media_links.html.erb +5 -5
- data/app/views/layouts/decidim/_wrapper.html.erb +5 -5
- data/app/views/layouts/decidim/mailer.html.erb +1 -1
- data/app/views/layouts/decidim/widget.html.erb +5 -5
- data/app/views/pages/home/_hero.html.erb +1 -1
- data/app/views/pages/home.html.erb +6 -6
- data/config/locales/ca.yml +66 -27
- data/config/locales/en.yml +69 -30
- data/config/locales/es.yml +66 -27
- data/config/locales/eu.yml +69 -30
- data/config/locales/fi.yml +69 -30
- data/config/locales/fr.yml +85 -46
- data/config/locales/gl.yml +69 -30
- data/config/locales/it.yml +69 -30
- data/config/locales/nl.yml +122 -83
- data/config/locales/pl.yml +69 -30
- data/config/locales/pt-BR.yml +69 -30
- data/config/locales/pt.yml +69 -30
- data/config/locales/ru.yml +0 -7
- data/config/locales/sv.yml +69 -30
- data/config/locales/uk.yml +0 -13
- data/config/routes.rb +8 -0
- data/db/migrate/20180206183235_create_participatory_space_private_users.rb +15 -0
- data/db/migrate/20180221101934_fix_nickname_index.rb +5 -6
- data/db/migrate/20180226140756_add_version_to_action_logs.rb +5 -1
- data/db/migrate/20180227131727_create_participatory_space_links.rb +12 -0
- data/db/migrate/20180305132906_rename_features_to_components.rb +13 -0
- data/db/migrate/20180308113207_doorkeeper_models.rb +85 -0
- data/db/migrate/20180314085339_rename_maximum_votes_per_proposal_to_threshold_per_proposal.rb +2 -2
- data/db/migrate/{20180326075746_change_event_name_and_class_to_rename_to_publish_proposal_event.rb → 20180323102631_change_event_name_and_class_to_rename_to_publish_proposal_event.rb} +0 -0
- data/db/seeds.rb +12 -2
- data/lib/decidim/api/attachable_interface.rb +13 -0
- data/lib/decidim/api/authorable_interface.rb +13 -0
- data/lib/decidim/api/categorizable_interface.rb +13 -0
- data/lib/decidim/api/participatory_space_interface.rb +4 -4
- data/lib/decidim/api/scopable_interface.rb +13 -0
- data/lib/decidim/authorable.rb +8 -0
- data/lib/decidim/{feature_manifest.rb → component_manifest.rb} +24 -21
- data/lib/decidim/{feature_validator.rb → component_validator.rb} +6 -6
- data/lib/decidim/{features → components}/export_manifest.rb +4 -4
- data/lib/decidim/components/namer.rb +35 -0
- data/lib/decidim/components.rb +9 -0
- data/lib/decidim/content_parsers/user_parser.rb +1 -1
- data/lib/decidim/core/api.rb +13 -0
- data/lib/decidim/core/engine.rb +76 -3
- data/lib/decidim/core/test/factories.rb +43 -10
- data/lib/decidim/core/test/shared_examples/announcements_examples.rb +9 -9
- data/lib/decidim/core/test/shared_examples/attachable_interface_examples.rb +16 -0
- data/lib/decidim/core/test/shared_examples/authorable_interface_examples.rb +33 -0
- data/lib/decidim/core/test/shared_examples/categorizable_interface_examples.rb +19 -0
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +3 -3
- data/lib/decidim/core/test/shared_examples/follows_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/has_component.rb +21 -0
- data/lib/decidim/core/test/shared_examples/has_reference.rb +2 -2
- data/lib/decidim/core/test/shared_examples/localised_email.rb +1 -1
- data/lib/decidim/core/test/shared_examples/paginated_resource_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/reportable.rb +8 -6
- data/lib/decidim/core/test/shared_examples/reports_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/scopable_interface_examples.rb +19 -0
- data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +8 -3
- data/lib/decidim/core/test/shared_examples/simple_event.rb +1 -1
- data/lib/decidim/core/test/shared_examples/user_localised_email_examples.rb +1 -1
- data/lib/decidim/core/test.rb +1 -1
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/core.rb +35 -37
- data/lib/decidim/events/base_event.rb +5 -5
- data/lib/decidim/events/simple_event.rb +8 -8
- data/lib/decidim/form_builder.rb +48 -3
- data/lib/decidim/has_attachment_collections.rb +1 -1
- data/lib/decidim/has_attachments.rb +1 -1
- data/lib/decidim/has_category.rb +2 -2
- data/lib/decidim/has_component.rb +23 -0
- data/lib/decidim/has_private_users.rb +26 -0
- data/lib/decidim/has_reference.rb +3 -3
- data/lib/decidim/page_finder.rb +1 -1
- data/lib/decidim/participatory_space_manifest.rb +3 -3
- data/lib/decidim/participatory_space_resourceable.rb +80 -0
- data/lib/decidim/publicable.rb +2 -2
- data/lib/decidim/query_extensions.rb +2 -2
- data/lib/decidim/rectify_ext.rb +32 -0
- data/lib/decidim/reportable.rb +1 -1
- data/lib/decidim/resource_manifest.rb +13 -13
- data/lib/decidim/resourceable.rb +8 -8
- data/lib/decidim/scopable.rb +1 -1
- data/lib/decidim/{scopable_feature.rb → scopable_component.rb} +1 -1
- data/lib/decidim/settings_manifest.rb +1 -1
- data/lib/decidim/stats_registry.rb +1 -1
- data/lib/decidim/view_model.rb +9 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.fr.js +4 -1
- data/vendor/assets/javascripts/form_datepicker.js.es6 +10 -10
- data/vendor/assets/javascripts/quill.min.js +2 -2
- data/vendor/assets/javascripts/quill.min.js.map +1 -1
- data/vendor/assets/javascripts/tagsinput.js +683 -0
- data/vendor/assets/javascripts/tribute.js +1607 -0
- data/vendor/assets/stylesheets/quill.bubble.css +30 -16
- data/vendor/assets/stylesheets/quill.core.css +19 -9
- data/vendor/assets/stylesheets/quill.snow.css +30 -16
- data/vendor/assets/stylesheets/tagsinput.css +55 -0
- data/vendor/assets/stylesheets/tribute.css +27 -0
- metadata +164 -27
- data/app/constraints/decidim/current_feature.rb +0 -41
- data/app/helpers/decidim/feature_path_helper.rb +0 -36
- data/app/views/layouts/decidim/_feature_authorization_modals.html.erb +0 -5
- data/lib/decidim/core/test/shared_examples/has_feature.rb +0 -21
- data/lib/decidim/features/namer.rb +0 -35
- data/lib/decidim/features.rb +0 -9
- data/lib/decidim/has_feature.rb +0 -23
@@ -3,15 +3,15 @@
|
|
3
3
|
module Decidim
|
4
4
|
# Helpers related to icons
|
5
5
|
module IconHelper
|
6
|
-
# Public: Returns an icon given an instance of a
|
6
|
+
# Public: Returns an icon given an instance of a Component. It defaults to
|
7
7
|
# a question mark when no icon is found.
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# component - The component to generate the icon for.
|
10
10
|
# options - a Hash with options
|
11
11
|
#
|
12
12
|
# Returns an HTML tag with the icon.
|
13
|
-
def
|
14
|
-
manifest_icon(
|
13
|
+
def component_icon(component, options = {})
|
14
|
+
manifest_icon(component.manifest, options)
|
15
15
|
end
|
16
16
|
|
17
17
|
# Public: Returns an icon given an instance of a Manifest. It defaults to
|
@@ -30,7 +30,7 @@ module Decidim
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Public: Finds the correct icon for the given resource. If the resource has a
|
33
|
-
#
|
33
|
+
# Component then it uses it to find the icon, otherwise checks for the resource
|
34
34
|
# manifest to find the icon.
|
35
35
|
#
|
36
36
|
# resource - The resource to generate the icon for.
|
@@ -38,8 +38,8 @@ module Decidim
|
|
38
38
|
#
|
39
39
|
# Returns an HTML tag with the icon.
|
40
40
|
def resource_icon(resource, options = {})
|
41
|
-
if resource.respond_to?(:
|
42
|
-
|
41
|
+
if resource.respond_to?(:component)
|
42
|
+
component_icon(resource.component, options)
|
43
43
|
elsif resource.respond_to?(:manifest)
|
44
44
|
manifest_icon(resource.manifest, options)
|
45
45
|
elsif resource.is_a?(Decidim::User)
|
@@ -28,14 +28,15 @@ module Decidim
|
|
28
28
|
# @return [String] The resulting route
|
29
29
|
#
|
30
30
|
def current_or_new_conversation_path_with(user)
|
31
|
-
|
31
|
+
decidim_routes = Decidim::Core::Engine.routes.url_helpers
|
32
|
+
return decidim_routes.new_user_session_path unless user_signed_in?
|
32
33
|
|
33
34
|
conversation = conversation_between(current_user, user)
|
34
35
|
|
35
36
|
if conversation
|
36
|
-
|
37
|
+
decidim_routes.conversation_path(conversation)
|
37
38
|
else
|
38
|
-
|
39
|
+
decidim_routes.new_conversation_path(recipient_id: user.id)
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
@@ -13,7 +13,7 @@ module Decidim
|
|
13
13
|
# and unless we remove these params they are added again as query string :(
|
14
14
|
default_params = {
|
15
15
|
participatory_process_id: nil,
|
16
|
-
|
16
|
+
component_id: nil
|
17
17
|
}
|
18
18
|
|
19
19
|
paginate collection, theme: "decidim", params: paginate_params.merge(default_params)
|
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
end)
|
28
28
|
end
|
29
29
|
|
30
|
-
# Gets the classes linked to the given class for the `
|
30
|
+
# Gets the classes linked to the given class for the `current_component`, and formats
|
31
31
|
# them in a nice way so that they can be used in a form. Resulting format looks like
|
32
32
|
# this, considering the given class is related to `Decidim::Meetings::Meeting`:
|
33
33
|
#
|
@@ -44,7 +44,7 @@ module Decidim
|
|
44
44
|
def linked_classes_for(klass)
|
45
45
|
return [] unless klass.respond_to?(:linked_classes_for)
|
46
46
|
|
47
|
-
klass.linked_classes_for(
|
47
|
+
klass.linked_classes_for(current_component).map do |k|
|
48
48
|
[k.underscore, t(k.demodulize.downcase, scope: "decidim.filters.linked_classes")]
|
49
49
|
end
|
50
50
|
end
|
@@ -4,12 +4,12 @@ module Decidim
|
|
4
4
|
class ExportJob < ApplicationJob
|
5
5
|
queue_as :default
|
6
6
|
|
7
|
-
def perform(user,
|
8
|
-
export_manifest =
|
7
|
+
def perform(user, component, name, format)
|
8
|
+
export_manifest = component.manifest.export_manifests.find do |manifest|
|
9
9
|
manifest.name == name.to_sym
|
10
10
|
end
|
11
11
|
|
12
|
-
collection = export_manifest.collection.call(
|
12
|
+
collection = export_manifest.collection.call(component)
|
13
13
|
serializer = export_manifest.serializer
|
14
14
|
|
15
15
|
export_data = Decidim::Exporters.find_exporter(format).new(collection, serializer).export
|
@@ -25,7 +25,6 @@ module Decidim
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
# rubocop:disable Naming/UncommunicativeMethodParamName
|
29
28
|
def notification_mail(from:, to:, conversation:, action:)
|
30
29
|
with_user(to) do
|
31
30
|
@organization = to.organization
|
@@ -42,7 +41,6 @@ module Decidim
|
|
42
41
|
|
43
42
|
mail(to: to.email, subject: subject)
|
44
43
|
end
|
45
|
-
# rubocop:enable Naming/UncommunicativeMethodParamName
|
46
44
|
end
|
47
45
|
end
|
48
46
|
end
|
@@ -33,12 +33,12 @@ module Decidim
|
|
33
33
|
|
34
34
|
def detect_current_organization(env)
|
35
35
|
host = host_for(env)
|
36
|
-
Decidim::Organization.
|
36
|
+
Decidim::Organization.find_by(host: host)
|
37
37
|
end
|
38
38
|
|
39
39
|
def find_secondary_host_org(env)
|
40
40
|
host = host_for(env)
|
41
|
-
Decidim::Organization.
|
41
|
+
Decidim::Organization.find_by("? = ANY(secondary_hosts)", host)
|
42
42
|
end
|
43
43
|
|
44
44
|
def host_for(env)
|
@@ -19,8 +19,8 @@ module Decidim
|
|
19
19
|
can_manage_process?(process)
|
20
20
|
end
|
21
21
|
|
22
|
-
can :read,
|
23
|
-
can_manage_process?(
|
22
|
+
can :read, Component do |component|
|
23
|
+
can_manage_process?(component.participatory_space)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -19,8 +19,8 @@ module Decidim
|
|
19
19
|
can_manage_process?(process)
|
20
20
|
end
|
21
21
|
|
22
|
-
can :read,
|
23
|
-
can_manage_process?(
|
22
|
+
can :read, Component do |component|
|
23
|
+
can_manage_process?(component.participatory_space)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -13,13 +13,14 @@ module Decidim
|
|
13
13
|
foreign_key: :decidim_user_id,
|
14
14
|
class_name: "Decidim::User"
|
15
15
|
|
16
|
-
belongs_to :
|
17
|
-
foreign_key: :
|
16
|
+
belongs_to :component,
|
17
|
+
foreign_key: :decidim_component_id,
|
18
18
|
optional: true,
|
19
|
-
class_name: "Decidim::
|
19
|
+
class_name: "Decidim::Component"
|
20
20
|
|
21
21
|
belongs_to :resource,
|
22
|
-
polymorphic: true
|
22
|
+
polymorphic: true,
|
23
|
+
optional: true
|
23
24
|
|
24
25
|
belongs_to :participatory_space,
|
25
26
|
optional: true,
|
@@ -29,7 +30,8 @@ module Decidim
|
|
29
30
|
optional: true,
|
30
31
|
class_name: "PaperTrail::Version"
|
31
32
|
|
32
|
-
validates :organization, :user, :action,
|
33
|
+
validates :organization, :user, :action, presence: true
|
34
|
+
validates :resource, presence: true, if: ->(log) { log.action != "delete" }
|
33
35
|
|
34
36
|
# To ensure records can't be deleted
|
35
37
|
before_destroy { |_record| raise ActiveRecord::ReadOnlyRecord }
|
data/app/models/decidim/area.rb
CHANGED
@@ -4,6 +4,9 @@ module Decidim
|
|
4
4
|
# Areas are used in Assemblies to help users know which is
|
5
5
|
# the Area of a participatory space.
|
6
6
|
class Area < ApplicationRecord
|
7
|
+
include Traceable
|
8
|
+
include Loggable
|
9
|
+
|
7
10
|
belongs_to :organization,
|
8
11
|
foreign_key: "decidim_organization_id",
|
9
12
|
class_name: "Decidim::Organization",
|
@@ -18,6 +21,10 @@ module Decidim
|
|
18
21
|
validates :name, :organization, presence: true
|
19
22
|
validates :name, uniqueness: { scope: :organization }
|
20
23
|
|
24
|
+
def self.log_presenter_class_for(_log)
|
25
|
+
Decidim::AdminLog::AreaPresenter
|
26
|
+
end
|
27
|
+
|
21
28
|
def translated_name
|
22
29
|
Decidim::AreaPresenter.new(self).translated_name
|
23
30
|
end
|
@@ -22,6 +22,20 @@ module Decidim
|
|
22
22
|
|
23
23
|
validate :active_handler?
|
24
24
|
|
25
|
+
def self.create_or_update_from(handler)
|
26
|
+
authorization = find_or_initialize_by(
|
27
|
+
user: handler.user,
|
28
|
+
name: handler.handler_name
|
29
|
+
)
|
30
|
+
|
31
|
+
authorization.attributes = {
|
32
|
+
unique_id: handler.unique_id,
|
33
|
+
metadata: handler.metadata
|
34
|
+
}
|
35
|
+
|
36
|
+
authorization.grant!
|
37
|
+
end
|
38
|
+
|
25
39
|
def grant!
|
26
40
|
remove_verification_attachment!
|
27
41
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
|
-
# A
|
5
|
-
# defined via a
|
6
|
-
#
|
7
|
-
class
|
4
|
+
# A Component represents a self-contained group of functionalities usually
|
5
|
+
# defined via a ComponentManifest. It's meant to be able to provide a single
|
6
|
+
# component that spans over several steps.
|
7
|
+
class Component < ApplicationRecord
|
8
8
|
include HasSettings
|
9
9
|
include Publicable
|
10
10
|
include Traceable
|
@@ -12,45 +12,45 @@ module Decidim
|
|
12
12
|
|
13
13
|
belongs_to :participatory_space, polymorphic: true
|
14
14
|
|
15
|
-
default_scope { order(arel_table[:weight].asc) }
|
15
|
+
default_scope { order(arel_table[:weight].asc, arel_table[:manifest_name].asc) }
|
16
16
|
|
17
17
|
delegate :organization, :categories, to: :participatory_space
|
18
18
|
|
19
19
|
def self.log_presenter_class_for(_log)
|
20
|
-
Decidim::AdminLog::
|
20
|
+
Decidim::AdminLog::ComponentPresenter
|
21
21
|
end
|
22
22
|
|
23
|
-
# Public: Finds the manifest this
|
23
|
+
# Public: Finds the manifest this component is associated to.
|
24
24
|
#
|
25
|
-
# Returns a
|
25
|
+
# Returns a ComponentManifest.
|
26
26
|
def manifest
|
27
|
-
Decidim.
|
27
|
+
Decidim.find_component_manifest(manifest_name)
|
28
28
|
end
|
29
29
|
|
30
|
-
# Public: Assigns a manifest to this
|
30
|
+
# Public: Assigns a manifest to this component.
|
31
31
|
#
|
32
|
-
# manifest - The
|
32
|
+
# manifest - The ComponentManifest for this Component.
|
33
33
|
#
|
34
34
|
# Returns nothing.
|
35
35
|
def manifest=(manifest)
|
36
36
|
self.manifest_name = manifest.name
|
37
37
|
end
|
38
38
|
|
39
|
-
# Public: The name of the engine the
|
39
|
+
# Public: The name of the engine the component is mounted to.
|
40
40
|
def mounted_engine
|
41
41
|
"decidim_#{participatory_space_name}_#{manifest_name}"
|
42
42
|
end
|
43
43
|
|
44
|
-
# Public: The name of the admin engine the
|
44
|
+
# Public: The name of the admin engine the component is mounted to.
|
45
45
|
def mounted_admin_engine
|
46
46
|
"decidim_admin_#{participatory_space_name}_#{manifest_name}"
|
47
47
|
end
|
48
48
|
|
49
|
-
# Public: The hash of contextual params when the
|
49
|
+
# Public: The hash of contextual params when the component is mounted.
|
50
50
|
def mounted_params
|
51
51
|
{
|
52
52
|
host: organization.host,
|
53
|
-
|
53
|
+
component_id: id,
|
54
54
|
"#{participatory_space.underscored_name}_slug".to_sym => participatory_space.slug
|
55
55
|
}
|
56
56
|
end
|
@@ -10,7 +10,7 @@ module Decidim
|
|
10
10
|
belongs_to :participatory_space, foreign_key: "decidim_participatory_space_id", foreign_type: "decidim_participatory_space_type", polymorphic: true
|
11
11
|
has_many :reports, foreign_key: "decidim_moderation_id", class_name: "Decidim::Report", dependent: :destroy
|
12
12
|
|
13
|
-
delegate :
|
13
|
+
delegate :component, :organization, to: :reportable
|
14
14
|
|
15
15
|
def self.log_presenter_class_for(_log)
|
16
16
|
Decidim::AdminLog::ModerationPresenter
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class OAuthApplication < ::Doorkeeper::Application
|
5
|
+
include Decidim::Traceable
|
6
|
+
include Decidim::Loggable
|
7
|
+
|
8
|
+
belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization", inverse_of: :oauth_applications
|
9
|
+
|
10
|
+
mount_uploader :organization_logo, OAuthApplicationLogoUploader
|
11
|
+
|
12
|
+
def owner
|
13
|
+
organization
|
14
|
+
end
|
15
|
+
|
16
|
+
def type
|
17
|
+
"Decidim::OAuthApplication"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.log_presenter_class_for(_log)
|
21
|
+
Decidim::AdminLog::OAuthApplicationPresenter
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -18,6 +18,7 @@ module Decidim
|
|
18
18
|
has_many :admins, -> { where(admin: true) }, foreign_key: "decidim_organization_id", class_name: "Decidim::User"
|
19
19
|
has_many :users_with_any_role, -> { where.not(roles: []) }, foreign_key: "decidim_organization_id", class_name: "Decidim::User"
|
20
20
|
has_many :users, foreign_key: "decidim_organization_id", class_name: "Decidim::User", dependent: :destroy
|
21
|
+
has_many :oauth_applications, foreign_key: "decidim_organization_id", class_name: "Decidim::OAuthApplication", inverse_of: :organization, dependent: :destroy
|
21
22
|
|
22
23
|
validates :name, :host, uniqueness: true
|
23
24
|
validates :reference_prefix, presence: true
|
@@ -34,6 +35,10 @@ module Decidim
|
|
34
35
|
Decidim::AdminLog::OrganizationPresenter
|
35
36
|
end
|
36
37
|
|
38
|
+
def available_authorization_handlers
|
39
|
+
available_authorizations & Decidim.authorization_handlers.map(&:name)
|
40
|
+
end
|
41
|
+
|
37
42
|
# Returns top level scopes for this organization.
|
38
43
|
#
|
39
44
|
# Returns an ActiveRecord::Relation.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class ParticipatorySpaceLink < ApplicationRecord
|
5
|
+
belongs_to :from, polymorphic: true
|
6
|
+
belongs_to :to, polymorphic: true
|
7
|
+
|
8
|
+
validates :name, presence: true, uniqueness: { scope: [:from, :to] }
|
9
|
+
validate :same_organization
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def same_organization
|
14
|
+
return if from.try(:organization) == to.try(:organization)
|
15
|
+
|
16
|
+
errors.add(:from, :invalid)
|
17
|
+
errors.add(:to, :invalid)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This class gives a given User access to a given private ParticipatorySpacePrivateUser
|
5
|
+
class ParticipatorySpacePrivateUser < ApplicationRecord
|
6
|
+
belongs_to :user, class_name: "Decidim::User", foreign_key: :decidim_user_id
|
7
|
+
belongs_to :privatable_to, polymorphic: true
|
8
|
+
|
9
|
+
validate :user_and_participatory_space_same_organization
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# Private: check if the participatory space and the user have the same organization
|
14
|
+
def user_and_participatory_space_same_organization
|
15
|
+
return if !privatable_to || !user
|
16
|
+
errors.add(:privatable_to, :invalid) unless user.organization == privatable_to.organization
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/app/models/decidim/user.rb
CHANGED
@@ -23,6 +23,8 @@ module Decidim
|
|
23
23
|
has_many :memberships, class_name: "Decidim::UserGroupMembership", foreign_key: :decidim_user_id, dependent: :destroy
|
24
24
|
has_many :user_groups, through: :memberships, class_name: "Decidim::UserGroup", foreign_key: :decidim_user_group_id
|
25
25
|
has_many :notifications, foreign_key: "decidim_user_id", class_name: "Decidim::Notification", dependent: :destroy
|
26
|
+
has_many :access_grants, class_name: "Doorkeeper::AccessGrant", foreign_key: :resource_owner_id, dependent: :destroy
|
27
|
+
has_many :access_tokens, class_name: "Doorkeeper::AccessToken", foreign_key: :resource_owner_id, dependent: :destroy
|
26
28
|
|
27
29
|
validates :name, presence: true, unless: -> { deleted? }
|
28
30
|
validates :nickname, presence: true, unless: -> { deleted? || managed? }
|
@@ -36,7 +38,12 @@ module Decidim
|
|
36
38
|
mount_uploader :avatar, Decidim::AvatarUploader
|
37
39
|
|
38
40
|
scope :not_deleted, -> { where(deleted_at: nil) }
|
41
|
+
|
39
42
|
scope :managed, -> { where(managed: true) }
|
43
|
+
scope :not_managed, -> { where(managed: false) }
|
44
|
+
|
45
|
+
scope :officialized, -> { where.not(officialized_at: nil) }
|
46
|
+
scope :not_officialized, -> { where(officialized_at: nil) }
|
40
47
|
|
41
48
|
# Public: Allows customizing the invitation instruction email content when
|
42
49
|
# inviting a user.
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module AdminLog
|
5
|
+
# This class holds the logic to present a `Decidim::Area`
|
6
|
+
# for the `AdminLog` log.
|
7
|
+
#
|
8
|
+
# Usage should be automatic and you shouldn't need to call this class
|
9
|
+
# directly, but here's an example:
|
10
|
+
#
|
11
|
+
# action_log = Decidim::ActionLog.last
|
12
|
+
# view_helpers # => this comes from the views
|
13
|
+
# AreaPresenter.new(action_log, view_helpers).present
|
14
|
+
class AreaPresenter < Decidim::Log::BasePresenter
|
15
|
+
private
|
16
|
+
|
17
|
+
def diff_fields_mapping
|
18
|
+
{
|
19
|
+
name: :i18n,
|
20
|
+
area_type_id: :area_type
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def action_string
|
25
|
+
case action
|
26
|
+
when "create", "delete", "update"
|
27
|
+
"decidim.admin_log.area.#{action}"
|
28
|
+
else
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def i18n_labels_scope
|
34
|
+
"activemodel.attributes.area"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module AdminLog
|
5
|
-
# This class holds the logic to present a `Decidim::
|
5
|
+
# This class holds the logic to present a `Decidim::Component`
|
6
6
|
# for the `AdminLog` log.
|
7
7
|
#
|
8
8
|
# Usage should be automatic and you shouldn't need to call this class
|
@@ -10,8 +10,8 @@ module Decidim
|
|
10
10
|
#
|
11
11
|
# action_log = Decidim::ActionLog.last
|
12
12
|
# view_helpers # => this comes from the views
|
13
|
-
#
|
14
|
-
class
|
13
|
+
# ComponentPresenter.new(action_log, view_helpers).present
|
14
|
+
class ComponentPresenter < Decidim::Log::BasePresenter
|
15
15
|
private
|
16
16
|
|
17
17
|
def diff_fields_mapping
|
@@ -23,13 +23,13 @@ module Decidim
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def i18n_labels_scope
|
26
|
-
"activemodel.attributes.
|
26
|
+
"activemodel.attributes.component"
|
27
27
|
end
|
28
28
|
|
29
29
|
def action_string
|
30
30
|
case action
|
31
31
|
when "create", "delete", "publish", "unpublish"
|
32
|
-
"decidim.admin_log.
|
32
|
+
"decidim.admin_log.component.#{action}"
|
33
33
|
else
|
34
34
|
super
|
35
35
|
end
|
@@ -7,7 +7,7 @@ module Decidim
|
|
7
7
|
class NewsletterResourcePresenter < Decidim::Log::ResourcePresenter
|
8
8
|
private
|
9
9
|
|
10
|
-
# Private: Finds the
|
10
|
+
# Private: Finds the admin link for the newsletter.
|
11
11
|
#
|
12
12
|
# Returns an HTML-safe String.
|
13
13
|
def resource_path
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module AdminLog
|
5
|
+
# This class holds the logic to present a `Decidim::OAuthApplication`
|
6
|
+
# for the `AdminLog` log.
|
7
|
+
#
|
8
|
+
# Usage should be automatic and you shouldn't need to call this class
|
9
|
+
# directly, but here's an example:
|
10
|
+
#
|
11
|
+
# action_log = Decidim::ActionLog.last
|
12
|
+
# view_helpers # => this comes from the views
|
13
|
+
# OAuthApplicationPresenter.new(action_log, view_helpers).present
|
14
|
+
class OAuthApplicationPresenter < Decidim::Log::BasePresenter
|
15
|
+
private
|
16
|
+
|
17
|
+
def diff_fields_mapping
|
18
|
+
{
|
19
|
+
name: :string,
|
20
|
+
organization_name: :string,
|
21
|
+
organization_url: :string,
|
22
|
+
organization_logo: :string,
|
23
|
+
redirect_uri: :string
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def action_string
|
28
|
+
case action
|
29
|
+
when "create", "delete", "update"
|
30
|
+
"decidim.admin_log.oauth_application.#{action}"
|
31
|
+
else
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def i18n_labels_scope
|
37
|
+
"activemodel.attributes.oauth_application"
|
38
|
+
end
|
39
|
+
|
40
|
+
# Private: Caches the object that will be responsible of presenting the OAuthApplication.
|
41
|
+
# Overwrites the method so that we can use a custom presenter to show the correct
|
42
|
+
# path for the OAuthApplication.
|
43
|
+
#
|
44
|
+
# Returns an object that responds to `present`.
|
45
|
+
def resource_presenter
|
46
|
+
@resource_presenter ||= Decidim::AdminLog::OAuthApplicationResourcePresenter.new(action_log.resource, h, action_log.extra["resource"])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module AdminLog
|
5
|
+
# This class extends the default resource presenter for logs, so that
|
6
|
+
# it can properly link to the OAuthApplication.
|
7
|
+
class OAuthApplicationResourcePresenter < Decidim::Log::ResourcePresenter
|
8
|
+
private
|
9
|
+
|
10
|
+
# Private: Finds the admin link for the OAuthApplication.
|
11
|
+
#
|
12
|
+
# Returns an HTML-safe String.
|
13
|
+
def resource_path
|
14
|
+
@resource_path ||= h.decidim_admin.oauth_application_path(resource)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -9,7 +9,7 @@ module Decidim
|
|
9
9
|
def highlighted
|
10
10
|
highlighted_stats = Decidim.stats.only([:users_count, :processes_count]).with_context(organization).map { |name, data| [name, data] }
|
11
11
|
highlighted_stats = highlighted_stats.concat(global_stats(priority: StatsRegistry::HIGH_PRIORITY))
|
12
|
-
highlighted_stats = highlighted_stats.concat(
|
12
|
+
highlighted_stats = highlighted_stats.concat(component_stats(priority: StatsRegistry::HIGH_PRIORITY))
|
13
13
|
highlighted_stats = highlighted_stats.reject(&:empty?)
|
14
14
|
highlighted_stats = highlighted_stats.reject { |_name, data| data.zero? }
|
15
15
|
|
@@ -29,7 +29,7 @@ module Decidim
|
|
29
29
|
# Public: Render a collection of stats that are not primary.
|
30
30
|
def not_highlighted
|
31
31
|
not_highlighted_stats = global_stats(priority: StatsRegistry::MEDIUM_PRIORITY)
|
32
|
-
not_highlighted_stats = not_highlighted_stats.concat(
|
32
|
+
not_highlighted_stats = not_highlighted_stats.concat(component_stats(priority: StatsRegistry::MEDIUM_PRIORITY))
|
33
33
|
not_highlighted_stats = not_highlighted_stats.reject(&:empty?)
|
34
34
|
not_highlighted_stats = not_highlighted_stats.reject { |_name, data| data.zero? }
|
35
35
|
|
@@ -55,9 +55,9 @@ module Decidim
|
|
55
55
|
.map { |name, data| [name, data] }
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
59
|
-
Decidim.
|
60
|
-
|
58
|
+
def component_stats(conditions)
|
59
|
+
Decidim.component_manifests.flat_map do |component|
|
60
|
+
component.stats.filter(conditions).with_context(published_components).map { |name, data| [name, data] }
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -80,8 +80,8 @@ module Decidim
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
def
|
84
|
-
@
|
83
|
+
def published_components
|
84
|
+
@published_components ||= Component.where(participatory_space: public_participatory_spaces).published
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|