decidim-core 0.27.5 → 0.27.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/activity_cell.rb +2 -2
- data/app/cells/decidim/card_cell.rb +2 -2
- data/app/cells/decidim/card_m/top.erb +1 -1
- data/app/cells/decidim/card_m_cell.rb +1 -1
- data/app/cells/decidim/follow_button_cell.rb +1 -1
- data/app/cells/decidim/notification/moderated.erb +24 -0
- data/app/cells/decidim/notification_cell.rb +5 -1
- data/app/cells/decidim/scopes_picker/scope_picker_values.erb +1 -1
- data/app/cells/decidim/tags_cell.rb +3 -1
- data/app/cells/decidim/user_profile_cell.rb +1 -1
- data/app/commands/decidim/create_omniauth_registration.rb +2 -4
- data/app/commands/decidim/messaging/reply_to_conversation.rb +3 -0
- data/app/commands/decidim/messaging/start_conversation.rb +3 -0
- data/app/controllers/concerns/decidim/devise_authentication_methods.rb +36 -0
- data/app/controllers/concerns/decidim/force_authentication.rb +1 -1
- data/app/controllers/concerns/decidim/paginable.rb +1 -1
- data/app/controllers/concerns/decidim/use_organization_time_zone.rb +1 -1
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -22
- data/app/controllers/decidim/devise/sessions_controller.rb +1 -24
- data/app/controllers/decidim/links_controller.rb +13 -1
- data/app/controllers/decidim/widgets_controller.rb +6 -0
- data/app/events/decidim/welcome_notification_event.rb +6 -9
- data/app/helpers/decidim/cells_paginate_helper.rb +1 -1
- data/app/helpers/decidim/check_boxes_tree_helper.rb +4 -4
- data/app/helpers/decidim/newsletters_helper.rb +83 -16
- data/app/helpers/decidim/resource_helper.rb +1 -1
- data/app/helpers/decidim/sanitize_helper.rb +9 -0
- data/app/helpers/decidim/user_profile_helper.rb +7 -2
- data/app/mailers/decidim/application_mailer.rb +40 -6
- data/app/mailers/decidim/messaging/conversation_mailer.rb +3 -72
- data/app/models/decidim/push_notification_message.rb +39 -0
- data/app/packs/images/decidim/.keep +0 -0
- data/app/packs/src/decidim/input_hashtags.js +1 -1
- data/app/packs/src/decidim/input_mentions.js +1 -1
- data/app/packs/src/decidim/input_multiple_mentions.js +1 -1
- data/app/packs/src/decidim/vizzs/index.js +1 -1
- data/app/packs/stylesheets/decidim/plugins/leaflet.scss +118 -114
- data/app/presenters/decidim/admin_log/oauth_application_resource_presenter.rb +1 -1
- data/app/presenters/decidim/admin_log/organization_presenter.rb +1 -1
- data/app/presenters/decidim/log/resource_presenter.rb +7 -1
- data/app/presenters/decidim/notification_to_mailer_presenter.rb +9 -0
- data/app/services/decidim/events_manager.rb +6 -0
- data/app/services/decidim/log/diff_changeset_calculator.rb +1 -1
- data/app/services/decidim/push_notification_message_sender.rb +36 -0
- data/app/services/decidim/send_push_notification.rb +22 -8
- data/app/views/decidim/devise/registrations/new.html.erb +2 -2
- data/app/views/decidim/links/new.html.erb +2 -0
- data/app/views/decidim/notifications_digest_mailer/_email_content.html.erb +7 -0
- data/app/views/decidim/shared/_address_details.html.erb +2 -2
- data/app/views/layouts/decidim/_js_configuration.html.erb +1 -0
- data/config/locales/ar.yml +4 -3
- data/config/locales/bg.yml +484 -1
- data/config/locales/ca.yml +23 -22
- data/config/locales/cs.yml +0 -1
- data/config/locales/de.yml +28 -27
- data/config/locales/el.yml +5 -4
- data/config/locales/en.yml +1 -0
- data/config/locales/eo.yml +3 -0
- data/config/locales/es-MX.yml +6 -5
- data/config/locales/es-PY.yml +6 -5
- data/config/locales/es.yml +25 -24
- data/config/locales/eu.yml +12 -2
- data/config/locales/fi-plain.yml +1 -0
- data/config/locales/fi.yml +4 -3
- data/config/locales/fr-CA.yml +5 -4
- data/config/locales/fr.yml +3 -2
- data/config/locales/ga-IE.yml +5 -0
- data/config/locales/gl.yml +3 -0
- data/config/locales/he-IL.yml +1 -0
- data/config/locales/hu.yml +41 -9
- data/config/locales/it.yml +5 -4
- data/config/locales/ja.yml +5 -3
- data/config/locales/lb.yml +5 -4
- data/config/locales/lt.yml +4 -4
- data/config/locales/lv.yml +4 -1
- data/config/locales/nl.yml +4 -1
- data/config/locales/no.yml +5 -4
- data/config/locales/pl.yml +168 -1
- data/config/locales/pt-BR.yml +113 -22
- data/config/locales/pt.yml +5 -4
- data/config/locales/ro-RO.yml +1 -3
- data/config/locales/ru.yml +13 -0
- data/config/locales/sk.yml +6 -1
- data/config/locales/sl.yml +5 -0
- data/config/locales/sv.yml +26 -3
- data/config/locales/tr-TR.yml +3 -3
- data/config/locales/uk.yml +15 -0
- data/config/locales/zh-CN.yml +0 -4
- data/config/locales/zh-TW.yml +4 -4
- data/decidim-core.gemspec +78 -0
- data/lib/decidim/acts_as_tree.rb +14 -1
- data/lib/decidim/asset_router/storage.rb +4 -0
- data/lib/decidim/attribute_encryptor.rb +6 -4
- data/lib/decidim/core/engine.rb +7 -3
- data/lib/decidim/core/test/factories.rb +314 -95
- data/lib/decidim/core/test/shared_examples/amendable/amendment_created_event_examples.rb +6 -26
- data/lib/decidim/core/test/shared_examples/amendable/amendment_promoted_event_examples.rb +8 -26
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +32 -0
- data/lib/decidim/core/test/shared_examples/embed_resource_examples.rb +187 -11
- data/lib/decidim/core/test/shared_examples/has_attachment_collections.rb +8 -6
- data/lib/decidim/core/test/shared_examples/has_attachments.rb +4 -4
- data/lib/decidim/core/test/shared_examples/has_category.rb +27 -0
- data/lib/decidim/core/test/shared_examples/has_reference.rb +1 -1
- data/lib/decidim/core/test/shared_examples/has_space_in_mcell_examples.rb +1 -2
- data/lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb +6 -3
- data/lib/decidim/core/test/shared_examples/resource_locator_presenter_examples.rb +134 -0
- data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/simple_event.rb +50 -2
- data/lib/decidim/core/test.rb +1 -0
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/core.rb +1 -0
- data/lib/decidim/engine_router.rb +17 -4
- data/lib/decidim/events/base_event.rb +9 -2
- data/lib/decidim/events/simple_event.rb +3 -17
- data/lib/decidim/form_builder.rb +13 -1
- data/lib/decidim/has_category.rb +1 -1
- data/lib/decidim/has_conversations.rb +91 -0
- data/lib/decidim/organization_settings.rb +10 -2
- data/lib/decidim/participable.rb +17 -0
- data/lib/decidim/view_model.rb +1 -0
- data/lib/decidim/webpacker/webpack/.modernizrrc +9 -0
- data/lib/premailer/adapter/decidim.rb +5 -4
- data/lib/tasks/decidim_reminders_tasks.rake +1 -0
- data/lib/tasks/upgrade/decidim_fix_categorization.rake +15 -0
- metadata +29 -27
- data/config/environment.rb +0 -3
@@ -10,6 +10,8 @@ module Decidim
|
|
10
10
|
# overwrite `BasePresenter#resource_presenter` to return your custom resource presenter.
|
11
11
|
# The only requirement for custom renderers is that they should respond to `present`.
|
12
12
|
class ResourcePresenter
|
13
|
+
include Decidim::SanitizeHelper
|
14
|
+
|
13
15
|
# Public: Initializes the presenter.
|
14
16
|
#
|
15
17
|
# resource - An instance of a model that can be located by
|
@@ -65,7 +67,11 @@ module Decidim
|
|
65
67
|
#
|
66
68
|
# Returns an HTML-safe String.
|
67
69
|
def present_resource_name
|
68
|
-
|
70
|
+
if resource.present? && resource.respond_to?(:presenter) && resource.presenter.respond_to?(:title)
|
71
|
+
resource.presenter.title(html_escape: true)
|
72
|
+
else
|
73
|
+
decidim_escape_translated(extra["title"]).html_safe
|
74
|
+
end
|
69
75
|
end
|
70
76
|
end
|
71
77
|
end
|
@@ -7,11 +7,16 @@ module Decidim
|
|
7
7
|
class NotificationToMailerPresenter < SimpleDelegator
|
8
8
|
include Decidim::TranslatableAttributes
|
9
9
|
|
10
|
+
EXTENDED_NOTIFICATIONS_CLASSES = [
|
11
|
+
"Decidim::Comments::CommentCreatedEvent"
|
12
|
+
].freeze
|
13
|
+
|
10
14
|
delegate :url_helpers, to: "Decidim::Core::Engine.routes"
|
11
15
|
delegate :resource_title, to: :event
|
12
16
|
delegate :resource_url, to: :event
|
13
17
|
delegate :email_intro, to: :event
|
14
18
|
delegate :resource_path, to: :event
|
19
|
+
delegate :safe_resource_text, to: :event
|
15
20
|
|
16
21
|
def date_time
|
17
22
|
if frequency == :daily
|
@@ -21,6 +26,10 @@ module Decidim
|
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
29
|
+
def show_extended_information?
|
30
|
+
EXTENDED_NOTIFICATIONS_CLASSES.include?(event_class)
|
31
|
+
end
|
32
|
+
|
24
33
|
private
|
25
34
|
|
26
35
|
def event
|
@@ -46,5 +46,11 @@ module Decidim
|
|
46
46
|
def self.subscribe(event, &block)
|
47
47
|
ActiveSupport::Notifications.subscribe(event, &block)
|
48
48
|
end
|
49
|
+
|
50
|
+
def self.subscribe_events!
|
51
|
+
subscribe(/^decidim\.events\./) do |event_name, data|
|
52
|
+
EventPublisherJob.perform_later(event_name, data)
|
53
|
+
end
|
54
|
+
end
|
49
55
|
end
|
50
56
|
end
|
@@ -86,7 +86,7 @@ module Decidim
|
|
86
86
|
locales.flat_map do |locale|
|
87
87
|
previous_value = values.first.try(:[], locale)
|
88
88
|
new_value = values.last.try(:[], locale)
|
89
|
-
if previous_value == new_value
|
89
|
+
if previous_value == new_value || (previous_value.nil? && new_value.blank?)
|
90
90
|
nil
|
91
91
|
else
|
92
92
|
label = generate_label(attribute, locale)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
# A wrapper for preparing push notifications messages from conversations
|
5
|
+
# It respects the same contract as the Decidim::Messaging::ConversationMailer
|
6
|
+
class PushNotificationMessageSender
|
7
|
+
include HasConversations
|
8
|
+
|
9
|
+
def deliver
|
10
|
+
SendPushNotification.new.perform(@notification, title)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# rubocop:disable Metrics/ParameterLists
|
16
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
17
|
+
#
|
18
|
+
# There are some parameters thar are not used in the method, but they are needed to
|
19
|
+
# keep the same contract as the Decidim::Messaging::ConversationMailer
|
20
|
+
def send_notification(from:, to:, conversation:, action:, message: nil, third_party: nil)
|
21
|
+
@action = action
|
22
|
+
@sender = to
|
23
|
+
@third_party = third_party
|
24
|
+
|
25
|
+
@notification = PushNotificationMessage.new(recipient: to, conversation: conversation, message: message)
|
26
|
+
|
27
|
+
self
|
28
|
+
end
|
29
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
30
|
+
# rubocop:enable Metrics/ParameterLists
|
31
|
+
|
32
|
+
def title
|
33
|
+
get_subject(action: @action, sender: @sender, third_party: @third_party)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -14,14 +14,19 @@ module Decidim
|
|
14
14
|
# Send the push notification. Returns `nil` if the user didn't allowed push notifications
|
15
15
|
# or if the subscription to push notifications doesn't exist
|
16
16
|
#
|
17
|
-
#
|
18
|
-
|
17
|
+
# @param notification [Decidim::Notification, Decidim::PushNotificationMessage] the notification to be sent
|
18
|
+
# @param title [String] the title of the notification. Optional.
|
19
|
+
#
|
20
|
+
# @return [Array<Net::HTTPCreated>, nil] the result of the dispatch or nil if user or subscription are empty
|
21
|
+
def perform(notification, title = nil)
|
19
22
|
return unless Rails.application.secrets.dig(:vapid, :enabled)
|
23
|
+
raise ArgumentError, "Need to provide a title if the notification is a PushNotificationMessage" if notification.is_a?(Decidim::PushNotificationMessage) && title.nil?
|
24
|
+
|
25
|
+
user = notification.user
|
20
26
|
|
21
|
-
I18n.with_locale(
|
22
|
-
|
23
|
-
|
24
|
-
payload = build_payload(message_params, subscription)
|
27
|
+
I18n.with_locale(user.locale || user.organization.default_locale) do
|
28
|
+
user.notifications_subscriptions.values.map do |subscription|
|
29
|
+
payload = build_payload(message_params(notification, title), subscription)
|
25
30
|
# Capture webpush exceptions in order to avoid this call to be repeated by the background job runner
|
26
31
|
# Webpush::Error class is the parent class of all defined errors
|
27
32
|
begin
|
@@ -36,9 +41,18 @@ module Decidim
|
|
36
41
|
|
37
42
|
private
|
38
43
|
|
39
|
-
def
|
44
|
+
def message_params(notification, title = nil)
|
45
|
+
case notification
|
46
|
+
when Decidim::PushNotificationMessage
|
47
|
+
notification_params(notification, title)
|
48
|
+
else # when Decidim::Notification
|
49
|
+
notification_params(Decidim::PushNotificationPresenter.new(notification))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def notification_params(notification, title = nil)
|
40
54
|
{
|
41
|
-
title: notification.title,
|
55
|
+
title: title.presence || notification.title,
|
42
56
|
body: notification.body,
|
43
57
|
icon: notification.icon,
|
44
58
|
data: { url: notification.url }
|
@@ -60,7 +60,7 @@
|
|
60
60
|
|
61
61
|
<div class="card" id="card__tos">
|
62
62
|
<div class="card__content">
|
63
|
-
<
|
63
|
+
<h2><%= t(".tos_title") %></h2>
|
64
64
|
|
65
65
|
<p class="tos-text">
|
66
66
|
<%= strip_tags(translated_attribute(terms_and_conditions_page.content)) %>
|
@@ -74,7 +74,7 @@
|
|
74
74
|
|
75
75
|
<div class="card" id="card__newsletter">
|
76
76
|
<div class="card__content">
|
77
|
-
<
|
77
|
+
<h2><%= t(".newsletter_title") %></h2>
|
78
78
|
<div class="field">
|
79
79
|
<%= f.check_box :newsletter, label: t(".newsletter"), checked: @form.newsletter %>
|
80
80
|
</div>
|
@@ -8,4 +8,11 @@
|
|
8
8
|
<%= link_to decidim_sanitize(notification.resource_title, strip_tags: true), notification.resource_url %>
|
9
9
|
</p>
|
10
10
|
<% end %>
|
11
|
+
<% if notification.show_extended_information? %>
|
12
|
+
<blockquote>
|
13
|
+
<p>
|
14
|
+
<%= notification.safe_resource_text %>
|
15
|
+
</p>
|
16
|
+
</blockquote>
|
17
|
+
<% end %>
|
11
18
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<% if geolocalizable.respond_to? :location %>
|
2
|
-
<strong><%= translated_attribute
|
2
|
+
<strong><%= decidim_sanitize(translated_attribute(geolocalizable.location)) %></strong><br>
|
3
3
|
<% end %>
|
4
4
|
<span><%= geolocalizable.address %></span><br>
|
5
5
|
<% if geolocalizable.respond_to? :location_hints %>
|
6
|
-
<span><%= translated_attribute
|
6
|
+
<span><%= decidim_sanitize(translated_attribute(geolocalizable.location_hints)) %></span>
|
7
7
|
<% end %>
|
data/config/locales/ar.yml
CHANGED
@@ -91,9 +91,7 @@ ar:
|
|
91
91
|
'true': 'نعم'
|
92
92
|
carrierwave:
|
93
93
|
errors:
|
94
|
-
file_resolution_too_large: دقة الملف أكبر من المسموح به
|
95
94
|
file_size_too_large: حجم الملف أكبر من المسموح به
|
96
|
-
not_inside_organization: لم يتم إرفاق الملف بأي منظمة
|
97
95
|
date:
|
98
96
|
formats:
|
99
97
|
decidim_short: "%d/%m/%Y"
|
@@ -335,7 +333,6 @@ ar:
|
|
335
333
|
'1': إنشاء التعديل الخاص بك
|
336
334
|
'2': قارن تعديلك
|
337
335
|
'3': اكمل تعديلك
|
338
|
-
'4': انشر تعديلك
|
339
336
|
anonymous_user: مجهول
|
340
337
|
application:
|
341
338
|
collection:
|
@@ -612,6 +609,7 @@ ar:
|
|
612
609
|
ready: جاهز
|
613
610
|
show:
|
614
611
|
download_data: قم بتنزيل البيانات
|
612
|
+
download_data_description: سيتم إرسال ملف يحتوي على جميع المعلومات المرتبطة بحسابك إلى <strong>%{user_email}</strong>. سوف يحتوي هذا البريد الإلكتروني على ملف .zip وكلمة مرور لفتحه.<br/><br/>لفك الملف ، ستحتاج إلى <a href="https://www.7-zip.org/">7-Zip</a> (للويندوز) أو <a href="https://www.keka.io/">Keka</a> (لماكوس). إذا كنت تستخدم لينوكس، في معظم الأحيان سيتم تثبيته بشكل افتراضي. إذا لم يكن الأمر كذلك، يمكنك استخدام <a href="https://gitlab.gnome.org/GNOME/file-roller">ملف Roller</a> أو <a href="https://peazip.github.io">PeaZip</a>).
|
615
613
|
request_data: طلب البيانات
|
616
614
|
editor_images:
|
617
615
|
create:
|
@@ -782,6 +780,7 @@ ar:
|
|
782
780
|
notification_title: تم إضفاء الطابع الرسمي على المشارك %{name} (%{nickname}).
|
783
781
|
export_mailer:
|
784
782
|
download_your_data_export:
|
783
|
+
click_button: 'انقر فوق الرابط التالي لتحميل بياناتك.<br/>الملف سيكون متاحا حتى %{date}.<br/>ستحتاج إلى <a href="https://www.7-zip.org/">7-Zip</a> (للويندوز)، <a href="https://www.keka.io/en/">Keka</a> (لماكوس) أو <a href="https://peazip.github.io">PeaZip</a> (للينوكس) لفتحه. كلمة المرور: %{password}'
|
785
784
|
download: تحميل
|
786
785
|
export:
|
787
786
|
ready: يرجى الاطلاع على نسخة مضغوطة من التصدير.
|
@@ -834,6 +833,7 @@ ar:
|
|
834
833
|
file_help:
|
835
834
|
file:
|
836
835
|
explanation: 'إرشادات الملف:'
|
836
|
+
message_1: يجب أن تكون صورة أو وثيقة.
|
837
837
|
message_2: بالنسبة للصور، يُفضل استخدام صور بالوضع العرضي، تقوم الخدمة باقتصاص الصورة.
|
838
838
|
icon:
|
839
839
|
explanation: 'إرشادات للأيقونة:'
|
@@ -1268,6 +1268,7 @@ ar:
|
|
1268
1268
|
error: كانت هناك مشكلة في قبول الشروط والأحكام.
|
1269
1269
|
success: عظيم! لقد قبلت الشروط والأحكام.
|
1270
1270
|
form:
|
1271
|
+
agreement: أوافق على هذه الشروط
|
1271
1272
|
legend: توافق على شروط وأحكام الاستخدام
|
1272
1273
|
refuse:
|
1273
1274
|
modal_body: إذا قمت بالرفض، لن تتمكن من استخدام المنصة، يمكنك <a href="%{download_your_data_path}">تنزيل بياناتك</a> و/أو <a href="%{delete_path}">حذف حسابك</a>.
|