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
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This cell renders the card of the given instance of a Component
|
5
|
+
# delegated to the components' cell if specified in the manifest
|
6
|
+
# otherwise a primary cell wil be shown.
|
7
|
+
class CardCell < Decidim::ViewModel
|
8
|
+
property :body
|
9
|
+
property :title
|
10
|
+
|
11
|
+
def show
|
12
|
+
if resource_cell?
|
13
|
+
cell(resource_cell, model, options)
|
14
|
+
else
|
15
|
+
render :show
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def resource_cell?
|
22
|
+
resource_cell.present?
|
23
|
+
end
|
24
|
+
|
25
|
+
def resource_cell
|
26
|
+
@resource_cell ||= model.component.manifest.card
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<span class="author__avatar author__avatar--small">
|
2
|
+
<%= image_tag model.avatar_url %>
|
3
|
+
</span>
|
4
|
+
|
5
|
+
<% if model.deleted? %>
|
6
|
+
<span class="label label--small label--basic">
|
7
|
+
<%= t("decidim.profile.deleted") %>
|
8
|
+
</span>
|
9
|
+
<% else %>
|
10
|
+
<span class="author__name"><%= model.name %></span>
|
11
|
+
|
12
|
+
<% if model.badge.present? %>
|
13
|
+
<span class="author__badge">
|
14
|
+
<%= icon model.badge %>
|
15
|
+
</span>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<% if model.nickname.present? %>
|
19
|
+
<span class="author__nickname"><%= model.nickname %></span>
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="author author--inline">
|
2
|
+
<% if model.profile_path.present? %>
|
3
|
+
<%= link_to model.profile_path do %>
|
4
|
+
<%= render :profile_inline %>
|
5
|
+
<% end %>
|
6
|
+
<% else %>
|
7
|
+
<%= render :profile_inline %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% if model.profile_path.present? %>
|
11
|
+
<%= link_to_current_or_new_conversation_with(model) %>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This cell renders the avatar, name and nickname of
|
5
|
+
# the given user or user group, and adds some links
|
6
|
+
# to potential actions on the given profile.
|
7
|
+
class ProfileCell < Decidim::ViewModel
|
8
|
+
include LayoutHelper
|
9
|
+
include Messaging::ConversationHelper
|
10
|
+
|
11
|
+
def show
|
12
|
+
render
|
13
|
+
end
|
14
|
+
|
15
|
+
delegate :user_signed_in?, :current_user, to: :parent_controller
|
16
|
+
end
|
17
|
+
end
|
@@ -55,6 +55,7 @@ module Decidim
|
|
55
55
|
@user.email_on_notification = true
|
56
56
|
@user.password = generated_password
|
57
57
|
@user.password_confirmation = generated_password
|
58
|
+
@user.remote_avatar_url = form.avatar_url if form.avatar_url.present?
|
58
59
|
@user.skip_confirmation! if verified_email
|
59
60
|
end
|
60
61
|
|
@@ -75,11 +76,11 @@ module Decidim
|
|
75
76
|
end
|
76
77
|
|
77
78
|
def existing_identity
|
78
|
-
@existing_identity ||= Identity.
|
79
|
+
@existing_identity ||= Identity.find_by(
|
79
80
|
user: organization.users,
|
80
81
|
provider: form.provider,
|
81
82
|
uid: form.uid
|
82
|
-
)
|
83
|
+
)
|
83
84
|
end
|
84
85
|
|
85
86
|
def verify_oauth_signature!
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This class infers the current component we're scoped to by looking at the
|
5
|
+
# request parameters and injects it into the environment.
|
6
|
+
class CurrentComponent
|
7
|
+
# Public: Initializes the class.
|
8
|
+
#
|
9
|
+
# manifest - The manifest of the component to check against.
|
10
|
+
def initialize(manifest)
|
11
|
+
@manifest = manifest
|
12
|
+
end
|
13
|
+
|
14
|
+
# Public: Matches the request against a component and injects it into the
|
15
|
+
# environment.
|
16
|
+
#
|
17
|
+
# request - The request that holds the current component relevant information.
|
18
|
+
#
|
19
|
+
# Returns a true if the request matched, false otherwise
|
20
|
+
def matches?(request)
|
21
|
+
env = request.env
|
22
|
+
|
23
|
+
@participatory_space = env["decidim.current_participatory_space"]
|
24
|
+
return false unless @participatory_space
|
25
|
+
|
26
|
+
current_component(env, request.params) ? true : false
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def current_component(env, params)
|
32
|
+
env["decidim.current_component"] ||= detect_current_component(params)
|
33
|
+
end
|
34
|
+
|
35
|
+
def detect_current_component(params)
|
36
|
+
@participatory_space.components.find do |component|
|
37
|
+
params["component_id"] == component.id.to_s && component.manifest_name == @manifest.name.to_s
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -10,10 +10,10 @@ module Decidim
|
|
10
10
|
helper_method :authorize_action_path, :action_authorization
|
11
11
|
end
|
12
12
|
|
13
|
-
# Public: Authorizes an action of a
|
13
|
+
# Public: Authorizes an action of a component given an action name.
|
14
14
|
#
|
15
15
|
# action_name - The action name to authorize. Actions are set up on the
|
16
|
-
#
|
16
|
+
# component's permissions panel.
|
17
17
|
# redirect_url - Url to be redirected to when the authorization is finished.
|
18
18
|
def authorize_action!(action_name, redirect_url: nil)
|
19
19
|
status = action_authorization(action_name)
|
@@ -49,7 +49,7 @@ module Decidim
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def _action_authorizer(action_name)
|
52
|
-
::Decidim::ActionAuthorizer.new(current_user,
|
52
|
+
::Decidim::ActionAuthorizer.new(current_user, current_component, action_name)
|
53
53
|
end
|
54
54
|
|
55
55
|
class Unauthorized < StandardError; end
|
@@ -72,7 +72,7 @@ module Decidim
|
|
72
72
|
def context
|
73
73
|
{
|
74
74
|
current_organization: @controller.try(:current_organization),
|
75
|
-
|
75
|
+
current_component: @controller.try(:current_component),
|
76
76
|
current_user: @controller.try(:current_user),
|
77
77
|
current_participatory_space: @controller.try(:current_participatory_space)
|
78
78
|
}
|
@@ -10,7 +10,7 @@ module Decidim
|
|
10
10
|
included do
|
11
11
|
before_action :check_impersonation_log_expired
|
12
12
|
|
13
|
-
helper_method :impersonation_session_ends_at, :impersonation_session_remaining_duration_in_minutes
|
13
|
+
helper_method :impersonation_session_ends_at, :impersonation_session_remaining_duration_in_minutes, :current_user_impersonated?
|
14
14
|
|
15
15
|
alias_method :real_user, :current_user
|
16
16
|
|
@@ -29,6 +29,10 @@ module Decidim
|
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
+
def current_user_impersonated?
|
33
|
+
current_user && impersonation_log.present?
|
34
|
+
end
|
35
|
+
|
32
36
|
# Returns the managed user impersonated by an admin if exists
|
33
37
|
def managed_user
|
34
38
|
return unless can_impersonate_users?
|
@@ -42,7 +46,7 @@ module Decidim
|
|
42
46
|
expired_log.ended_at = Time.current
|
43
47
|
expired_log.save!
|
44
48
|
flash[:alert] = I18n.t("managed_users.expired_session", scope: "decidim")
|
45
|
-
redirect_to decidim_admin.
|
49
|
+
redirect_to decidim_admin.impersonatable_users_path
|
46
50
|
end
|
47
51
|
|
48
52
|
# Gets the ability instance for the real user logged in.
|
@@ -24,9 +24,9 @@ module Decidim
|
|
24
24
|
def ability_context
|
25
25
|
{
|
26
26
|
current_settings: try(:current_settings),
|
27
|
-
|
27
|
+
component_settings: try(:component_settings),
|
28
28
|
current_organization: try(:current_organization),
|
29
|
-
|
29
|
+
current_component: try(:current_component)
|
30
30
|
}
|
31
31
|
end
|
32
32
|
|
@@ -56,5 +56,20 @@ module Decidim
|
|
56
56
|
def layout
|
57
57
|
current_participatory_space_manifest.context(current_participatory_space_context).layout
|
58
58
|
end
|
59
|
+
|
60
|
+
# Method for current user can visit the space (assembly or proces)
|
61
|
+
def current_user_can_visit_space?
|
62
|
+
(current_participatory_space.try(:private_space?) &&
|
63
|
+
current_participatory_space.users.include?(current_user)) ||
|
64
|
+
!current_participatory_space.try(:private_space?) ||
|
65
|
+
(current_participatory_space.try(:private_space?) &&
|
66
|
+
current_participatory_space.try(:is_transparent?))
|
67
|
+
end
|
68
|
+
|
69
|
+
def check_current_user_can_visit_space
|
70
|
+
return if current_user_can_visit_space?
|
71
|
+
flash[:alert] = I18n.t("participatory_space_private_users.not_allowed", scope: "decidim")
|
72
|
+
redirect_to action: "index"
|
73
|
+
end
|
59
74
|
end
|
60
75
|
end
|
@@ -4,19 +4,19 @@ require "active_support/concern"
|
|
4
4
|
|
5
5
|
module Decidim
|
6
6
|
# This concern groups methods and helpers related to accessing the settings
|
7
|
-
# of a
|
7
|
+
# of a component from a controller.
|
8
8
|
module Settings
|
9
9
|
extend ActiveSupport::Concern
|
10
10
|
|
11
11
|
included do
|
12
|
-
helper_method :
|
12
|
+
helper_method :component_settings, :current_settings
|
13
13
|
|
14
|
-
def
|
15
|
-
@
|
14
|
+
def component_settings
|
15
|
+
@component_settings ||= current_component.settings
|
16
16
|
end
|
17
17
|
|
18
18
|
def current_settings
|
19
|
-
@current_settings ||=
|
19
|
+
@current_settings ||= current_component.current_settings
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -17,8 +17,9 @@ module Decidim
|
|
17
17
|
helper Decidim::CookiesHelper
|
18
18
|
helper Decidim::AriaSelectedLinkToHelper
|
19
19
|
helper Decidim::MenuHelper
|
20
|
-
helper Decidim::
|
20
|
+
helper Decidim::ComponentPathHelper
|
21
21
|
helper Decidim::ViewHooksHelper
|
22
|
+
helper Decidim::CardHelper
|
22
23
|
|
23
24
|
# Saves the location before loading each page so we can return to the
|
24
25
|
# right page.
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
|
-
module
|
5
|
-
# Controller from which all
|
4
|
+
module Components
|
5
|
+
# Controller from which all component engines inherit from. It's in charge of
|
6
6
|
# setting the appropiate layout, including necessary helpers, and overall
|
7
7
|
# fooling the engine into thinking it's isolated.
|
8
8
|
class BaseController < Decidim::ApplicationController
|
@@ -23,35 +23,43 @@ module Decidim
|
|
23
23
|
helper Decidim::AttachmentsHelper
|
24
24
|
helper Decidim::SanitizeHelper
|
25
25
|
|
26
|
-
helper_method :
|
26
|
+
helper_method :current_component,
|
27
27
|
:current_participatory_space,
|
28
28
|
:current_manifest
|
29
29
|
|
30
30
|
skip_authorize_resource
|
31
31
|
|
32
32
|
before_action do
|
33
|
-
authorize! :read,
|
33
|
+
authorize! :read, current_component
|
34
34
|
end
|
35
|
+
before_action :redirect_unless_feature_private
|
35
36
|
|
36
37
|
def current_participatory_space
|
37
38
|
request.env["decidim.current_participatory_space"]
|
38
39
|
end
|
39
40
|
|
40
|
-
|
41
|
-
|
41
|
+
deprecate current_feature: "current_feature is deprecated and will be removed from Decidim's next release"
|
42
|
+
|
43
|
+
def current_component
|
44
|
+
request.env["decidim.current_component"]
|
42
45
|
end
|
46
|
+
alias current_feature current_component
|
43
47
|
|
44
48
|
def current_manifest
|
45
|
-
@current_manifest ||=
|
49
|
+
@current_manifest ||= current_component.manifest
|
46
50
|
end
|
47
51
|
|
48
52
|
def ability_context
|
49
53
|
super.merge(
|
50
54
|
current_manifest: current_manifest,
|
51
55
|
current_settings: current_settings,
|
52
|
-
|
56
|
+
component_settings: component_settings
|
53
57
|
)
|
54
58
|
end
|
59
|
+
|
60
|
+
def redirect_unless_feature_private
|
61
|
+
raise ActionController::RoutingError, "Not Found" unless current_user_can_visit_space?
|
62
|
+
end
|
55
63
|
end
|
56
64
|
end
|
57
65
|
end
|
@@ -13,6 +13,7 @@ module Decidim
|
|
13
13
|
|
14
14
|
def create
|
15
15
|
form_params = user_params_from_oauth_hash || params[:user]
|
16
|
+
|
16
17
|
@form = form(OmniauthRegistrationForm).from_params(form_params)
|
17
18
|
@form.email ||= verified_email
|
18
19
|
|
@@ -84,7 +85,8 @@ module Decidim
|
|
84
85
|
uid: oauth_data[:uid],
|
85
86
|
name: oauth_data[:info][:name],
|
86
87
|
nickname: oauth_data[:info][:nickname],
|
87
|
-
oauth_signature: OmniauthRegistrationForm.create_signature(oauth_data[:provider], oauth_data[:uid])
|
88
|
+
oauth_signature: OmniauthRegistrationForm.create_signature(oauth_data[:provider], oauth_data[:uid]),
|
89
|
+
avatar_url: oauth_data[:info][:image]
|
88
90
|
}
|
89
91
|
end
|
90
92
|
|
@@ -8,8 +8,6 @@ module Decidim
|
|
8
8
|
include FormFactory
|
9
9
|
include Decidim::DeviseControllers
|
10
10
|
|
11
|
-
helper_method :terms_and_conditions_page
|
12
|
-
|
13
11
|
before_action :configure_permitted_parameters
|
14
12
|
helper_method :terms_and_conditions_page
|
15
13
|
|
@@ -48,7 +46,7 @@ module Decidim
|
|
48
46
|
private
|
49
47
|
|
50
48
|
def terms_and_conditions_page
|
51
|
-
@terms_and_conditions_page ||= Decidim::StaticPage.find_by(slug: "terms-and-conditions")
|
49
|
+
@terms_and_conditions_page ||= Decidim::StaticPage.find_by(slug: "terms-and-conditions", organization: current_organization)
|
52
50
|
end
|
53
51
|
|
54
52
|
protected
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Doorkeeper
|
5
|
+
# Custom Doorkeeper AuthorizationsController to avoid namespace problems.
|
6
|
+
class AuthorizationsController < ::Doorkeeper::AuthorizationsController
|
7
|
+
skip_authorization_check
|
8
|
+
|
9
|
+
helper_method :oauth_application
|
10
|
+
|
11
|
+
def oauth_application
|
12
|
+
@oauth_application ||= Decidim::OAuthApplication.find_by(uid: params[:client_id])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Doorkeeper
|
5
|
+
# A controller to expose a simple JSON API so OAuth clients can get the user's information.
|
6
|
+
class CredentialsController < ApplicationController
|
7
|
+
skip_authorization_check
|
8
|
+
before_action :doorkeeper_authorize!
|
9
|
+
respond_to :json
|
10
|
+
|
11
|
+
def me
|
12
|
+
respond_with public_data
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def public_data
|
18
|
+
{
|
19
|
+
id: current_resource_owner.id,
|
20
|
+
email: current_resource_owner.email,
|
21
|
+
name: current_resource_owner.name,
|
22
|
+
nickname: current_resource_owner.nickname,
|
23
|
+
image: avatar_url
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def current_resource_owner
|
28
|
+
@current_resource_owner ||= Decidim::User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
|
29
|
+
end
|
30
|
+
|
31
|
+
def avatar_url
|
32
|
+
avatar_url = current_resource_owner.avatar_url
|
33
|
+
return unless avatar_url
|
34
|
+
|
35
|
+
unless avatar_url.match?(%r{/https?://})
|
36
|
+
request_uri = URI.parse(request.url)
|
37
|
+
request_uri.path = avatar_url
|
38
|
+
request_uri.query = nil
|
39
|
+
avatar_url = request_uri.to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
avatar_url
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/app/forms/decidim/form.rb
CHANGED
@@ -41,22 +41,22 @@ module Decidim
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def email_unique_in_organization
|
44
|
-
errors.add :email, :taken if User.
|
44
|
+
errors.add :email, :taken if User.find_by(email: email, organization: current_organization).present?
|
45
45
|
end
|
46
46
|
|
47
47
|
def nickname_unique_in_organization
|
48
|
-
errors.add :nickname, :taken if User.
|
48
|
+
errors.add :nickname, :taken if User.find_by(nickname: nickname, organization: current_organization).present?
|
49
49
|
end
|
50
50
|
|
51
51
|
def user_group_name_unique_in_organization
|
52
|
-
errors.add :user_group_name, :taken if UserGroup.
|
52
|
+
errors.add :user_group_name, :taken if UserGroup.find_by(name: user_group_name, decidim_organization_id: current_organization.id).present?
|
53
53
|
end
|
54
54
|
|
55
55
|
def user_group_document_number_unique_in_organization
|
56
|
-
errors.add :user_group_document_number, :taken if UserGroup.
|
56
|
+
errors.add :user_group_document_number, :taken if UserGroup.find_by(
|
57
57
|
document_number: user_group_document_number,
|
58
58
|
decidim_organization_id: current_organization.id
|
59
|
-
).
|
59
|
+
).present?
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# Helpers related to icons
|
5
|
+
module CardHelper
|
6
|
+
# Public: Returns a card given an instance of a Component.
|
7
|
+
#
|
8
|
+
# model - The component instance to generate the card for.
|
9
|
+
# options - a Hash with options, for the size of the card
|
10
|
+
#
|
11
|
+
# Returns an HTML.
|
12
|
+
def card_for(model, options = {})
|
13
|
+
cell "decidim/card", model, options
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A helper to get the root path for a component.
|
5
|
+
module ComponentPathHelper
|
6
|
+
# Returns the defined root path for a given component.
|
7
|
+
#
|
8
|
+
# component - the Component we want to find the root path for.
|
9
|
+
#
|
10
|
+
# Returns a relative url.
|
11
|
+
def main_component_path(component)
|
12
|
+
current_params = try(:params) || {}
|
13
|
+
EngineRouter.main_proxy(component).root_path(locale: current_params[:locale])
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the defined root url for a given component.
|
17
|
+
#
|
18
|
+
# component - the Component we want to find the root path for.
|
19
|
+
#
|
20
|
+
# Returns an absolute url.
|
21
|
+
def main_component_url(component)
|
22
|
+
current_params = try(:params) || {}
|
23
|
+
EngineRouter.main_proxy(component).root_url(locale: current_params[:locale])
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the defined admin root path for a given component.
|
27
|
+
#
|
28
|
+
# component - the Component we want to find the root path for.
|
29
|
+
#
|
30
|
+
# Returns a relative url.
|
31
|
+
def manage_component_path(component)
|
32
|
+
current_params = try(:params) || {}
|
33
|
+
EngineRouter.admin_proxy(component).root_path(locale: current_params[:locale])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|