decidim-core 0.31.4 → 0.31.6
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/amendable/amend_button_card/show.erb +2 -2
- data/app/cells/decidim/author_cell.rb +0 -4
- data/app/cells/decidim/content_blocks/cta_settings_form/show.erb +1 -1
- data/app/cells/decidim/content_blocks/hero_settings_form/show.erb +2 -2
- data/app/cells/decidim/content_blocks/highlighted_content_banner_cell.rb +1 -1
- data/app/cells/decidim/content_blocks/highlighted_content_banner_settings_form/show.erb +1 -1
- data/app/cells/decidim/content_blocks/highlighted_participatory_spaces_cell.rb +1 -1
- data/app/cells/decidim/content_blocks/html_cell.rb +1 -1
- data/app/cells/decidim/content_blocks/participatory_space_hero_settings_form/show.erb +1 -1
- data/app/cells/decidim/content_blocks/static_page/section_cell.rb +1 -1
- data/app/cells/decidim/content_blocks/static_page/section_settings_form/show.erb +3 -1
- data/app/cells/decidim/content_blocks/static_page/summary_cell.rb +1 -1
- data/app/cells/decidim/content_blocks/static_page/summary_settings_form/show.erb +3 -1
- data/app/cells/decidim/content_blocks/static_page/two_pane_section_cell.rb +2 -2
- data/app/cells/decidim/content_blocks/static_page/two_pane_section_settings_form/show.erb +4 -2
- data/app/cells/decidim/data_consent/category.erb +5 -5
- data/app/cells/decidim/resource_types_filter/show.erb +2 -2
- data/app/cells/decidim/upload_modal_cell.rb +5 -0
- data/app/commands/decidim/destroy_account.rb +12 -1
- data/app/commands/decidim/multiple_attachments_methods.rb +28 -27
- data/app/controllers/concerns/decidim/devise_controllers.rb +10 -0
- data/app/controllers/decidim/download_your_data_controller.rb +1 -1
- data/app/controllers/decidim/notifications_subscriptions_controller.rb +8 -0
- data/app/controllers/decidim/private_downloads_controller.rb +29 -0
- data/app/jobs/decidim/process_inactive_participant_job.rb +0 -7
- data/app/mailers/decidim/delete_user_mailer.rb +14 -0
- data/app/mailers/decidim/participants_account_mailer.rb +0 -16
- data/app/models/decidim/attachment.rb +20 -2
- data/app/models/decidim/authorization.rb +7 -0
- data/app/models/decidim/moderation.rb +1 -1
- data/app/models/decidim/participatory_space_private_user.rb +1 -1
- data/app/models/decidim/private_download.rb +61 -0
- data/app/models/decidim/private_export.rb +6 -0
- data/app/models/decidim/user_base_entity.rb +17 -2
- data/app/models/decidim/user_moderation.rb +1 -1
- data/app/packs/src/decidim/controllers/form_validator/form_validator.js +6 -6
- data/app/packs/src/decidim/controllers/form_validator/form_validator.test.js +23 -1
- data/app/packs/src/decidim/controllers/mention/controller.js +296 -140
- data/app/packs/src/decidim/controllers/mention/input_mentions.test.js +120 -457
- data/app/packs/src/decidim/controllers/multiple_mentions/controller.js +68 -32
- data/app/packs/src/decidim/controllers/multiple_mentions/input_multiple_mentions.test.js +30 -23
- data/app/packs/src/decidim/direct_uploads/upload_field.js +4 -4
- data/app/packs/src/decidim/direct_uploads/upload_modal.js +11 -7
- data/app/packs/src/decidim/geocoding/reverse_geocoding.js +15 -5
- data/app/packs/src/decidim/geocoding/reverse_geocoding.test.js +197 -0
- data/app/packs/src/decidim/index.js +4 -3
- data/app/packs/src/decidim/sw/push-permissions.js +48 -13
- data/app/packs/src/decidim/sw/sw.js +1 -1
- data/app/packs/src/decidim/utilities/text.js +6 -6
- data/app/packs/stylesheets/decidim/_conversations.scss +14 -0
- data/app/packs/stylesheets/decidim/_editor_suggestions.scss +49 -0
- data/app/packs/stylesheets/decidim/_floating_help.scss +1 -1
- data/app/packs/stylesheets/decidim/_tom_select.scss +23 -0
- data/app/packs/stylesheets/decidim/application.scss +2 -0
- data/app/packs/stylesheets/decidim/editor.scss +2 -33
- data/app/packs/stylesheets/decidim/geocoding_addons.scss +10 -2
- data/app/presenters/decidim/menu_item_presenter.rb +9 -3
- data/app/presenters/decidim/stats_presenter.rb +1 -1
- data/app/services/decidim/notifications_subscriptions_persistor.rb +6 -0
- data/app/services/decidim/push_subscription_endpoint_validator.rb +34 -0
- data/app/services/decidim/send_push_notification.rb +5 -1
- data/app/uploaders/decidim/image_uploader.rb +1 -1
- data/app/views/decidim/delete_user_mailer/delete.html.erb +6 -0
- data/app/views/decidim/gamification/badges/index.html.erb +1 -1
- data/app/views/decidim/homepage/show.html.erb +1 -1
- data/app/views/decidim/last_activities/index.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/_error_modal.html.erb +11 -19
- data/app/views/decidim/messaging/conversations/error.js.erb +12 -7
- data/app/views/decidim/newsletters/unsubscribe.html.erb +1 -1
- data/app/views/decidim/notifications_settings/show.html.erb +5 -5
- data/app/views/decidim/offline/show.html.erb +1 -1
- data/app/views/decidim/pages/index.html.erb +1 -1
- data/app/views/decidim/profiles/show.html.erb +1 -1
- data/app/views/decidim/shared/_resource_actions.html.erb +4 -4
- data/app/views/decidim/user_activities/index.html.erb +1 -1
- data/app/views/layouts/decidim/_wrapper.html.erb +2 -2
- data/app/views/layouts/decidim/header/_menu_breadcrumb_mobile_tablet.html.erb +1 -1
- data/app/views/layouts/decidim/shared/_layout_center.html.erb +1 -1
- data/app/views/layouts/decidim/shared/_layout_item.html.erb +1 -1
- data/app/views/layouts/decidim/shared/_layout_two_col.html.erb +1 -1
- data/config/locales/ar.yml +0 -5
- data/config/locales/bg.yml +0 -6
- data/config/locales/ca-IT.yml +10 -10
- data/config/locales/ca.yml +10 -10
- data/config/locales/cs.yml +4 -13
- data/config/locales/de.yml +5 -17
- data/config/locales/el.yml +0 -4
- data/config/locales/en.yml +9 -9
- data/config/locales/es-MX.yml +9 -9
- data/config/locales/es-PY.yml +9 -9
- data/config/locales/es.yml +9 -9
- data/config/locales/eu.yml +49 -49
- data/config/locales/fi-plain.yml +9 -9
- data/config/locales/fi.yml +11 -11
- data/config/locales/fr-CA.yml +10 -9
- data/config/locales/fr.yml +10 -9
- data/config/locales/gl.yml +0 -3
- data/config/locales/hu.yml +0 -5
- data/config/locales/id-ID.yml +0 -3
- data/config/locales/it.yml +11 -3
- data/config/locales/ja.yml +24 -21
- data/config/locales/lb.yml +0 -5
- data/config/locales/lt.yml +0 -5
- data/config/locales/lv.yml +0 -3
- data/config/locales/nl.yml +0 -5
- data/config/locales/no.yml +0 -5
- data/config/locales/pl.yml +2 -8
- data/config/locales/pt-BR.yml +3 -16
- data/config/locales/pt.yml +0 -5
- data/config/locales/ro-RO.yml +1 -14
- data/config/locales/sk.yml +1408 -4
- data/config/locales/sv.yml +3 -11
- data/config/locales/tr-TR.yml +0 -6
- data/config/locales/zh-CN.yml +0 -5
- data/config/locales/zh-TW.yml +0 -5
- data/config/routes.rb +1 -0
- data/lib/decidim/api/functions/user_entity_list.rb +2 -0
- data/lib/decidim/attachment_attributes.rb +58 -9
- data/lib/decidim/command.rb +1 -1
- data/lib/decidim/content_renderers/base_renderer.rb +112 -0
- data/lib/decidim/content_renderers/blob_renderer.rb +4 -7
- data/lib/decidim/content_renderers/mention_resource_renderer.rb +10 -6
- data/lib/decidim/content_renderers/resource_renderer.rb +16 -7
- data/lib/decidim/content_renderers/user_renderer.rb +11 -9
- data/lib/decidim/core/content_blocks/registry_manager.rb +4 -4
- data/lib/decidim/core/engine.rb +8 -0
- data/lib/decidim/core/test/factories.rb +3 -0
- data/lib/decidim/core/test/shared_examples/admin_resource_gallery_examples.rb +10 -10
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +6 -6
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/map/autocomplete.rb +4 -3
- data/lib/decidim/searchable.rb +5 -0
- data/lib/decidim/view_model.rb +1 -1
- data/lib/tasks/decidim_mailers_tasks.rake +31 -9
- metadata +14 -10
- data/app/commands/decidim/gallery_methods.rb +0 -107
- data/app/packs/src/decidim/vendor/tribute.js +0 -1890
- data/app/packs/stylesheets/decidim/_tribute.scss +0 -36
- data/app/views/decidim/participants_account_mailer/removal_notification.html.erb +0 -11
data/lib/decidim/core/version.rb
CHANGED
|
@@ -37,19 +37,20 @@ module Decidim
|
|
|
37
37
|
template.snippets.add(:decidim_geocoding_scripts, template.append_javascript_pack_tag("decidim_geocoding"))
|
|
38
38
|
template.snippets.add(:decidim_geocoding_styles, template.append_stylesheet_pack_tag("decidim_geocoding"))
|
|
39
39
|
|
|
40
|
-
template.content_tag(:div, class: "geocoding
|
|
40
|
+
template.content_tag(:div, class: "geocoding") do
|
|
41
41
|
template.text_field(
|
|
42
42
|
object_name,
|
|
43
43
|
method,
|
|
44
44
|
options.merge("data-decidim-geocoding" => view_options.to_json)
|
|
45
45
|
) +
|
|
46
|
-
template.content_tag(:div, class: "input-group-button
|
|
47
|
-
template.content_tag(:button, class: "button button__sm md:button__sm button__text-secondary", type: "button", data: {
|
|
46
|
+
template.content_tag(:div, class: "input-group-button geocoding__locate") do
|
|
47
|
+
template.content_tag(:button, class: "button button__sm md:button__sm button__text-secondary geocoding__button", type: "button", data: {
|
|
48
48
|
input: "#{object_name}_#{method}",
|
|
49
49
|
latitude: "#{object_name}_latitude",
|
|
50
50
|
longitude: "#{object_name}_longitude",
|
|
51
51
|
error_no_location: I18n.t("errors.no_device_location", scope: "decidim.proposals.forms"),
|
|
52
52
|
error_unsupported: I18n.t("errors.device_not_supported", scope: "decidim.proposals.forms"),
|
|
53
|
+
locating_text: I18n.t("locating", scope: "decidim.proposals.forms"),
|
|
53
54
|
url: Decidim::Core::Engine.routes.url_helpers.locate_path
|
|
54
55
|
}) do
|
|
55
56
|
icon("map-pin-line", role: "img", "aria-hidden": true) + " #{I18n.t("use_my_location", scope: "decidim.proposals.forms")}"
|
data/lib/decidim/searchable.rb
CHANGED
|
@@ -117,6 +117,11 @@ module Decidim
|
|
|
117
117
|
searchables_in_org.find_each do |sr|
|
|
118
118
|
next if sr.blank?
|
|
119
119
|
|
|
120
|
+
unless sr.locale.in?(org.available_locales)
|
|
121
|
+
sr.destroy
|
|
122
|
+
next
|
|
123
|
+
end
|
|
124
|
+
|
|
120
125
|
sr.update(contents_to_searchable_resource_attributes(fields, sr.locale))
|
|
121
126
|
end
|
|
122
127
|
end
|
data/lib/decidim/view_model.rb
CHANGED
|
@@ -4,20 +4,42 @@ namespace :decidim do
|
|
|
4
4
|
namespace :mailers do
|
|
5
5
|
desc "Sends the notification digest email with the daily report"
|
|
6
6
|
task notifications_digest_daily: :environment do
|
|
7
|
-
|
|
7
|
+
time = Time.now.utc
|
|
8
|
+
target_users = Decidim::User.where(notifications_sending_frequency: :daily)
|
|
9
|
+
|
|
10
|
+
target_users.find_in_batches do |batch|
|
|
11
|
+
notification_users =
|
|
12
|
+
Decidim::Notification
|
|
13
|
+
.daily(time)
|
|
14
|
+
.where(decidim_user_id: batch.pluck(:id))
|
|
15
|
+
.select(:decidim_user_id)
|
|
16
|
+
.distinct
|
|
17
|
+
.pluck(:decidim_user_id)
|
|
18
|
+
|
|
19
|
+
notification_users.each do |user_id|
|
|
20
|
+
Decidim::EmailNotificationsDigestGeneratorJob.perform_later(user_id, :daily, time:)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
8
23
|
end
|
|
9
24
|
|
|
10
25
|
desc "Sends the notification digest email with the weekly report"
|
|
11
26
|
task notifications_digest_weekly: :environment do
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
time = Time.now.utc
|
|
28
|
+
target_users = Decidim::User.where(notifications_sending_frequency: :weekly)
|
|
29
|
+
|
|
30
|
+
target_users.find_in_batches do |batch|
|
|
31
|
+
notification_users =
|
|
32
|
+
Decidim::Notification
|
|
33
|
+
.weekly(time)
|
|
34
|
+
.where(decidim_user_id: batch.pluck(:id))
|
|
35
|
+
.select(:decidim_user_id)
|
|
36
|
+
.distinct
|
|
37
|
+
.pluck(:decidim_user_id)
|
|
15
38
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Decidim::EmailNotificationsDigestGeneratorJob.perform_later(user.id, frequency, time:)
|
|
39
|
+
notification_users.each do |user_id|
|
|
40
|
+
Decidim::EmailNotificationsDigestGeneratorJob.perform_later(user_id, :weekly, time:)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
21
43
|
end
|
|
22
44
|
end
|
|
23
45
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: decidim-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.31.
|
|
4
|
+
version: 0.31.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Josep Jaume Rey Peroy
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2026-
|
|
13
|
+
date: 2026-07-06 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: concurrent-ruby
|
|
@@ -828,28 +828,28 @@ dependencies:
|
|
|
828
828
|
requirements:
|
|
829
829
|
- - '='
|
|
830
830
|
- !ruby/object:Gem::Version
|
|
831
|
-
version: 0.31.
|
|
831
|
+
version: 0.31.6
|
|
832
832
|
type: :development
|
|
833
833
|
prerelease: false
|
|
834
834
|
version_requirements: !ruby/object:Gem::Requirement
|
|
835
835
|
requirements:
|
|
836
836
|
- - '='
|
|
837
837
|
- !ruby/object:Gem::Version
|
|
838
|
-
version: 0.31.
|
|
838
|
+
version: 0.31.6
|
|
839
839
|
- !ruby/object:Gem::Dependency
|
|
840
840
|
name: decidim-dev
|
|
841
841
|
requirement: !ruby/object:Gem::Requirement
|
|
842
842
|
requirements:
|
|
843
843
|
- - '='
|
|
844
844
|
- !ruby/object:Gem::Version
|
|
845
|
-
version: 0.31.
|
|
845
|
+
version: 0.31.6
|
|
846
846
|
type: :development
|
|
847
847
|
prerelease: false
|
|
848
848
|
version_requirements: !ruby/object:Gem::Requirement
|
|
849
849
|
requirements:
|
|
850
850
|
- - '='
|
|
851
851
|
- !ruby/object:Gem::Version
|
|
852
|
-
version: 0.31.
|
|
852
|
+
version: 0.31.6
|
|
853
853
|
description: Adds core features so other engines can hook into the framework.
|
|
854
854
|
email:
|
|
855
855
|
- josepjaume@gmail.com
|
|
@@ -1195,7 +1195,6 @@ files:
|
|
|
1195
1195
|
- app/commands/decidim/delete_follow.rb
|
|
1196
1196
|
- app/commands/decidim/destroy_account.rb
|
|
1197
1197
|
- app/commands/decidim/destroy_ephemeral_user.rb
|
|
1198
|
-
- app/commands/decidim/gallery_methods.rb
|
|
1199
1198
|
- app/commands/decidim/invite_user.rb
|
|
1200
1199
|
- app/commands/decidim/invite_user_again.rb
|
|
1201
1200
|
- app/commands/decidim/like_resource.rb
|
|
@@ -1294,6 +1293,7 @@ files:
|
|
|
1294
1293
|
- app/controllers/decidim/offline_controller.rb
|
|
1295
1294
|
- app/controllers/decidim/open_data_controller.rb
|
|
1296
1295
|
- app/controllers/decidim/pages_controller.rb
|
|
1296
|
+
- app/controllers/decidim/private_downloads_controller.rb
|
|
1297
1297
|
- app/controllers/decidim/profiles_controller.rb
|
|
1298
1298
|
- app/controllers/decidim/qr_controller.rb
|
|
1299
1299
|
- app/controllers/decidim/report_users_controller.rb
|
|
@@ -1429,6 +1429,7 @@ files:
|
|
|
1429
1429
|
- app/mailers/decidim/application_mailer.rb
|
|
1430
1430
|
- app/mailers/decidim/block_user_mailer.rb
|
|
1431
1431
|
- app/mailers/decidim/decidim_devise_mailer.rb
|
|
1432
|
+
- app/mailers/decidim/delete_user_mailer.rb
|
|
1432
1433
|
- app/mailers/decidim/export_mailer.rb
|
|
1433
1434
|
- app/mailers/decidim/messaging/conversation_mailer.rb
|
|
1434
1435
|
- app/mailers/decidim/newsletter_mailer.rb
|
|
@@ -1483,6 +1484,7 @@ files:
|
|
|
1483
1484
|
- app/models/decidim/participatory_space_role_config/null_object.rb
|
|
1484
1485
|
- app/models/decidim/participatory_space_role_config/participatory_space_admin.rb
|
|
1485
1486
|
- app/models/decidim/permission_action.rb
|
|
1487
|
+
- app/models/decidim/private_download.rb
|
|
1486
1488
|
- app/models/decidim/private_export.rb
|
|
1487
1489
|
- app/models/decidim/push_notification_message.rb
|
|
1488
1490
|
- app/models/decidim/reminder.rb
|
|
@@ -1710,6 +1712,7 @@ files:
|
|
|
1710
1712
|
- app/packs/src/decidim/geocoding/provider/here.js
|
|
1711
1713
|
- app/packs/src/decidim/geocoding/provider/photon.js
|
|
1712
1714
|
- app/packs/src/decidim/geocoding/reverse_geocoding.js
|
|
1715
|
+
- app/packs/src/decidim/geocoding/reverse_geocoding.test.js
|
|
1713
1716
|
- app/packs/src/decidim/identity_selector_dialog.js
|
|
1714
1717
|
- app/packs/src/decidim/index.js
|
|
1715
1718
|
- app/packs/src/decidim/map.js
|
|
@@ -1752,7 +1755,6 @@ files:
|
|
|
1752
1755
|
- app/packs/src/decidim/utilities/dom.js
|
|
1753
1756
|
- app/packs/src/decidim/utilities/text.js
|
|
1754
1757
|
- app/packs/src/decidim/vendor/jquery-tmpl.js
|
|
1755
|
-
- app/packs/src/decidim/vendor/tribute.js
|
|
1756
1758
|
- app/packs/stylesheets/decidim/_accordion.scss
|
|
1757
1759
|
- app/packs/stylesheets/decidim/_actions.scss
|
|
1758
1760
|
- app/packs/stylesheets/decidim/_activity.scss
|
|
@@ -1767,6 +1769,7 @@ files:
|
|
|
1767
1769
|
- app/packs/stylesheets/decidim/_datepicker.scss
|
|
1768
1770
|
- app/packs/stylesheets/decidim/_documents.scss
|
|
1769
1771
|
- app/packs/stylesheets/decidim/_dropdown.scss
|
|
1772
|
+
- app/packs/stylesheets/decidim/_editor_suggestions.scss
|
|
1770
1773
|
- app/packs/stylesheets/decidim/_emoji.scss
|
|
1771
1774
|
- app/packs/stylesheets/decidim/_filters.scss
|
|
1772
1775
|
- app/packs/stylesheets/decidim/_flash.scss
|
|
@@ -1807,9 +1810,9 @@ files:
|
|
|
1807
1810
|
- app/packs/stylesheets/decidim/_tabs_x.scss
|
|
1808
1811
|
- app/packs/stylesheets/decidim/_tags.scss
|
|
1809
1812
|
- app/packs/stylesheets/decidim/_toggle_switch.scss
|
|
1813
|
+
- app/packs/stylesheets/decidim/_tom_select.scss
|
|
1810
1814
|
- app/packs/stylesheets/decidim/_tooltip.scss
|
|
1811
1815
|
- app/packs/stylesheets/decidim/_tos.scss
|
|
1812
|
-
- app/packs/stylesheets/decidim/_tribute.scss
|
|
1813
1816
|
- app/packs/stylesheets/decidim/_typography.scss
|
|
1814
1817
|
- app/packs/stylesheets/decidim/_versions.scss
|
|
1815
1818
|
- app/packs/stylesheets/decidim/_vertical_tabs.scss
|
|
@@ -1943,6 +1946,7 @@ files:
|
|
|
1943
1946
|
- app/services/decidim/onboarding_manager.rb
|
|
1944
1947
|
- app/services/decidim/open_data_exporter.rb
|
|
1945
1948
|
- app/services/decidim/push_notification_message_sender.rb
|
|
1949
|
+
- app/services/decidim/push_subscription_endpoint_validator.rb
|
|
1946
1950
|
- app/services/decidim/resource_search.rb
|
|
1947
1951
|
- app/services/decidim/send_push_notification.rb
|
|
1948
1952
|
- app/services/decidim/settings_change.rb
|
|
@@ -1998,6 +2002,7 @@ files:
|
|
|
1998
2002
|
- app/views/decidim/application/_radio_accordion.html.erb
|
|
1999
2003
|
- app/views/decidim/authorization_modals/show.html.erb
|
|
2000
2004
|
- app/views/decidim/block_user_mailer/notify.html.erb
|
|
2005
|
+
- app/views/decidim/delete_user_mailer/delete.html.erb
|
|
2001
2006
|
- app/views/decidim/devise/confirmations/new.html.erb
|
|
2002
2007
|
- app/views/decidim/devise/invitations/edit.html.erb
|
|
2003
2008
|
- app/views/decidim/devise/omniauth_registrations/new.html.erb
|
|
@@ -2065,7 +2070,6 @@ files:
|
|
|
2065
2070
|
- app/views/decidim/pages/index.html.erb
|
|
2066
2071
|
- app/views/decidim/pages/show.html.erb
|
|
2067
2072
|
- app/views/decidim/participants_account_mailer/inactivity_notification.html.erb
|
|
2068
|
-
- app/views/decidim/participants_account_mailer/removal_notification.html.erb
|
|
2069
2073
|
- app/views/decidim/participatory_space_private_users/_participatory_space_private_user.html.erb
|
|
2070
2074
|
- app/views/decidim/profiles/show.html.erb
|
|
2071
2075
|
- app/views/decidim/qr/show.html.erb
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Decidim
|
|
4
|
-
# A module with all the gallery common methods
|
|
5
|
-
# Allows to create several image attachments at once
|
|
6
|
-
module GalleryMethods
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
def build_gallery(attached_to = nil)
|
|
10
|
-
@gallery = []
|
|
11
|
-
@form.add_photos.compact_blank.each do |photo|
|
|
12
|
-
if photo.is_a?(Hash) && photo.has_key?(:id)
|
|
13
|
-
update_attachment_title_for(photo)
|
|
14
|
-
next
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
@gallery << Attachment.new(
|
|
18
|
-
title: photos_title(photo),
|
|
19
|
-
attached_to: attached_to || gallery_attached_to,
|
|
20
|
-
file: photos_signed_id(photo), # Define attached_to before this
|
|
21
|
-
content_type: photos_content_type(photo)
|
|
22
|
-
)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def update_attachment_title_for(photo)
|
|
27
|
-
Decidim::Attachment.find(photo[:id]).update(title: photos_title(photo))
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def image?(signed_id)
|
|
31
|
-
blob(signed_id).content_type.start_with? "image"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def gallery_invalid?
|
|
35
|
-
@gallery.each do |photo|
|
|
36
|
-
if photo.invalid? && photo.errors.has_key?(:file)
|
|
37
|
-
@form.errors.add(:add_photos, photo.errors[:file])
|
|
38
|
-
return true
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
false
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def create_gallery(first_weight: 0)
|
|
45
|
-
weight = first_weight
|
|
46
|
-
# Add the weights first to the old photos
|
|
47
|
-
@form.photos.each do |photo|
|
|
48
|
-
photo.update!(weight:)
|
|
49
|
-
weight += 1
|
|
50
|
-
end
|
|
51
|
-
@gallery.map! do |photo|
|
|
52
|
-
photo.weight = weight
|
|
53
|
-
photo.attached_to = gallery_attached_to
|
|
54
|
-
photo.save!
|
|
55
|
-
weight += 1
|
|
56
|
-
@form.photos << photo
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def photo_cleanup!
|
|
61
|
-
gallery_attached_to.photos.each do |photo|
|
|
62
|
-
next unless @form.photos.map(&:id).exclude?(photo.id)
|
|
63
|
-
|
|
64
|
-
photo.destroy! if (@form.respond_to?(:documents) && @form.documents.map(&:id).exclude?(photo.id)) || !@form.respond_to?(:documents)
|
|
65
|
-
end
|
|
66
|
-
# manually reset cached photos
|
|
67
|
-
gallery_attached_to.reload
|
|
68
|
-
gallery_attached_to.instance_variable_set(:@photos, nil)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# maybe a custom settings options would be nice
|
|
72
|
-
def gallery_allowed?
|
|
73
|
-
true
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def process_gallery?
|
|
77
|
-
gallery_allowed? && @form.add_photos.any?
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def gallery_attached_to
|
|
81
|
-
return @attached_to if @attached_to.present?
|
|
82
|
-
return form.current_organization if form.respond_to?(:current_organization)
|
|
83
|
-
|
|
84
|
-
form.current_component.organization if form.respond_to?(:current_component)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def photos_signed_id(photo)
|
|
88
|
-
return photo[:file] if photo.is_a?(Hash)
|
|
89
|
-
|
|
90
|
-
photo
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def photos_title(photo)
|
|
94
|
-
return { I18n.locale => photo[:title] } if photo.is_a?(Hash) && photo.has_key?(:title)
|
|
95
|
-
|
|
96
|
-
{ I18n.locale => "" }
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def photos_content_type(photo)
|
|
100
|
-
blob(photos_signed_id(photo)).content_type
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def blob(signed_id)
|
|
104
|
-
ActiveStorage::Blob.find_signed(signed_id)
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|