decidim-core 0.32.1 → 0.32.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/cells/decidim/address_cell.rb +7 -3
- data/app/cells/decidim/card_metadata_cell.rb +3 -1
- data/app/cells/decidim/content_blocks/participatory_space_main_data/title.erb +1 -14
- data/app/cells/decidim/date_range/show.erb +6 -6
- data/app/cells/decidim/date_range_cell.rb +7 -2
- data/app/cells/decidim/following_cell.rb +1 -1
- data/app/cells/decidim/member/show.erb +1 -1
- data/app/cells/decidim/nav_links/show.erb +3 -1
- data/app/cells/decidim/share_text_widget/modal.erb +1 -0
- data/app/cells/decidim/share_widget/modal.erb +1 -0
- data/app/cells/decidim/share_widget/qr_code_modal.erb +2 -4
- data/app/commands/decidim/create_follow.rb +2 -3
- data/app/commands/decidim/create_omniauth_registration.rb +19 -7
- data/app/commands/decidim/create_user_report.rb +1 -1
- data/app/commands/decidim/destroy_account.rb +6 -6
- data/app/commands/decidim/destroy_ephemeral_user.rb +2 -0
- data/app/commands/decidim/invite_user.rb +1 -1
- data/app/commands/decidim/multiple_attachments_methods.rb +17 -3
- data/app/commands/decidim/update_resources_taxonomies.rb +2 -1
- data/app/controllers/concerns/decidim/devise_authentication_methods.rb +4 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +2 -0
- data/app/controllers/concerns/decidim/direct_upload.rb +12 -6
- data/app/controllers/concerns/decidim/disable_redirection_to_external_host.rb +2 -0
- data/app/controllers/concerns/decidim/filter_resource.rb +2 -0
- data/app/controllers/concerns/decidim/impersonate_users.rb +4 -4
- data/app/controllers/concerns/decidim/locale_switcher.rb +12 -10
- data/app/controllers/concerns/decidim/needs_organization.rb +15 -0
- data/app/controllers/concerns/decidim/needs_permission.rb +22 -10
- data/app/controllers/concerns/decidim/onboarding_action_methods.rb +2 -0
- data/app/controllers/concerns/decidim/paginable.rb +7 -3
- data/app/controllers/concerns/decidim/payload_info.rb +2 -0
- data/app/controllers/concerns/decidim/resource_versions_concern.rb +14 -0
- data/app/controllers/decidim/amendments_controller.rb +34 -6
- data/app/controllers/decidim/application_controller.rb +2 -6
- data/app/controllers/decidim/authorization_modals_controller.rb +3 -1
- data/app/controllers/decidim/components/base_controller.rb +2 -0
- data/app/controllers/decidim/devise/passwords_controller.rb +8 -0
- data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +10 -4
- data/app/controllers/decidim/doorkeeper/credentials_controller.rb +6 -1
- data/app/controllers/decidim/favicon_controller.rb +9 -0
- data/app/controllers/decidim/free_resource_authorization_modals_controller.rb +2 -0
- data/app/controllers/decidim/gamification/badges_controller.rb +2 -0
- data/app/controllers/decidim/homepage_controller.rb +4 -1
- data/app/controllers/decidim/likes_controller.rb +1 -1
- data/app/controllers/decidim/links_controller.rb +2 -0
- data/app/controllers/decidim/manifests_controller.rb +2 -0
- data/app/controllers/decidim/messaging/conversations_controller.rb +11 -5
- data/app/controllers/decidim/newsletters_controller.rb +4 -0
- data/app/controllers/decidim/notifications_subscriptions_controller.rb +4 -0
- data/app/controllers/decidim/offline_controller.rb +5 -1
- data/app/controllers/decidim/open_data_controller.rb +5 -1
- data/app/controllers/decidim/pages_controller.rb +31 -3
- data/app/controllers/decidim/private_downloads_controller.rb +2 -0
- data/app/controllers/decidim/profiles_controller.rb +20 -2
- data/app/controllers/decidim/qr_controller.rb +3 -1
- data/app/controllers/decidim/resource_autocomplete_controller.rb +2 -0
- data/app/controllers/decidim/searches_controller.rb +2 -0
- data/app/controllers/decidim/short_links_controller.rb +4 -0
- data/app/controllers/decidim/static_map_controller.rb +2 -0
- data/app/controllers/decidim/timeouts_controller.rb +4 -0
- data/app/controllers/decidim/tos_controller.rb +2 -0
- data/app/controllers/decidim/upload_validations_controller.rb +4 -2
- data/app/controllers/decidim/user_activities_controller.rb +3 -0
- data/app/forms/decidim/upload_validation_form.rb +16 -10
- data/app/helpers/concerns/decidim/user_role_checker.rb +35 -10
- data/app/helpers/decidim/cells_paginate_helper.rb +0 -5
- data/app/helpers/decidim/decidim_form_helper.rb +1 -1
- data/app/helpers/decidim/layout_helper.rb +1 -0
- data/app/helpers/decidim/orders_helper.rb +8 -6
- data/app/helpers/decidim/paginate_helper.rb +15 -3
- data/app/helpers/decidim/sanitize_helper.rb +11 -1
- data/app/helpers/decidim/url_helper.rb +35 -0
- data/app/jobs/decidim/application_job.rb +4 -0
- data/app/jobs/decidim/open_data_job.rb +21 -5
- data/app/models/decidim/action_log.rb +7 -1
- data/app/models/decidim/authorization.rb +24 -0
- data/app/models/decidim/component.rb +10 -0
- data/app/models/decidim/like.rb +1 -1
- data/app/models/decidim/oauth_application.rb +1 -0
- data/app/models/decidim/user.rb +1 -0
- data/app/models/decidim/user_base_entity.rb +1 -1
- data/app/packs/src/decidim/callout.js +10 -0
- data/app/packs/src/decidim/callout.test.js +32 -0
- data/app/packs/src/decidim/controllers/accordion/accordion.test.js +64 -0
- data/app/packs/src/decidim/controllers/accordion/controller.js +43 -0
- data/app/packs/src/decidim/controllers/autofocus/controller.js +30 -0
- data/app/packs/src/decidim/controllers/language_change/controller.js +21 -8
- data/app/packs/src/decidim/controllers/language_change/language_change.test.js +0 -1
- data/app/packs/src/decidim/controllers/mention/controller.js +32 -3
- data/app/packs/src/decidim/controllers/mention/input_mentions.test.js +8 -5
- data/app/packs/src/decidim/controllers/multiple_mentions/input_multiple_mentions.test.js +1 -1
- data/app/packs/src/decidim/datepicker/datepicker_functions.js +61 -32
- data/app/packs/src/decidim/datepicker/form_datepicker.js +18 -2
- data/app/packs/src/decidim/datepicker/generate_datepicker.js +16 -8
- data/app/packs/src/decidim/datepicker/generate_timepicker.js +5 -3
- data/app/packs/src/decidim/datepicker/test/date.test.js +8 -0
- data/app/packs/src/decidim/datepicker/test/datepicker_functions_adjust_picker_position.test.js +64 -0
- data/app/packs/src/decidim/datepicker/test/time.test.js +39 -24
- data/app/packs/src/decidim/editor/common/suggestion.js +32 -22
- data/app/packs/src/decidim/editor/extensions/mention/index.js +14 -3
- data/app/packs/src/decidim/editor/index.js +4 -0
- data/app/packs/src/decidim/editor/test/extensions/mention.test.js +32 -9
- data/app/packs/src/decidim/refactor/implementation/autofocus.js +22 -0
- data/app/packs/src/decidim/refactor/implementation/autofocus.test.js +171 -0
- data/app/packs/src/decidim/utilities/dom.js +2 -2
- data/app/packs/stylesheets/decidim/_content_blocks.scss +4 -10
- data/app/packs/stylesheets/decidim/_conversations.scss +0 -8
- data/app/packs/stylesheets/decidim/_datepicker.scss +3 -3
- data/app/packs/stylesheets/decidim/_modal.scss +16 -8
- data/app/packs/stylesheets/decidim/_modal_share.scss +0 -22
- data/app/packs/stylesheets/decidim/_participatory_spaces.scss +11 -1
- data/app/packs/stylesheets/decidim/_rich_text.scss +12 -9
- data/app/packs/stylesheets/decidim/_spinner.scss +16 -0
- data/app/packs/stylesheets/decidim/_tom_select.scss +1 -1
- data/app/packs/stylesheets/decidim/_typography.scss +5 -2
- data/app/packs/stylesheets/decidim/application.scss +1 -0
- data/app/packs/stylesheets/decidim/legacy/email.scss +0 -5
- data/app/permissions/decidim/permissions.rb +20 -0
- data/app/presenters/decidim/admin_log/component_presenter.rb +1 -1
- data/app/presenters/decidim/log/base_presenter.rb +20 -2
- data/app/presenters/decidim/log/user_presenter.rb +2 -2
- data/app/presenters/decidim/menu_item_presenter.rb +1 -5
- data/app/presenters/decidim/resource_presenter.rb +11 -0
- data/app/resolvers/decidim/meta_image_url_resolver.rb +7 -1
- data/app/serializers/decidim/exporters/open_data_blocked_user_serializer.rb +11 -2
- data/app/serializers/decidim/exporters/open_data_moderation_serializer.rb +25 -1
- data/app/services/decidim/action_logger.rb +97 -29
- data/app/services/decidim/svg_content_validator.rb +889 -0
- data/app/uploaders/decidim/application_uploader.rb +2 -2
- data/app/validators/uploader_image_content_validator.rb +280 -0
- data/app/views/decidim/application/_radio_accordion.html.erb +1 -5
- data/app/views/decidim/manifests/show.json.erb +25 -22
- data/app/views/decidim/messaging/conversations/_add_conversation_users.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/create.js.erb +1 -3
- data/app/views/decidim/shared/_login_modal.html.erb +12 -14
- data/app/views/decidim/shared/_results_per_page.html.erb +1 -1
- data/app/views/layouts/decidim/_mailer_logo.html.erb +1 -1
- data/app/views/layouts/decidim/header/_menu_breadcrumb_desktop.html.erb +3 -2
- data/config/initializers/rack_attack.rb +10 -0
- data/config/locales/bg.yml +1 -4
- data/config/locales/ca-IT.yml +10 -4
- data/config/locales/ca.yml +17 -11
- data/config/locales/cs.yml +24 -4
- data/config/locales/de.yml +100 -6
- data/config/locales/en.yml +10 -4
- data/config/locales/es-MX.yml +10 -4
- data/config/locales/es-PY.yml +10 -4
- data/config/locales/es.yml +16 -10
- data/config/locales/eu.yml +171 -168
- data/config/locales/fi-plain.yml +5 -3
- data/config/locales/fi.yml +5 -3
- data/config/locales/fr-CA.yml +10 -4
- data/config/locales/fr.yml +10 -4
- data/config/locales/gl.yml +1484 -33
- data/config/locales/hu.yml +0 -1
- data/config/locales/it.yml +0 -2
- data/config/locales/ja.yml +6 -4
- data/config/locales/pl.yml +1 -4
- data/config/locales/pt-BR.yml +1 -4
- data/config/locales/ro-RO.yml +0 -3
- data/config/locales/sk.yml +70 -4
- data/config/locales/sv.yml +71 -15
- data/config/locales/tr-TR.yml +1 -3
- data/config/routes.rb +11 -2
- data/db/migrate/20250523104311_move_cta_to_hero_content_block.rb +1 -1
- data/db/migrate/20250527122040_move_highlighted_content_banner_settings_to_content_block.rb +3 -0
- data/db/migrate/20260909000000_add_failed_attempts_and_locked_at_to_decidim_authorizations.rb +8 -0
- data/db/migrate/20261007090000_make_user_optional_in_action_logs.rb +12 -0
- data/decidim-core.gemspec +1 -1
- data/lib/decidim/api/functions/user_entity_list.rb +1 -0
- data/lib/decidim/api/types/user_moderation_type.rb +2 -2
- data/lib/decidim/content_parsers/user_parser.rb +1 -1
- data/lib/decidim/content_parsers.rb +0 -1
- data/lib/decidim/content_renderers/mention_resource_renderer.rb +19 -5
- data/lib/decidim/content_renderers/user_renderer.rb +15 -4
- data/lib/decidim/core/test/shared_examples/participatory_space_members_page_examples.rb +77 -0
- data/lib/decidim/core/test/shared_examples/participatory_space_members_shared_examples.rb +58 -0
- data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +23 -1
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/core.rb +10 -1
- data/lib/decidim/form_builder.rb +9 -1
- data/lib/decidim/has_upload_validations.rb +1 -0
- data/lib/decidim/legacy_form_builder.rb +4 -0
- data/lib/decidim/maintenance/import_models/scope.rb +2 -1
- data/lib/decidim/maintenance/taxonomy_importer.rb +4 -1
- data/lib/decidim/seeds.rb +1 -1
- data/lib/decidim/view_model.rb +1 -0
- data/lib/tasks/decidim_open_data_tasks.rake +7 -0
- metadata +14 -7
- data/lib/decidim/content_parsers/inline_images_parser.rb +0 -68
- data/lib/tasks/upgrade/decidim_active_storage_migration_tasks.rake +0 -79
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b36d5939e11ea9f6641061565d89c529db8c1bcbb9c2d1eb42a3e38467962bfa
|
|
4
|
+
data.tar.gz: 9e114b4cb16118a1e9ea8d668c74fb7d5cd22a3b073bd26bf726280d479c3a00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d231f0aaa0f6b3470ad0f9e5f651c96291211c1d2bfd729a8e2828ea19e9f286e245524b44a5282977addaf958241ba2696e3c3b8cbbd1dec04da57a6cd70239
|
|
7
|
+
data.tar.gz: 188fc272e8072d119a29d91fefa8808c19ad793e9699512979af8f5786c6c9945a5709b9da28f5ce5e35a05e8054ccd614a5126c5d965bd28a09a6a8d9e9759c
|
|
@@ -37,8 +37,12 @@ module Decidim
|
|
|
37
37
|
t("show.pending_address", scope: "decidim.meetings.meetings")
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
# Returns true when the model has both start and end times present, so the
|
|
41
|
+
# start-and-end-time section can be rendered.
|
|
40
42
|
def display_start_and_end_time?
|
|
41
|
-
model.respond_to?(:start_time) && model.respond_to?(:end_time)
|
|
43
|
+
return false unless model.respond_to?(:start_time) && model.respond_to?(:end_time)
|
|
44
|
+
|
|
45
|
+
model.start_time.present? && model.end_time.present?
|
|
42
46
|
end
|
|
43
47
|
|
|
44
48
|
def start_and_end_time
|
|
@@ -63,11 +67,11 @@ module Decidim
|
|
|
63
67
|
private
|
|
64
68
|
|
|
65
69
|
def start_time
|
|
66
|
-
l model.start_time, format:
|
|
70
|
+
l model.start_time, format: :time_of_day
|
|
67
71
|
end
|
|
68
72
|
|
|
69
73
|
def end_time
|
|
70
|
-
l model.end_time, format:
|
|
74
|
+
l model.end_time, format: :time_of_day_with_time_zone
|
|
71
75
|
end
|
|
72
76
|
end
|
|
73
77
|
end
|
|
@@ -101,11 +101,13 @@ module Decidim
|
|
|
101
101
|
}
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
+
# Returns the metadata item with the formatted start date time, or nil when
|
|
105
|
+
# the dates are blank.
|
|
104
106
|
def start_date_item
|
|
105
107
|
return if dates_blank?
|
|
106
108
|
|
|
107
109
|
{
|
|
108
|
-
text: I18n.l(start_date, format:
|
|
110
|
+
text: I18n.l(start_date.in_time_zone, format: :time_of_day_with_time_zone),
|
|
109
111
|
icon: "time-line"
|
|
110
112
|
}
|
|
111
113
|
end
|
|
@@ -23,15 +23,11 @@
|
|
|
23
23
|
<% end %>
|
|
24
24
|
</div>
|
|
25
25
|
|
|
26
|
-
<button class="button button__sm button__text-secondary mt-2" data-controls="panel-view-more-<%= seed %>" aria-expanded="false"
|
|
26
|
+
<button class="button button__sm button__text-secondary mt-2" data-controls="panel-view-more-<%= seed %>" aria-expanded="false">
|
|
27
27
|
<span>
|
|
28
28
|
<%= t("view_more", scope: "layouts.decidim.announcements") %>
|
|
29
29
|
</span>
|
|
30
30
|
<%= icon "arrow-down-s-line" %>
|
|
31
|
-
<span>
|
|
32
|
-
<%= t("view_less", scope: "layouts.decidim.announcements") %>
|
|
33
|
-
</span>
|
|
34
|
-
<%= icon "arrow-up-s-line" %>
|
|
35
31
|
</button>
|
|
36
32
|
<% else %>
|
|
37
33
|
<% if rich_text_processors? %>
|
|
@@ -42,12 +38,3 @@
|
|
|
42
38
|
<% end %>
|
|
43
39
|
</div>
|
|
44
40
|
<% end %>
|
|
45
|
-
<script>
|
|
46
|
-
const button = document.querySelector('button[data-controls^="panel-view-more"]')
|
|
47
|
-
button.addEventListener('keydown', function(e){
|
|
48
|
-
// press space or enter
|
|
49
|
-
if (e.keyCode === 32 || e.keyCode === 13){
|
|
50
|
-
document.querySelector('div[id^=panel-view-more]').toggleAttribute('inert')
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
</script>
|
|
@@ -2,29 +2,29 @@
|
|
|
2
2
|
<% if same_day? %>
|
|
3
3
|
<div data-date>
|
|
4
4
|
<%= l start_time, format: "%d" %>
|
|
5
|
-
<span data-month><%= l start_time, format:
|
|
5
|
+
<span data-month><%= l start_time, format: show_year? ? :decidim_month_and_year : :decidim_month %></span>
|
|
6
6
|
</div>
|
|
7
7
|
<div data-time>
|
|
8
|
-
<%= l start_time, format:
|
|
8
|
+
<%= l start_time, format: :time_of_day %> - <%= l end_time, format: :time_of_day %>
|
|
9
9
|
</div>
|
|
10
10
|
<% else %>
|
|
11
11
|
<div>
|
|
12
12
|
<div data-date>
|
|
13
13
|
<%= l start_time, format: "%d" %>
|
|
14
|
-
<span data-month><%= l start_time, format:
|
|
14
|
+
<span data-month><%= l start_time, format: show_year? ? :decidim_month_and_year : :decidim_month %></span>
|
|
15
15
|
</div>
|
|
16
16
|
<div data-time>
|
|
17
|
-
<%= l start_time, format:
|
|
17
|
+
<%= l start_time, format: :time_of_day %>
|
|
18
18
|
</div>
|
|
19
19
|
</div>
|
|
20
20
|
<%= icon "arrow-right-line" %>
|
|
21
21
|
<div>
|
|
22
22
|
<div data-date>
|
|
23
23
|
<%= l end_time, format: "%d" %>
|
|
24
|
-
<span data-month><%= l end_time, format:
|
|
24
|
+
<span data-month><%= l end_time, format: show_year? ? :decidim_month_and_year : :decidim_month %></span>
|
|
25
25
|
</div>
|
|
26
26
|
<div data-time>
|
|
27
|
-
<%= l end_time, format:
|
|
27
|
+
<%= l end_time, format: :time_of_day %>
|
|
28
28
|
</div>
|
|
29
29
|
</div>
|
|
30
30
|
<% end %>
|
|
@@ -21,12 +21,17 @@ module Decidim
|
|
|
21
21
|
|
|
22
22
|
private
|
|
23
23
|
|
|
24
|
+
# Values are normalized to the rendering time zone so the date checks below
|
|
25
|
+
# and the rendered values agree. Plain `Time` and `Date` values (e.g. from
|
|
26
|
+
# `Time.parse` or a database read outside the organization time zone) can
|
|
27
|
+
# fall on a different day once converted, and the checks must use the same
|
|
28
|
+
# zone as the display.
|
|
24
29
|
def start_time
|
|
25
|
-
model[:start]
|
|
30
|
+
model[:start]&.in_time_zone
|
|
26
31
|
end
|
|
27
32
|
|
|
28
33
|
def end_time
|
|
29
|
-
model[:end]
|
|
34
|
+
model[:end]&.in_time_zone
|
|
30
35
|
end
|
|
31
36
|
|
|
32
37
|
def same_day?
|
|
@@ -11,7 +11,7 @@ module Decidim
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def public_followings
|
|
14
|
-
@public_followings ||=
|
|
14
|
+
@public_followings ||= model.public_users_followings.page(params[:page]).per(20)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def non_public_followings?
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
<% model.each do |item| %>
|
|
9
9
|
<li>
|
|
10
10
|
<%= link_to item[:url], class: "participatory-space__nav-item" do %>
|
|
11
|
-
|
|
11
|
+
<span class="participatory-space__nav-label">
|
|
12
|
+
<%= decidim_escape_translated(item[:name]) %>
|
|
13
|
+
</span>
|
|
12
14
|
<%= icon "arrow-right-line" %>
|
|
13
15
|
<% end %>
|
|
14
16
|
</li>
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<%= decidim_modal id: "QRCodeDialog", class: "qr-modal" do %>
|
|
2
2
|
<div data-dialog-container>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<h2 id="dialog-title-qr-code-dialog" tabindex="-1"><%= t("decidim.share_widget.qr_code") %></h2>
|
|
6
|
-
</div>
|
|
3
|
+
<%= icon "qr-code-line" %>
|
|
4
|
+
<h2 id="dialog-title-qr-code-dialog" tabindex="-1" data-dialog-title><%= t("decidim.share_widget.qr_code") %></h2>
|
|
7
5
|
<div class="content">
|
|
8
6
|
<div>
|
|
9
7
|
<% if current_organization.logo.attached? %>
|
|
@@ -33,9 +33,8 @@ module Decidim
|
|
|
33
33
|
attr_reader :follow, :form
|
|
34
34
|
|
|
35
35
|
def create_follow!
|
|
36
|
-
@follow =
|
|
37
|
-
followable: form.followable
|
|
38
|
-
user: current_user
|
|
36
|
+
@follow = current_user.following_follows.where(
|
|
37
|
+
followable: form.followable
|
|
39
38
|
).first_or_create!
|
|
40
39
|
end
|
|
41
40
|
|
|
@@ -30,9 +30,9 @@ module Decidim
|
|
|
30
30
|
end
|
|
31
31
|
return broadcast(:invalid) if form.invalid?
|
|
32
32
|
|
|
33
|
+
initialize_user
|
|
33
34
|
transaction do
|
|
34
|
-
|
|
35
|
-
@identity = create_identity
|
|
35
|
+
@identity = existing_identity || create_identity
|
|
36
36
|
end
|
|
37
37
|
trigger_omniauth_event
|
|
38
38
|
|
|
@@ -50,11 +50,23 @@ module Decidim
|
|
|
50
50
|
|
|
51
51
|
REGEXP_SANITIZER = /[<>?%&\^*#@()\[\]=+:;"{}\\|]/
|
|
52
52
|
|
|
53
|
+
def initialize_user
|
|
54
|
+
create_or_find_user
|
|
55
|
+
rescue ActiveRecord::RecordNotUnique
|
|
56
|
+
@create_retries ||= 0
|
|
57
|
+
|
|
58
|
+
# This may happen if the callback endpoint is called several times in a
|
|
59
|
+
# row which some Omniauth providers may allow (e.g. through a double
|
|
60
|
+
# click). This should ensure that the user will not get an error even if
|
|
61
|
+
# the authentication service sent the callback request several times.
|
|
62
|
+
raise if @create_retries >= 2
|
|
63
|
+
|
|
64
|
+
@create_retries += 1
|
|
65
|
+
retry
|
|
66
|
+
end
|
|
67
|
+
|
|
53
68
|
def create_or_find_user
|
|
54
|
-
@user =
|
|
55
|
-
email: verified_email,
|
|
56
|
-
organization:
|
|
57
|
-
)
|
|
69
|
+
@user = organization.users.find_or_initialize_by(email: verified_email)
|
|
58
70
|
|
|
59
71
|
if @user.persisted?
|
|
60
72
|
# If user has left the account unconfirmed and later on decides to sign
|
|
@@ -105,7 +117,7 @@ module Decidim
|
|
|
105
117
|
end
|
|
106
118
|
|
|
107
119
|
def existing_identity
|
|
108
|
-
@existing_identity ||= Identity.find_by(
|
|
120
|
+
@existing_identity ||= Identity.find_by( # rubocop:disable Decidim/OrganizationScopedFinder -- user: organization.users scopes the lookup to the current organization
|
|
109
121
|
user: organization.users,
|
|
110
122
|
provider: form.provider,
|
|
111
123
|
uid: form.uid
|
|
@@ -38,7 +38,7 @@ module Decidim
|
|
|
38
38
|
attr_reader :form, :report
|
|
39
39
|
|
|
40
40
|
def find_or_create_moderation!
|
|
41
|
-
@moderation =
|
|
41
|
+
@moderation = @reportable.user_moderation || @reportable.create_user_moderation!
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def create_report!
|
|
@@ -57,15 +57,15 @@ module Decidim
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def destroy_user_badges
|
|
60
|
-
Decidim::Gamification::BadgeScore.where(user: current_user).find_each(&:destroy)
|
|
60
|
+
Decidim::Gamification::BadgeScore.where(user: current_user).find_each(&:destroy) # rubocop:disable Decidim/OrganizationScopedFinder -- records belong to the current user
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
def destroy_user_reports
|
|
64
|
-
Decidim::UserModeration.where(user: current_user).find_each(&:destroy)
|
|
64
|
+
Decidim::UserModeration.where(user: current_user).find_each(&:destroy) # rubocop:disable Decidim/OrganizationScopedFinder -- records belong to the current user
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def destroy_user_likes
|
|
68
|
-
Decidim::Like.where(author: current_user).find_each(&:destroy)
|
|
68
|
+
Decidim::Like.where(author: current_user).find_each(&:destroy) # rubocop:disable Decidim/OrganizationScopedFinder -- records belong to the current user
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
def destroy_user_identities
|
|
@@ -97,12 +97,12 @@ module Decidim
|
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def destroy_follows
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
current_user.follows.find_each(&:destroy)
|
|
101
|
+
current_user.following_follows.find_each(&:destroy)
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
def destroy_member
|
|
105
|
-
Decidim::ParticipatorySpace::Member.where(user: current_user).find_each(&:destroy)
|
|
105
|
+
Decidim::ParticipatorySpace::Member.where(user: current_user).find_each(&:destroy) # rubocop:disable Decidim/OrganizationScopedFinder -- records belong to the current user
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
def delegate_destroy_to_participatory_spaces
|
|
@@ -32,7 +32,9 @@ module Decidim
|
|
|
32
32
|
attr_reader :user
|
|
33
33
|
|
|
34
34
|
def destroy_pending_authorizations!
|
|
35
|
+
# rubocop:disable Decidim/OrganizationScopedFinder -- authorizations belong to the ephemeral user passed to the command
|
|
35
36
|
Decidim::Authorization.where(user:, granted_at: nil).destroy_all
|
|
37
|
+
# rubocop:enable Decidim/OrganizationScopedFinder
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
def destroy_account!
|
|
@@ -22,7 +22,7 @@ module Decidim
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def update_attachment_title_for(attachment)
|
|
25
|
-
|
|
25
|
+
attachments_for(attachment_parent).find_by(id: attachment[:id])&.update(title: title_for(attachment))
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def attachments_invalid?
|
|
@@ -43,7 +43,7 @@ module Decidim
|
|
|
43
43
|
weight = first_weight
|
|
44
44
|
# Add the weights first to the old attachments
|
|
45
45
|
attachment_ids = keep_ids
|
|
46
|
-
|
|
46
|
+
attachments_for(attachment_parent).where(id: attachment_ids).each do |attachment|
|
|
47
47
|
attachment.update!(weight:)
|
|
48
48
|
weight += 1
|
|
49
49
|
end
|
|
@@ -57,7 +57,8 @@ module Decidim
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def attachment_cleanup!(include_all_attachments: false)
|
|
60
|
-
attachments =
|
|
60
|
+
attachments = attachments_for(attachments_attached_to)
|
|
61
|
+
attachments = attachments.with_attached_file if include_all_attachments
|
|
61
62
|
|
|
62
63
|
attachments.each do |attachment|
|
|
63
64
|
attachment.destroy! unless keep_ids.include?(attachment.id)
|
|
@@ -79,6 +80,19 @@ module Decidim
|
|
|
79
80
|
form.current_component.organization if form.respond_to?(:current_component)
|
|
80
81
|
end
|
|
81
82
|
|
|
83
|
+
def attachment_parent
|
|
84
|
+
@attached_to || @resource || attachments_attached_to
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Only attachments owned by the record being changed can be modified. Some
|
|
88
|
+
# parents, such as organizations, do not include the attachments concern,
|
|
89
|
+
# so fall back to filtering by the polymorphic association.
|
|
90
|
+
def attachments_for(parent)
|
|
91
|
+
return parent.attachments if parent.respond_to?(:attachments)
|
|
92
|
+
|
|
93
|
+
Decidim::Attachment.where(attached_to: parent) # rubocop:disable Decidim/OrganizationScopedFinder -- parent is the current organization or an already scoped record
|
|
94
|
+
end
|
|
95
|
+
|
|
82
96
|
def signed_id_for(attachment)
|
|
83
97
|
return attachment[:file] if attachment.is_a?(Hash)
|
|
84
98
|
|
|
@@ -7,9 +7,10 @@ module Decidim
|
|
|
7
7
|
#
|
|
8
8
|
# taxonomy_ids - the taxonomy ids to update
|
|
9
9
|
# resources - an ApplicationRecord collection of resources to update.
|
|
10
|
+
# organization - the organization that owns the taxonomies.
|
|
10
11
|
def initialize(taxonomy_ids, resources, organization)
|
|
11
12
|
@organization = organization
|
|
12
|
-
@taxonomies =
|
|
13
|
+
@taxonomies = organization.taxonomies.non_roots.where(id: taxonomy_ids)
|
|
13
14
|
@resources = resources
|
|
14
15
|
@response = { taxonomies: [], successful: [], errored: [] }
|
|
15
16
|
end
|
|
@@ -9,6 +9,8 @@ module Decidim
|
|
|
9
9
|
include Decidim::OnboardingActionMethods
|
|
10
10
|
|
|
11
11
|
included do
|
|
12
|
+
protected
|
|
13
|
+
|
|
12
14
|
def after_sign_in_path_for(user)
|
|
13
15
|
if user.present? && user.blocked?
|
|
14
16
|
check_user_block_status(user)
|
|
@@ -21,6 +23,8 @@ module Decidim
|
|
|
21
23
|
end
|
|
22
24
|
end
|
|
23
25
|
|
|
26
|
+
private
|
|
27
|
+
|
|
24
28
|
# Calling the `stored_location_for` method removes the key, so in order
|
|
25
29
|
# to check if there is any pending redirect after login I need to call
|
|
26
30
|
# this method and use the value to set a pending redirect. This is the
|
|
@@ -30,7 +30,7 @@ module Decidim
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def extension
|
|
33
|
-
File.extname(blob_args[:filename]).delete(".")
|
|
33
|
+
File.extname(blob_args[:filename]).delete(".").try(:downcase)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def maximum_allowed_size
|
|
@@ -42,11 +42,17 @@ module Decidim
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def allowed_extensions
|
|
45
|
-
if user_has_elevated_role?
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
extensions = if user_has_elevated_role?
|
|
46
|
+
current_organization.settings.upload_allowed_file_extensions_admin
|
|
47
|
+
else
|
|
48
|
+
current_organization.settings.upload_allowed_file_extensions
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# The configured extensions are matched case-insensitively, as the
|
|
52
|
+
# filename extension is normalized before the comparison. An allowlist
|
|
53
|
+
# entry such as "JPG" must therefore accept both "photo.jpg" and
|
|
54
|
+
# "photo.JPG".
|
|
55
|
+
extensions.map { |pattern| pattern.to_s.downcase }
|
|
50
56
|
end
|
|
51
57
|
|
|
52
58
|
def content_types
|
|
@@ -7,6 +7,8 @@ module Decidim
|
|
|
7
7
|
extend ActiveSupport::Concern
|
|
8
8
|
|
|
9
9
|
included do
|
|
10
|
+
private
|
|
11
|
+
|
|
10
12
|
def redirect_back(fallback_location:, allow_other_host: true, **args) # rubocop:disable Lint/UnusedMethodArgument
|
|
11
13
|
super(fallback_location:, allow_other_host: Decidim.allow_open_redirects, **args)
|
|
12
14
|
end
|
|
@@ -26,6 +26,8 @@ module Decidim
|
|
|
26
26
|
@current_user ||= managed_user || real_user
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
private
|
|
30
|
+
|
|
29
31
|
# Clear the `@real_user` instance variable because otherwise that would be
|
|
30
32
|
# the return value for any `current_user` calls after the user has already
|
|
31
33
|
# signed out.
|
|
@@ -47,8 +49,6 @@ module Decidim
|
|
|
47
49
|
((impersonation_session_ends_at - Time.current) / 60).round
|
|
48
50
|
end
|
|
49
51
|
|
|
50
|
-
private
|
|
51
|
-
|
|
52
52
|
def current_user_impersonated?
|
|
53
53
|
current_user && impersonation_log.present?
|
|
54
54
|
end
|
|
@@ -87,14 +87,14 @@ module Decidim
|
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
def expired_log
|
|
90
|
-
@expired_log ||= Decidim::ImpersonationLog
|
|
90
|
+
@expired_log ||= Decidim::ImpersonationLog # rubocop:disable Decidim/OrganizationScopedFinder -- real_user is the impersonated user of the current session
|
|
91
91
|
.where(admin: real_user)
|
|
92
92
|
.expired
|
|
93
93
|
.first
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
def impersonation_log
|
|
97
|
-
@impersonation_log ||= Decidim::ImpersonationLog
|
|
97
|
+
@impersonation_log ||= Decidim::ImpersonationLog # rubocop:disable Decidim/OrganizationScopedFinder -- real_user is the impersonated user of the current session
|
|
98
98
|
.where(admin: real_user)
|
|
99
99
|
.active
|
|
100
100
|
.first
|
|
@@ -25,16 +25,6 @@ module Decidim
|
|
|
25
25
|
I18n.with_locale(locale, &)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
# Adds the current locale to all the URLs generated by url_for so users
|
|
29
|
-
# experience a consistent behaviour if they copy or share links.
|
|
30
|
-
#
|
|
31
|
-
# Returns a Hash.
|
|
32
|
-
def default_url_options
|
|
33
|
-
return {} if locale_in_script_name?
|
|
34
|
-
|
|
35
|
-
{ locale: current_locale }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
28
|
# The current locale for the user. Available as a helper for the views.
|
|
39
29
|
#
|
|
40
30
|
# Returns a String.
|
|
@@ -142,6 +132,18 @@ module Decidim
|
|
|
142
132
|
uri.to_s
|
|
143
133
|
end
|
|
144
134
|
|
|
135
|
+
private
|
|
136
|
+
|
|
137
|
+
# Adds the current locale to all the URLs generated by url_for so users
|
|
138
|
+
# experience a consistent behaviour if they copy or share links.
|
|
139
|
+
#
|
|
140
|
+
# Returns a Hash.
|
|
141
|
+
def default_url_options
|
|
142
|
+
return {} if locale_in_script_name?
|
|
143
|
+
|
|
144
|
+
{ locale: current_locale }
|
|
145
|
+
end
|
|
146
|
+
|
|
145
147
|
def locale_in_script_name?
|
|
146
148
|
script_name = request&.script_name.to_s
|
|
147
149
|
return false if script_name.blank?
|
|
@@ -37,6 +37,21 @@ module Decidim
|
|
|
37
37
|
def verify_organization
|
|
38
38
|
redirect_to decidim_system.root_path unless current_organization
|
|
39
39
|
end
|
|
40
|
+
|
|
41
|
+
# Checks whether the given resource belongs to the current organization.
|
|
42
|
+
def in_organization?(resource)
|
|
43
|
+
return false if resource.blank?
|
|
44
|
+
|
|
45
|
+
resource.organization == current_organization
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Raises ActiveRecord::RecordNotFound when the given resource belongs to
|
|
49
|
+
# another organization. Blank resources are handled by the callers.
|
|
50
|
+
def ensure_in_organization!(resource)
|
|
51
|
+
return if resource.blank? || in_organization?(resource)
|
|
52
|
+
|
|
53
|
+
raise ActiveRecord::RecordNotFound
|
|
54
|
+
end
|
|
40
55
|
end
|
|
41
56
|
end
|
|
42
57
|
end
|
|
@@ -41,19 +41,11 @@ module Decidim
|
|
|
41
41
|
component_settings: try(:component_settings),
|
|
42
42
|
current_organization: try(:current_organization),
|
|
43
43
|
current_component: try(:current_component),
|
|
44
|
-
share_token:
|
|
44
|
+
share_token: store_share_token
|
|
45
45
|
}
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
if Rails.env.development?
|
|
50
|
-
Rails.logger.debug "==========="
|
|
51
|
-
Rails.logger.debug [permission_scope, action, subject, permission_class_chain].map(&:inspect).join("\n")
|
|
52
|
-
Rails.logger.debug "==========="
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
raise Decidim::ActionForbidden unless allowed_to?(action, subject, extra_context)
|
|
56
|
-
end
|
|
48
|
+
public
|
|
57
49
|
|
|
58
50
|
# rubocop:disable Metrics/ParameterLists
|
|
59
51
|
def allowed_to?(action, subject, extra_context = {}, chain = permission_class_chain, user = current_user, scope = nil)
|
|
@@ -76,6 +68,18 @@ module Decidim
|
|
|
76
68
|
allowed_to?(action, subject, extra_context, chain, user, :admin)
|
|
77
69
|
end
|
|
78
70
|
|
|
71
|
+
protected
|
|
72
|
+
|
|
73
|
+
def enforce_permission_to(action, subject, extra_context = {})
|
|
74
|
+
if Rails.env.development?
|
|
75
|
+
Rails.logger.debug "==========="
|
|
76
|
+
Rails.logger.debug [permission_scope, action, subject, permission_class_chain].map(&:inspect).join("\n")
|
|
77
|
+
Rails.logger.debug "==========="
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
raise Decidim::ActionForbidden unless allowed_to?(action, subject, extra_context)
|
|
81
|
+
end
|
|
82
|
+
|
|
79
83
|
def permission_class_chain
|
|
80
84
|
raise "Please, make this method return an array of permission classes"
|
|
81
85
|
end
|
|
@@ -83,6 +87,14 @@ module Decidim
|
|
|
83
87
|
def permission_scope
|
|
84
88
|
raise "Please, make this method return a symbol"
|
|
85
89
|
end
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
def store_share_token
|
|
94
|
+
session[:share_token] = params[:share_token] if params.has_key?(:share_token)
|
|
95
|
+
|
|
96
|
+
session[:share_token].presence
|
|
97
|
+
end
|
|
86
98
|
end
|
|
87
99
|
end
|
|
88
100
|
end
|