decidim-core 0.11.2 → 0.12.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/notifications.js.es6 +8 -6
- data/app/assets/javascripts/decidim/user_registrations.js.es6 +25 -1
- data/app/assets/stylesheets/decidim/application.scss.erb +4 -0
- data/app/assets/stylesheets/decidim/layouts/_home.scss +79 -0
- data/app/assets/stylesheets/decidim/modules/_author-avatar.scss +2 -1
- data/app/assets/stylesheets/decidim/modules/_cards.scss +82 -38
- data/app/assets/stylesheets/decidim/modules/_collapsible-list.scss +16 -0
- data/app/assets/stylesheets/decidim/modules/_definition-data.scss +27 -0
- data/app/assets/stylesheets/decidim/modules/_fingerprint.scss +8 -0
- data/app/assets/stylesheets/decidim/modules/_horizontal-tabs.scss +51 -0
- data/app/assets/stylesheets/decidim/modules/_inline-filters.scss +5 -3
- data/app/assets/stylesheets/decidim/modules/_margins.scss +6 -4
- data/app/assets/stylesheets/decidim/modules/_modules.scss +3 -0
- data/app/assets/stylesheets/decidim/modules/_navbar.scss +113 -7
- data/app/assets/stylesheets/decidim/modules/_signup.scss +22 -5
- data/app/assets/stylesheets/decidim/modules/_toggle.scss +9 -0
- data/app/assets/stylesheets/decidim/modules/_typography.scss +5 -1
- data/app/assets/stylesheets/decidim/utils/_helpers.scss +42 -0
- data/app/assets/stylesheets/decidim/utils/_mixins.scss +6 -0
- data/app/assets/stylesheets/decidim/utils/_settings.scss +3 -2
- data/app/cells/decidim/announcement/show.erb +11 -0
- data/app/cells/decidim/announcement_cell.rb +32 -0
- data/app/cells/decidim/author/comments.erb +6 -0
- data/app/cells/decidim/author/contact.erb +3 -0
- data/app/cells/decidim/author/date.erb +5 -0
- data/app/cells/decidim/author/flag.erb +5 -0
- data/app/cells/decidim/author/profile.erb +9 -0
- data/app/cells/decidim/{profile → author}/profile_inline.erb +1 -1
- data/app/cells/decidim/author/show.erb +18 -0
- data/app/cells/decidim/author/withdraw.erb +6 -0
- data/app/cells/decidim/author_cell.rb +109 -0
- data/app/cells/decidim/card/show.erb +18 -16
- data/app/cells/decidim/card_cell.rb +17 -4
- data/app/cells/decidim/card_m/author.erb +3 -0
- data/app/cells/decidim/card_m/badge.erb +1 -0
- data/app/cells/decidim/card_m/comments_counter.erb +3 -0
- data/app/cells/decidim/card_m/data.erb +0 -0
- data/app/cells/decidim/card_m/footer.erb +0 -0
- data/app/cells/decidim/card_m/header.erb +17 -0
- data/app/cells/decidim/card_m/image.erb +5 -0
- data/app/cells/decidim/card_m/label.erb +3 -0
- data/app/cells/decidim/card_m/show.erb +24 -0
- data/app/cells/decidim/card_m/status.erb +9 -0
- data/app/cells/decidim/card_m/tags.erb +0 -0
- data/app/cells/decidim/card_m_cell.rb +136 -0
- data/app/cells/decidim/collapsible_list/show.erb +20 -0
- data/app/cells/decidim/collapsible_list_cell.rb +66 -0
- data/app/cells/decidim/fingerprint/show.erb +22 -0
- data/app/cells/decidim/fingerprint_cell.rb +17 -0
- data/app/cells/decidim/follow_button/show.erb +34 -0
- data/app/cells/decidim/follow_button_cell.rb +40 -0
- data/app/cells/decidim/followers/show.erb +9 -0
- data/app/cells/decidim/followers_cell.rb +18 -0
- data/app/cells/decidim/following/show.erb +9 -0
- data/app/cells/decidim/following_cell.rb +24 -0
- data/app/cells/decidim/notifications/show.erb +48 -0
- data/app/cells/decidim/notifications_cell.rb +21 -0
- data/app/cells/decidim/progress_bar/show.erb +17 -0
- data/app/cells/decidim/progress_bar_cell.rb +68 -0
- data/app/cells/decidim/tags/category.erb +1 -0
- data/app/cells/decidim/tags/scope.erb +1 -0
- data/app/cells/decidim/tags/show.erb +5 -0
- data/app/cells/decidim/tags_cell.rb +62 -0
- data/app/cells/decidim/tos_page/announcement.erb +2 -0
- data/app/cells/decidim/tos_page/refuse_btn_modal.erb +23 -0
- data/app/cells/decidim/tos_page/sticky_form.erb +29 -0
- data/app/cells/decidim/tos_page_cell.rb +39 -0
- data/app/cells/decidim/user_profile/footer.erb +5 -0
- data/app/cells/decidim/user_profile/header.erb +20 -0
- data/app/cells/decidim/user_profile_cell.rb +26 -0
- data/app/commands/decidim/create_omniauth_registration.rb +1 -1
- data/app/commands/decidim/create_registration.rb +2 -1
- data/app/commands/decidim/search.rb +45 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +15 -12
- data/app/controllers/concerns/decidim/http_caching_disabler.rb +21 -0
- data/app/controllers/concerns/decidim/impersonate_users.rb +1 -6
- data/app/controllers/concerns/decidim/locale_switcher.rb +1 -1
- data/app/controllers/concerns/decidim/needs_permission.rb +70 -0
- data/app/controllers/concerns/decidim/needs_tos_accepted.rb +42 -0
- data/app/controllers/concerns/decidim/participatory_space_context.rb +1 -7
- data/app/controllers/concerns/decidim/user_profile.rb +3 -1
- data/app/controllers/decidim/account_controller.rb +4 -4
- data/app/controllers/decidim/application_controller.rb +17 -8
- data/app/controllers/decidim/components/base_controller.rb +14 -9
- data/app/controllers/decidim/cookie_policy_controller.rb +0 -2
- data/app/controllers/decidim/devise/confirmations_controller.rb +13 -0
- data/app/controllers/decidim/devise/invitations_controller.rb +3 -1
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +9 -3
- data/app/controllers/decidim/devise/passwords_controller.rb +1 -1
- data/app/controllers/decidim/devise/registrations_controller.rb +1 -7
- data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +0 -2
- data/app/controllers/decidim/doorkeeper/credentials_controller.rb +0 -1
- data/app/controllers/decidim/errors_controller.rb +0 -2
- data/app/controllers/decidim/follows_controller.rb +4 -2
- data/app/controllers/decidim/locales_controller.rb +1 -1
- data/app/controllers/decidim/messaging/conversations_controller.rb +5 -5
- data/app/controllers/decidim/newsletters_controller.rb +0 -2
- data/app/controllers/decidim/notifications_controller.rb +3 -19
- data/app/controllers/decidim/notifications_settings_controller.rb +2 -2
- data/app/controllers/decidim/pages_controller.rb +12 -10
- data/app/controllers/decidim/profiles_controller.rb +10 -4
- data/app/controllers/decidim/reports_controller.rb +14 -1
- data/app/controllers/decidim/scopes_controller.rb +3 -3
- data/app/controllers/decidim/searches_controller.rb +39 -0
- data/app/controllers/decidim/static_map_controller.rb +0 -2
- data/app/controllers/decidim/tos_controller.rb +20 -0
- data/app/controllers/decidim/widgets_controller.rb +0 -1
- data/app/forms/decidim/follow_form.rb +1 -0
- data/app/forms/decidim/registration_form.rb +2 -1
- data/app/helpers/decidim/card_helper.rb +2 -0
- data/app/helpers/decidim/cells_paginate_helper.rb +16 -0
- data/app/helpers/decidim/cta_button_helper.rb +1 -1
- data/app/helpers/decidim/decidim_form_helper.rb +4 -0
- data/app/helpers/decidim/icon_helper.rb +2 -0
- data/app/helpers/decidim/resource_helper.rb +1 -2
- data/app/helpers/decidim/scopes_helper.rb +17 -10
- data/app/helpers/decidim/searches_helper.rb +16 -0
- data/app/helpers/decidim/tooltip_helper.rb +12 -0
- data/app/models/decidim/organization.rb +10 -0
- data/app/models/decidim/permission_action.rb +40 -0
- data/app/models/decidim/searchable_resource.rb +37 -0
- data/app/models/decidim/static_page.rb +4 -0
- data/app/models/decidim/user.rb +39 -3
- data/app/permissions/decidim/default_permissions.rb +61 -0
- data/app/permissions/decidim/permissions.rb +106 -0
- data/app/permissions/decidim/user_manager_permissions.rb +24 -0
- data/app/presenters/decidim/admin_log/organization_presenter.rb +2 -1
- data/app/presenters/decidim/home_stats_presenter.rb +2 -8
- data/app/presenters/decidim/user_presenter.rb +8 -0
- data/app/services/decidim/traceability.rb +6 -9
- data/app/types/decidim/core/user_type.rb +1 -1
- data/app/views/decidim/devise/invitations/edit.html.erb +56 -10
- data/app/views/decidim/devise/registrations/new.html.erb +36 -14
- data/app/views/decidim/devise/shared/_newsletter_modal.html.erb +25 -0
- data/app/views/decidim/follows/update_button.js.erb +2 -2
- data/app/views/decidim/messaging/conversations/_message.html.erb +1 -1
- data/app/views/{pages → decidim/pages}/decidim_page.html.erb +5 -0
- data/app/views/decidim/pages/home.html.erb +17 -0
- data/app/views/{pages → decidim/pages}/home/_extended.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_footer_sub_hero.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_hero.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_highlighted_content_banner.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_highlighted_processes.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_statistics.html.erb +0 -0
- data/app/views/{pages → decidim/pages}/home/_sub_hero.html.erb +0 -0
- data/app/views/decidim/profiles/_followers.html.erb +5 -0
- data/app/views/decidim/profiles/_following.html.erb +5 -0
- data/app/views/decidim/profiles/_notifications.html.erb +0 -0
- data/app/views/decidim/profiles/_user.html.erb +59 -0
- data/app/views/decidim/profiles/_user_follow.erb +32 -0
- data/app/views/decidim/profiles/show.html.erb +32 -59
- data/app/views/decidim/searches/_count.html.erb +1 -0
- data/app/views/decidim/searches/_filters.html.erb +20 -0
- data/app/views/decidim/searches/_filters_small_view.html.erb +18 -0
- data/app/views/decidim/searches/_results.html.erb +5 -0
- data/app/views/decidim/searches/index.html.erb +20 -0
- data/app/views/decidim/searches/index.js.erb +5 -0
- data/app/views/decidim/shared/_address_details.html.erb +7 -9
- data/app/views/decidim/shared/_announcement.html.erb +1 -6
- data/app/views/decidim/shared/_author_reference.html.erb +1 -1
- data/app/views/decidim/shared/_follow_button.html.erb +1 -34
- data/app/views/decidim/shared/_static_map.html.erb +3 -1
- data/app/views/decidim/shared/_tags.html.erb +1 -11
- data/app/views/kaminari/decidim/_paginator.html.erb +16 -15
- data/app/views/layouts/decidim/_head.html.erb +1 -0
- data/app/views/layouts/decidim/_topbar_search.html.erb +8 -0
- data/app/views/layouts/decidim/_user_menu.html.erb +2 -2
- data/app/views/layouts/decidim/_wrapper.html.erb +3 -2
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/rack_attack.rb +28 -0
- data/config/locales/ca.yml +136 -55
- data/config/locales/en.yml +135 -54
- data/config/locales/es.yml +136 -55
- data/config/locales/eu.yml +136 -54
- data/config/locales/fi.yml +135 -54
- data/config/locales/fr.yml +136 -54
- data/config/locales/gl.yml +136 -54
- data/config/locales/it.yml +136 -54
- data/config/locales/nl.yml +136 -54
- data/config/locales/pl.yml +144 -54
- data/config/locales/pt-BR.yml +136 -54
- data/config/locales/pt.yml +136 -54
- data/config/locales/ru.yml +150 -60
- data/config/locales/sv.yml +136 -54
- data/config/locales/uk.yml +146 -57
- data/config/routes.rb +11 -1
- data/db/migrate/20180209122819_create_decidim_searchable_resource.rb +21 -0
- data/db/migrate/20180508111640_add_tos_version_to_organization.rb +19 -0
- data/db/migrate/20180508111710_add_accepted_tos_version_field_to_users.rb +25 -0
- data/db/seeds.rb +33 -26
- data/lib/decidim/component_manifest.rb +35 -27
- data/lib/decidim/content_processor.rb +21 -3
- data/lib/decidim/core.rb +27 -16
- data/lib/decidim/core/engine.rb +8 -19
- data/lib/decidim/core/test.rb +2 -0
- data/lib/decidim/core/test/factories.rb +34 -4
- data/lib/decidim/core/test/shared_examples/fingerprint_examples.rb +15 -0
- data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +27 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/events/base_event.rb +5 -1
- data/lib/decidim/fingerprint_calculator.rb +42 -0
- data/lib/decidim/fingerprintable.rb +63 -0
- data/lib/decidim/form_builder.rb +1 -0
- data/lib/decidim/manifest_registry.rb +4 -10
- data/lib/decidim/participable.rb +4 -0
- data/lib/decidim/participatory_space_manifest.rb +36 -0
- data/lib/decidim/participatory_space_resourceable.rb +11 -0
- data/lib/decidim/resource_manifest.rb +10 -11
- data/lib/decidim/resourceable.rb +3 -2
- data/lib/decidim/search_resource_fields_mapper.rb +93 -0
- data/lib/decidim/searchable.rb +85 -0
- data/lib/decidim/settings_manifest.rb +3 -2
- data/lib/decidim/traceable.rb +2 -0
- data/lib/decidim/view_model.rb +9 -0
- data/lib/tasks/decidim_tasks.rake +79 -1
- metadata +149 -76
- data/app/assets/stylesheets/decidim/extras/_register_form.scss +0 -9
- data/app/cells/decidim/author_box/show.erb +0 -10
- data/app/cells/decidim/author_box_cell.rb +0 -21
- data/app/cells/decidim/profile/show.erb +0 -13
- data/app/cells/decidim/profile_cell.rb +0 -17
- data/app/controllers/concerns/decidim/needs_authorization.rb +0 -46
- data/app/models/decidim/abilities/admin_ability.rb +0 -29
- data/app/models/decidim/abilities/base_ability.rb +0 -56
- data/app/models/decidim/abilities/everyone_ability.rb +0 -25
- data/app/models/decidim/abilities/participatory_process_admin_ability.rb +0 -28
- data/app/models/decidim/abilities/participatory_process_collaborator_ability.rb +0 -28
- data/app/models/decidim/abilities/participatory_process_moderator_ability.rb +0 -15
- data/app/models/decidim/abilities/user_manager_ability.rb +0 -35
- data/app/views/decidim/notifications/_notification.html.erb +0 -20
- data/app/views/decidim/notifications/index.html.erb +0 -36
- data/app/views/decidim/shared/_author.html.erb +0 -21
- data/app/views/pages/home.html.erb +0 -17
- data/db/migrate/20180613080638_rename_missing_features_to_components.rb +0 -15
- data/lib/decidim/abilities.rb +0 -7
- data/lib/decidim/abilities/participatory_process_role_ability.rb +0 -60
- data/lib/decidim/page_finder.rb +0 -49
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This cell renders the category of a resource
|
5
|
+
# shown with the translated name and links to
|
6
|
+
# the resource parent `component` and `participatory space` index.
|
7
|
+
# The context `resource` must be present
|
8
|
+
# example use inside another `cell`:
|
9
|
+
# <%= cell("decidim/category", model.category, context: {resource: model}) %>
|
10
|
+
#
|
11
|
+
class TagsCell < Decidim::ViewModel
|
12
|
+
def show
|
13
|
+
render if category? || scope?
|
14
|
+
end
|
15
|
+
|
16
|
+
def category
|
17
|
+
render if category?
|
18
|
+
end
|
19
|
+
|
20
|
+
def scope
|
21
|
+
render if scope?
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def tags_classes
|
27
|
+
(["tags"] + context[:extra_classes].to_a).join(" ")
|
28
|
+
end
|
29
|
+
|
30
|
+
def category?
|
31
|
+
model.category.present?
|
32
|
+
end
|
33
|
+
|
34
|
+
def link_to_category
|
35
|
+
link_to category_name, category_path
|
36
|
+
end
|
37
|
+
|
38
|
+
def category_name
|
39
|
+
model.category.translated_name
|
40
|
+
end
|
41
|
+
|
42
|
+
def category_path
|
43
|
+
resource_locator(model).index(filter: { category_id: model.category.id })
|
44
|
+
end
|
45
|
+
|
46
|
+
def scope?
|
47
|
+
has_visible_scopes?(model)
|
48
|
+
end
|
49
|
+
|
50
|
+
def link_to_scope
|
51
|
+
link_to scope_name, scope_path
|
52
|
+
end
|
53
|
+
|
54
|
+
def scope_name
|
55
|
+
translated_attribute model.scope.name
|
56
|
+
end
|
57
|
+
|
58
|
+
def scope_path
|
59
|
+
resource_locator(model).index(filter: { scope_id: model.scope.id })
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<button class="clear button secondary button--nomargin small" type="button" data-open="tos-refuse-modal">
|
2
|
+
<%= t("refuse.modal_button", scope: "decidim.pages.terms_and_conditions") %>
|
3
|
+
</button>
|
4
|
+
|
5
|
+
<div id="tos-refuse-modal" class="reveal" data-reveal aria-labelledby="#{modal_title}" aria-hidden="true" role="dialog">
|
6
|
+
<h2>
|
7
|
+
<%= t("refuse.modal_title", scope: "decidim.pages.terms_and_conditions") %>
|
8
|
+
</h2>
|
9
|
+
|
10
|
+
<p>
|
11
|
+
<%= t("refuse.modal_body", scope: "decidim.pages.terms_and_conditions", data_portability_path: "#", delete_path: decidim.delete_account_path) %>
|
12
|
+
</p>
|
13
|
+
|
14
|
+
<div class="row column flex-center">
|
15
|
+
<%= button_to decidim.destroy_user_session_path, method: :delete, class: "clear button secondary button--nomargin small" do %>
|
16
|
+
<%= t("refuse.modal_btn_exit", scope: "decidim.pages.terms_and_conditions") %>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= button_to decidim.accept_tos_path, method: :put, class: "button button--nomargin small" do %>
|
20
|
+
<%= t("refuse.modal_btn_continue", scope: "decidim.pages.terms_and_conditions") %>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
23
|
+
</div>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<div data-sticky-container class="cell-sticky">
|
2
|
+
<div class="sticky"
|
3
|
+
data-sticky
|
4
|
+
data-stick-to="bottom"
|
5
|
+
data-margin-bottom="0"
|
6
|
+
data-top-anchor="sticky-top-stop:top"
|
7
|
+
data-btm-anchor="sticky-btm-stop:top"
|
8
|
+
data-sticky-on="small">
|
9
|
+
<article class="card">
|
10
|
+
<div class="card__content">
|
11
|
+
<div class="card__header">
|
12
|
+
<h5 class="card__title text-center">
|
13
|
+
<%= t("form.legend", scope: "decidim.pages.terms_and_conditions") %>
|
14
|
+
</h5>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div class="row column flex-center">
|
18
|
+
<%= cell "decidim/tos_page", :refuse_btn_modal %>
|
19
|
+
|
20
|
+
<%= button_to decidim.accept_tos_path, method: :put, class: "button button--nomargin small" do %>
|
21
|
+
<%= t("form.agreement", scope: "decidim.pages.terms_and_conditions") %>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
</article>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div id="sticky-btm-stop"></div>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This cell renders specific _partials_ for the `terms_and_conditions` StaticPage
|
5
|
+
# the `model` is the partial to render
|
6
|
+
# - :announcement, the TOS updated announcement when redirected to the TOS page.
|
7
|
+
# - :sticky_form, the Accept updated TOS form in the TOS page.
|
8
|
+
# - :refuse_btn_modal, the Modal with info when refusing the updated TOS.
|
9
|
+
class TosPageCell < Decidim::ViewModel
|
10
|
+
include Decidim::SanitizeHelper
|
11
|
+
include Cell::ViewModel::Partial
|
12
|
+
|
13
|
+
delegate :current_user, to: :controller, prefix: false
|
14
|
+
|
15
|
+
def show
|
16
|
+
return if model.nil?
|
17
|
+
return unless current_user
|
18
|
+
return if current_user.tos_accepted?
|
19
|
+
render model
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def announcement_args
|
25
|
+
args = {
|
26
|
+
callout_class: "warning",
|
27
|
+
announcement: {
|
28
|
+
title: t("required_review.title", scope: "decidim.pages.terms_and_conditions"),
|
29
|
+
body: t("required_review.body", scope: "decidim.pages.terms_and_conditions")
|
30
|
+
}
|
31
|
+
}
|
32
|
+
args
|
33
|
+
end
|
34
|
+
|
35
|
+
def decidim
|
36
|
+
Decidim::Core::Engine.routes.url_helpers
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="card__header">
|
2
|
+
<div class="author-data author-data--big">
|
3
|
+
<div class="author-data__main">
|
4
|
+
<div class="author author--flex">
|
5
|
+
<%= link_to resource_path, class: "author__avatar" do %>
|
6
|
+
<%= image_tag avatar %>
|
7
|
+
<% end %>
|
8
|
+
<div>
|
9
|
+
<div class="author__name--container">
|
10
|
+
<%= link_to name, resource_path, class: "author__name" %>
|
11
|
+
<%= icon "verified-badge", class: "author__verified" if officialized? %>
|
12
|
+
</div>
|
13
|
+
<%= link_to nickname, resource_path, class: "author__nickname" %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<%= render :author if has_author? %>
|
20
|
+
</div>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This cell renders the profile of the given user.
|
5
|
+
class UserProfileCell < Decidim::CardMCell
|
6
|
+
property :name
|
7
|
+
property :nickname
|
8
|
+
property :officialized?
|
9
|
+
|
10
|
+
def resource_path
|
11
|
+
decidim.profile_path(model.nickname)
|
12
|
+
end
|
13
|
+
|
14
|
+
def nickname
|
15
|
+
"@" + model.nickname
|
16
|
+
end
|
17
|
+
|
18
|
+
def description
|
19
|
+
html_truncate(model.about.to_s, length: 100)
|
20
|
+
end
|
21
|
+
|
22
|
+
def avatar
|
23
|
+
model.avatar_url(:big)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -51,7 +51,7 @@ module Decidim
|
|
51
51
|
@user.email = (verified_email || form.email)
|
52
52
|
@user.name = form.name
|
53
53
|
@user.nickname = form.normalized_nickname
|
54
|
-
@user.newsletter_notifications =
|
54
|
+
@user.newsletter_notifications = false
|
55
55
|
@user.email_on_notification = true
|
56
56
|
@user.password = generated_password
|
57
57
|
@user.password_confirmation = generated_password
|
@@ -41,7 +41,8 @@ module Decidim
|
|
41
41
|
organization: form.current_organization,
|
42
42
|
tos_agreement: form.tos_agreement,
|
43
43
|
newsletter_notifications: form.newsletter,
|
44
|
-
email_on_notification: true
|
44
|
+
email_on_notification: true,
|
45
|
+
accepted_tos_version: form.current_organization.tos_version)
|
45
46
|
end
|
46
47
|
|
47
48
|
def create_user_group
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A command that will act as a search service, with all the business logic for performing searches.
|
5
|
+
class Search < Rectify::Command
|
6
|
+
ACCEPTED_FILTERS = [:resource_type, :decidim_scope_id].freeze
|
7
|
+
|
8
|
+
attr_reader :term, :results
|
9
|
+
|
10
|
+
# Public: Initializes the command.
|
11
|
+
#
|
12
|
+
# @param term: The term to search for.
|
13
|
+
def initialize(term, organization, filters = {})
|
14
|
+
@term = term
|
15
|
+
@organization = organization
|
16
|
+
@filters = filters
|
17
|
+
end
|
18
|
+
|
19
|
+
# Executes the command. Broadcasts these events:
|
20
|
+
#
|
21
|
+
# - :ok when everything is valid, together with the search results.
|
22
|
+
# - :invalid if something failed and couldn't proceed.
|
23
|
+
#
|
24
|
+
# Returns nothing.
|
25
|
+
def call
|
26
|
+
query = SearchableResource.where(organization: @organization, locale: I18n.locale)
|
27
|
+
@filters.each_pair do |attribute_name, value|
|
28
|
+
query = query.where(attribute_name => value) if permit_filter?(attribute_name, value)
|
29
|
+
end
|
30
|
+
@results = if term.present?
|
31
|
+
query.global_search(I18n.transliterate(term))
|
32
|
+
else
|
33
|
+
query.all
|
34
|
+
end
|
35
|
+
|
36
|
+
broadcast(:ok, @results.order("datetime DESC"))
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def permit_filter?(attribute_name, value)
|
42
|
+
ACCEPTED_FILTERS.include?(attribute_name.to_sym) && value.present?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -11,9 +11,7 @@ module Decidim
|
|
11
11
|
include Decidim::NeedsOrganization
|
12
12
|
include Decidim::LocaleSwitcher
|
13
13
|
include ImpersonateUsers
|
14
|
-
include
|
15
|
-
|
16
|
-
skip_authorization_check
|
14
|
+
include NeedsPermission
|
17
15
|
|
18
16
|
helper Decidim::TranslationsHelper
|
19
17
|
helper Decidim::MetaTagsHelper
|
@@ -30,18 +28,23 @@ module Decidim
|
|
30
28
|
# Saves the location before loading each page so we can return to the
|
31
29
|
# right page.
|
32
30
|
before_action :store_current_location
|
33
|
-
end
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
def permission_class_chain
|
33
|
+
[
|
34
|
+
Decidim::Admin::Permissions,
|
35
|
+
Decidim::Permissions
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
39
|
+
def permission_scope
|
40
|
+
:public
|
41
|
+
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
+
def store_current_location
|
44
|
+
return if params[:redirect_url].blank? || !request.format.html?
|
43
45
|
|
44
|
-
|
46
|
+
store_location_for(:user, params[:redirect_url])
|
47
|
+
end
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
# This module will disable http caching from the controller in
|
7
|
+
# order to prevent proxies from storing sensible information.
|
8
|
+
module HttpCachingDisabler
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
before_action :disable_http_caching
|
13
|
+
end
|
14
|
+
|
15
|
+
def disable_http_caching
|
16
|
+
response.headers["Cache-Control"] = "no-cache, no-store"
|
17
|
+
response.headers["Pragma"] = "no-cache"
|
18
|
+
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -49,13 +49,8 @@ module Decidim
|
|
49
49
|
redirect_to decidim_admin.impersonatable_users_path
|
50
50
|
end
|
51
51
|
|
52
|
-
# Gets the ability instance for the real user logged in.
|
53
|
-
def real_ability
|
54
|
-
@real_ability ||= current_ability_klass.new(real_user, ability_context)
|
55
|
-
end
|
56
|
-
|
57
52
|
def can_impersonate_users?
|
58
|
-
real_user &&
|
53
|
+
real_user && allowed_to?(:impersonate, :managed_user, {}, [Decidim::Admin::Permissions], real_user)
|
59
54
|
end
|
60
55
|
|
61
56
|
def expired_log
|
@@ -46,7 +46,7 @@ module Decidim
|
|
46
46
|
#
|
47
47
|
# Returns an Array of Strings.
|
48
48
|
def available_locales
|
49
|
-
@available_locales ||= current_organization.available_locales
|
49
|
+
@available_locales ||= (current_organization || Decidim).public_send(:available_locales)
|
50
50
|
end
|
51
51
|
|
52
52
|
# The default locale of this organization.
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
# Common logic to work with the permissions system
|
7
|
+
module NeedsPermission
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
helper_method :allowed_to?
|
12
|
+
|
13
|
+
class ::Decidim::ActionForbidden < StandardError
|
14
|
+
end
|
15
|
+
|
16
|
+
rescue_from Decidim::ActionForbidden, with: :user_has_no_permission
|
17
|
+
|
18
|
+
# Handles the case when a user visits a path that is not allowed to them.
|
19
|
+
# Redirects the user to the root path and shows a flash message telling
|
20
|
+
# them they are not authorized.
|
21
|
+
def user_has_no_permission
|
22
|
+
flash[:alert] = t("actions.unauthorized", scope: "decidim.core")
|
23
|
+
redirect_to(request.referer || user_has_no_permission_path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def user_has_no_permission_path
|
27
|
+
raise NotImplementedError
|
28
|
+
end
|
29
|
+
|
30
|
+
def permissions_context
|
31
|
+
{
|
32
|
+
current_settings: try(:current_settings),
|
33
|
+
component_settings: try(:component_settings),
|
34
|
+
current_organization: try(:current_organization),
|
35
|
+
current_component: try(:current_component)
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def enforce_permission_to(action, subject, extra_context = {})
|
40
|
+
Rails.logger.debug "==========="
|
41
|
+
Rails.logger.debug [permission_scope, action, subject, permission_class_chain].map(&:inspect).join("\n")
|
42
|
+
Rails.logger.debug "==========="
|
43
|
+
|
44
|
+
raise Decidim::ActionForbidden unless allowed_to?(action, subject, extra_context)
|
45
|
+
end
|
46
|
+
|
47
|
+
def allowed_to?(action, subject, extra_context = {}, chain = permission_class_chain, user = current_user)
|
48
|
+
permission_action = Decidim::PermissionAction.new(scope: permission_scope, action: action, subject: subject)
|
49
|
+
|
50
|
+
chain.inject(permission_action) do |current_permission_action, permission_class|
|
51
|
+
permission_class.new(
|
52
|
+
user,
|
53
|
+
current_permission_action,
|
54
|
+
permissions_context.merge(extra_context)
|
55
|
+
).permissions
|
56
|
+
end.allowed?
|
57
|
+
rescue Decidim::PermissionAction::PermissionNotSetError
|
58
|
+
false
|
59
|
+
end
|
60
|
+
|
61
|
+
def permission_class_chain
|
62
|
+
raise "Please, make this method return an array of permission classes"
|
63
|
+
end
|
64
|
+
|
65
|
+
def permission_scope
|
66
|
+
raise "Please, make this method return a symbol"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|