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
@@ -6,12 +6,12 @@ module Decidim
|
|
6
6
|
include Decidim::UserProfile
|
7
7
|
|
8
8
|
def show
|
9
|
-
|
9
|
+
enforce_permission_to :read, :user, current_user: current_user
|
10
10
|
@notifications_settings = form(NotificationsSettingsForm).from_model(current_user)
|
11
11
|
end
|
12
12
|
|
13
13
|
def update
|
14
|
-
|
14
|
+
enforce_permission_to :update, :user, current_user: current_user
|
15
15
|
@notifications_settings = form(NotificationsSettingsForm).from_params(params)
|
16
16
|
|
17
17
|
UpdateNotificationsSettings.call(current_user, @notifications_settings) do
|
@@ -1,29 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_dependency "decidim/page_finder"
|
4
|
-
|
5
3
|
module Decidim
|
6
4
|
# This controller serves static pages using HighVoltage.
|
7
5
|
class PagesController < Decidim::ApplicationController
|
8
|
-
include HighVoltage::StaticPage
|
9
|
-
|
10
6
|
layout "layouts/decidim/application"
|
11
7
|
|
12
|
-
authorize_resource :public_pages, class: false
|
13
|
-
delegate :page, to: :page_finder
|
14
8
|
helper_method :page, :stats
|
15
9
|
helper CtaButtonHelper
|
16
10
|
helper Decidim::SanitizeHelper
|
17
11
|
skip_before_action :store_current_location
|
18
12
|
|
19
13
|
def index
|
20
|
-
|
21
|
-
|
14
|
+
enforce_permission_to :read, :public_page
|
15
|
+
@pages = current_organization.static_pages.sorted_by_i18n_title
|
16
|
+
end
|
17
|
+
|
18
|
+
def show
|
19
|
+
enforce_permission_to :read, :public_page, page: page
|
20
|
+
if params[:id] == "home"
|
21
|
+
render :home
|
22
|
+
else
|
23
|
+
render :decidim_page
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
|
-
def
|
26
|
-
@
|
27
|
+
def page
|
28
|
+
@page ||= current_organization.static_pages.find_by(slug: params[:id])
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
@@ -3,13 +3,14 @@
|
|
3
3
|
module Decidim
|
4
4
|
# The controller to handle the user's public profile page.
|
5
5
|
class ProfilesController < Decidim::ApplicationController
|
6
|
-
skip_authorization_check
|
7
|
-
|
8
6
|
helper Decidim::Messaging::ConversationHelper
|
9
7
|
|
10
|
-
helper_method :user
|
8
|
+
helper_method :user, :active_content
|
11
9
|
|
12
|
-
def show
|
10
|
+
def show
|
11
|
+
return redirect_to profile_notifications_path(nickname: params[:nickname]) if current_user == user && params[:active].blank?
|
12
|
+
return redirect_to profile_path(nickname: params[:nickname]) if current_user != user && params[:active] == "notifications"
|
13
|
+
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
@@ -19,5 +20,10 @@ module Decidim
|
|
19
20
|
organization: current_organization
|
20
21
|
)
|
21
22
|
end
|
23
|
+
|
24
|
+
def active_content
|
25
|
+
return "following" if current_user != user && params[:active].blank?
|
26
|
+
params[:active].presence
|
27
|
+
end
|
22
28
|
end
|
23
29
|
end
|
@@ -4,10 +4,12 @@ module Decidim
|
|
4
4
|
# Exposes the report resource so users can report a reportable.
|
5
5
|
class ReportsController < Decidim::ApplicationController
|
6
6
|
include FormFactory
|
7
|
+
include NeedsPermission
|
8
|
+
|
7
9
|
before_action :authenticate_user!
|
8
10
|
|
9
11
|
def create
|
10
|
-
|
12
|
+
enforce_permission_to :create, :moderation
|
11
13
|
|
12
14
|
@form = form(Decidim::ReportForm).from_params(params)
|
13
15
|
|
@@ -29,5 +31,16 @@ module Decidim
|
|
29
31
|
def reportable
|
30
32
|
@reportable ||= GlobalID::Locator.locate_signed params[:sgid]
|
31
33
|
end
|
34
|
+
|
35
|
+
def permission_class_chain
|
36
|
+
[
|
37
|
+
reportable.participatory_space.manifest.permissions_class,
|
38
|
+
Decidim::Permissions
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
def permission_scope
|
43
|
+
:public
|
44
|
+
end
|
32
45
|
end
|
33
46
|
end
|
@@ -6,10 +6,10 @@ module Decidim
|
|
6
6
|
skip_before_action :store_current_location
|
7
7
|
|
8
8
|
def picker
|
9
|
-
|
9
|
+
enforce_permission_to :pick, :scope
|
10
10
|
|
11
11
|
title = params[:title] || t("decidim.scopes.picker.title", field: params[:field]&.downcase)
|
12
|
-
root =
|
12
|
+
root = current_organization.scopes.find(params[:root]) if params[:root]
|
13
13
|
context = root ? { root: root.id, title: title } : { title: title }
|
14
14
|
required = params[:required] && params[:required] != "false"
|
15
15
|
if params[:current]
|
@@ -18,7 +18,7 @@ module Decidim
|
|
18
18
|
parent_scopes = current.part_of_scopes(root)
|
19
19
|
else
|
20
20
|
current = root
|
21
|
-
scopes = root&.children ||
|
21
|
+
scopes = root&.children || current_organization.scopes.top_level
|
22
22
|
parent_scopes = [root].compact
|
23
23
|
end
|
24
24
|
render :picker, layout: nil, locals: { required: required, title: title, root: root, current: current, scopes: scopes.order(name: :asc),
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
class SearchesController < Decidim::ApplicationController
|
5
|
+
include Rectify::ControllerHelpers
|
6
|
+
include FormFactory
|
7
|
+
include FilterResource
|
8
|
+
include Paginable
|
9
|
+
|
10
|
+
helper Decidim::FiltersHelper
|
11
|
+
helper_method :term
|
12
|
+
|
13
|
+
def index
|
14
|
+
Search.call(term, current_organization, filters) do
|
15
|
+
on(:ok) do |results|
|
16
|
+
expose(results: results)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def default_filter_params
|
24
|
+
{
|
25
|
+
term: params[:term],
|
26
|
+
resource_type: nil,
|
27
|
+
decidim_scope_id: nil
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def term
|
32
|
+
@term ||= filter_params[:term]
|
33
|
+
end
|
34
|
+
|
35
|
+
def filters
|
36
|
+
filter_params
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# The controller to handle the current user's
|
5
|
+
# Terms and Conditions agreement.
|
6
|
+
class TosController < Decidim::ApplicationController
|
7
|
+
skip_before_action :store_current_location
|
8
|
+
|
9
|
+
def accept_tos
|
10
|
+
current_user.accepted_tos_version = Time.current
|
11
|
+
if current_user.save!
|
12
|
+
flash[:notice] = t("accept.success", scope: "decidim.pages.terms_and_conditions")
|
13
|
+
redirect_to after_sign_in_path_for current_user
|
14
|
+
else
|
15
|
+
flash[:alert] = t("accept.error", scope: "decidim.pages.terms_and_conditions")
|
16
|
+
redirect_to decidim.page_path tos_page
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -8,6 +8,7 @@ module Decidim
|
|
8
8
|
attribute :followable_gid, String
|
9
9
|
|
10
10
|
validates :followable_gid, :followable, presence: true
|
11
|
+
validates :followable, exclusion: { in: ->(form) { [form.current_user] } }
|
11
12
|
|
12
13
|
def followable
|
13
14
|
@followable ||= GlobalID::Locator.locate_signed followable_gid
|
@@ -20,9 +20,10 @@ module Decidim
|
|
20
20
|
|
21
21
|
validates :sign_up_as, inclusion: { in: %w(user user_group) }
|
22
22
|
validates :name, presence: true
|
23
|
-
validates :nickname, presence: true
|
23
|
+
validates :nickname, presence: true, length: { maximum: Decidim::User.nickname_max_length }
|
24
24
|
validates :email, presence: true, 'valid_email_2/email': { disposable: true }
|
25
25
|
validates :password, presence: true, confirmation: true, length: { in: Decidim::User.password_length }
|
26
|
+
validates :password_confirmation, presence: true
|
26
27
|
validates :tos_agreement, allow_nil: false, acceptance: true
|
27
28
|
|
28
29
|
validates :user_group_name, presence: true, if: :user_group?
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module CellsPaginateHelper
|
5
|
+
include Kaminari::Helpers::HelperMethods
|
6
|
+
include ActionView::Helpers::OutputSafetyHelper
|
7
|
+
include ActionView::Helpers::TranslationHelper
|
8
|
+
include Cell::ViewModel::Partial
|
9
|
+
include Decidim::PaginateHelper
|
10
|
+
|
11
|
+
def paginate(scope, options = {}, &block)
|
12
|
+
options = options.reverse_merge(views_prefix: "../views/")
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -6,7 +6,7 @@ module Decidim
|
|
6
6
|
# Renders the Call To Action button. Link and text can be configured
|
7
7
|
# per organization.
|
8
8
|
def cta_button
|
9
|
-
button_text = translated_attribute(current_organization.cta_button_text).presence || t("pages.home.hero.participate")
|
9
|
+
button_text = translated_attribute(current_organization.cta_button_text).presence || t("decidim.pages.home.hero.participate")
|
10
10
|
|
11
11
|
link_to button_text, cta_button_path, class: "hero-cta button expanded large button--sc"
|
12
12
|
end
|
@@ -185,5 +185,9 @@ module Decidim
|
|
185
185
|
|
186
186
|
alert_box(record.errors.full_messages_for(:base).join(","), "alert", false)
|
187
187
|
end
|
188
|
+
|
189
|
+
def foundation_datepicker_locale_tag
|
190
|
+
javascript_include_tag "datepicker-locales/foundation-datepicker.#{I18n.locale}.js" if I18n.locale != :en
|
191
|
+
end
|
188
192
|
end
|
189
193
|
end
|
@@ -16,9 +16,8 @@ module Decidim
|
|
16
16
|
# Returns nothing.
|
17
17
|
def linked_resources_for(resource, type, link_name)
|
18
18
|
linked_resources = resource.linked_resources(type, link_name).group_by { |linked_resource| linked_resource.class.name }
|
19
|
-
safe_join(linked_resources.map do |klass, resources|
|
20
|
-
next unless resources.any? { |r| r.component.published? }
|
21
19
|
|
20
|
+
safe_join(linked_resources.map do |klass, resources|
|
22
21
|
resource_manifest = klass.constantize.resource_manifest
|
23
22
|
content_tag(:div, class: "section") do
|
24
23
|
i18n_name = "#{resource.class.name.demodulize.underscore}_#{resource_manifest.name}"
|
@@ -13,7 +13,9 @@ module Decidim
|
|
13
13
|
#
|
14
14
|
# Returns boolean.
|
15
15
|
def has_visible_scopes?(resource)
|
16
|
-
resource.participatory_space.scopes_enabled? &&
|
16
|
+
resource.participatory_space.scopes_enabled? &&
|
17
|
+
resource.scope.present? &&
|
18
|
+
resource.participatory_space.scope != resource.scope
|
17
19
|
end
|
18
20
|
|
19
21
|
# Retrieves the translated name and type for an scope.
|
@@ -22,13 +24,11 @@ module Decidim
|
|
22
24
|
#
|
23
25
|
# Returns a string
|
24
26
|
def scope_name_for_picker(scope, global_name)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
global_name
|
31
|
-
end
|
27
|
+
return global_name unless scope
|
28
|
+
|
29
|
+
name = translated_attribute(scope.name)
|
30
|
+
name << " (#{translated_attribute(scope.scope_type.name)})" if scope.scope_type
|
31
|
+
name
|
32
32
|
end
|
33
33
|
|
34
34
|
# Renders a scopes picker field in a form.
|
@@ -66,8 +66,15 @@ module Decidim
|
|
66
66
|
# Returns nothing.
|
67
67
|
def scopes_picker_filter(form, name)
|
68
68
|
form.scopes_picker name, multiple: true, legend_title: I18n.t("decidim.scopes.scopes"), label: false do |scope|
|
69
|
-
{
|
70
|
-
|
69
|
+
{
|
70
|
+
url: decidim.scopes_picker_path(
|
71
|
+
root: try(:current_participatory_space)&.scope,
|
72
|
+
current: scope&.id,
|
73
|
+
title: I18n.t("decidim.scopes.prompt"),
|
74
|
+
global_value: "global"
|
75
|
+
),
|
76
|
+
text: scope_name_for_picker(scope, I18n.t("decidim.scopes.prompt"))
|
77
|
+
}
|
71
78
|
end
|
72
79
|
end
|
73
80
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A Helper to render and link to resources.
|
5
|
+
module SearchesHelper
|
6
|
+
def searchable_resource_human_name(resource)
|
7
|
+
resource.model_name.human.pluralize
|
8
|
+
end
|
9
|
+
|
10
|
+
def searchable_resources_as_options(all_label)
|
11
|
+
[["", all_label]] + Decidim::Searchable.searchable_resources.values.collect do |r|
|
12
|
+
[r.name, searchable_resource_human_name(r)]
|
13
|
+
end.sort
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This helper includes some methods to help with the inclusion of tooltips
|
5
|
+
# on the layout.
|
6
|
+
module TooltipHelper
|
7
|
+
def with_tooltip(title, &block)
|
8
|
+
content_tag(:span, data: { tooltip: true, disable_hover: false, click_open: false },
|
9
|
+
title: title, &block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -49,5 +49,15 @@ module Decidim
|
|
49
49
|
def homepage_big_url
|
50
50
|
homepage_image.big.url
|
51
51
|
end
|
52
|
+
|
53
|
+
def public_participatory_spaces
|
54
|
+
@public_participatory_spaces ||= Decidim.participatory_space_manifests.flat_map do |manifest|
|
55
|
+
manifest.participatory_spaces.call(self).public_spaces
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def published_components
|
60
|
+
@published_components ||= Component.where(participatory_space: public_participatory_spaces).published
|
61
|
+
end
|
52
62
|
end
|
53
63
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# This class encapsulates an action, which will be used by the
|
5
|
+
# permissions system to check if the user is allowed to perform it.
|
6
|
+
#
|
7
|
+
# It consists of a `scope` (which will typically be either `:public` or
|
8
|
+
# `:admin`), the name of the `:action` that is being performed and the
|
9
|
+
# `:subject` of the action.
|
10
|
+
class PermissionAction
|
11
|
+
# action - a Symbol representing the action being performed
|
12
|
+
# scope - a Symbol representing the scope of the action
|
13
|
+
# subject - a Symbol representing the subject of the action
|
14
|
+
def initialize(action:, scope:, subject:)
|
15
|
+
@action = action
|
16
|
+
@scope = scope
|
17
|
+
@subject = subject
|
18
|
+
@state = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :action, :scope, :subject
|
22
|
+
|
23
|
+
def allow!
|
24
|
+
raise PermissionCannotBeDisallowedError, "Allowing a previously disallowed action is not permitted: #{inspect}" if @state == :disallowed
|
25
|
+
@state = :allowed
|
26
|
+
end
|
27
|
+
|
28
|
+
def disallow!
|
29
|
+
@state = :disallowed
|
30
|
+
end
|
31
|
+
|
32
|
+
def allowed?
|
33
|
+
raise PermissionNotSetError, "Permission hasn't been allowed or disallowed yet: #{inspect}" if @state.blank?
|
34
|
+
@state == :allowed
|
35
|
+
end
|
36
|
+
|
37
|
+
class PermissionNotSetError < StandardError; end
|
38
|
+
class PermissionCannotBeDisallowedError < StandardError; end
|
39
|
+
end
|
40
|
+
end
|