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.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/activity_cell.rb +2 -2
  3. data/app/cells/decidim/card_cell.rb +2 -2
  4. data/app/cells/decidim/card_m/top.erb +1 -1
  5. data/app/cells/decidim/card_m_cell.rb +1 -1
  6. data/app/cells/decidim/follow_button_cell.rb +1 -1
  7. data/app/cells/decidim/notification/moderated.erb +24 -0
  8. data/app/cells/decidim/notification_cell.rb +5 -1
  9. data/app/cells/decidim/scopes_picker/scope_picker_values.erb +1 -1
  10. data/app/cells/decidim/tags_cell.rb +3 -1
  11. data/app/cells/decidim/user_profile_cell.rb +1 -1
  12. data/app/commands/decidim/create_omniauth_registration.rb +2 -4
  13. data/app/commands/decidim/messaging/reply_to_conversation.rb +3 -0
  14. data/app/commands/decidim/messaging/start_conversation.rb +3 -0
  15. data/app/controllers/concerns/decidim/devise_authentication_methods.rb +36 -0
  16. data/app/controllers/concerns/decidim/force_authentication.rb +1 -1
  17. data/app/controllers/concerns/decidim/paginable.rb +1 -1
  18. data/app/controllers/concerns/decidim/use_organization_time_zone.rb +1 -1
  19. data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -22
  20. data/app/controllers/decidim/devise/sessions_controller.rb +1 -24
  21. data/app/controllers/decidim/links_controller.rb +13 -1
  22. data/app/controllers/decidim/widgets_controller.rb +6 -0
  23. data/app/events/decidim/welcome_notification_event.rb +6 -9
  24. data/app/helpers/decidim/cells_paginate_helper.rb +1 -1
  25. data/app/helpers/decidim/check_boxes_tree_helper.rb +4 -4
  26. data/app/helpers/decidim/newsletters_helper.rb +83 -16
  27. data/app/helpers/decidim/resource_helper.rb +1 -1
  28. data/app/helpers/decidim/sanitize_helper.rb +9 -0
  29. data/app/helpers/decidim/user_profile_helper.rb +7 -2
  30. data/app/mailers/decidim/application_mailer.rb +40 -6
  31. data/app/mailers/decidim/messaging/conversation_mailer.rb +3 -72
  32. data/app/models/decidim/push_notification_message.rb +39 -0
  33. data/app/packs/images/decidim/.keep +0 -0
  34. data/app/packs/src/decidim/input_hashtags.js +1 -1
  35. data/app/packs/src/decidim/input_mentions.js +1 -1
  36. data/app/packs/src/decidim/input_multiple_mentions.js +1 -1
  37. data/app/packs/src/decidim/vizzs/index.js +1 -1
  38. data/app/packs/stylesheets/decidim/plugins/leaflet.scss +118 -114
  39. data/app/presenters/decidim/admin_log/oauth_application_resource_presenter.rb +1 -1
  40. data/app/presenters/decidim/admin_log/organization_presenter.rb +1 -1
  41. data/app/presenters/decidim/log/resource_presenter.rb +7 -1
  42. data/app/presenters/decidim/notification_to_mailer_presenter.rb +9 -0
  43. data/app/services/decidim/events_manager.rb +6 -0
  44. data/app/services/decidim/log/diff_changeset_calculator.rb +1 -1
  45. data/app/services/decidim/push_notification_message_sender.rb +36 -0
  46. data/app/services/decidim/send_push_notification.rb +22 -8
  47. data/app/views/decidim/devise/registrations/new.html.erb +2 -2
  48. data/app/views/decidim/links/new.html.erb +2 -0
  49. data/app/views/decidim/notifications_digest_mailer/_email_content.html.erb +7 -0
  50. data/app/views/decidim/shared/_address_details.html.erb +2 -2
  51. data/app/views/layouts/decidim/_js_configuration.html.erb +1 -0
  52. data/config/locales/ar.yml +4 -3
  53. data/config/locales/bg.yml +484 -1
  54. data/config/locales/ca.yml +23 -22
  55. data/config/locales/cs.yml +0 -1
  56. data/config/locales/de.yml +28 -27
  57. data/config/locales/el.yml +5 -4
  58. data/config/locales/en.yml +1 -0
  59. data/config/locales/eo.yml +3 -0
  60. data/config/locales/es-MX.yml +6 -5
  61. data/config/locales/es-PY.yml +6 -5
  62. data/config/locales/es.yml +25 -24
  63. data/config/locales/eu.yml +12 -2
  64. data/config/locales/fi-plain.yml +1 -0
  65. data/config/locales/fi.yml +4 -3
  66. data/config/locales/fr-CA.yml +5 -4
  67. data/config/locales/fr.yml +3 -2
  68. data/config/locales/ga-IE.yml +5 -0
  69. data/config/locales/gl.yml +3 -0
  70. data/config/locales/he-IL.yml +1 -0
  71. data/config/locales/hu.yml +41 -9
  72. data/config/locales/it.yml +5 -4
  73. data/config/locales/ja.yml +5 -3
  74. data/config/locales/lb.yml +5 -4
  75. data/config/locales/lt.yml +4 -4
  76. data/config/locales/lv.yml +4 -1
  77. data/config/locales/nl.yml +4 -1
  78. data/config/locales/no.yml +5 -4
  79. data/config/locales/pl.yml +168 -1
  80. data/config/locales/pt-BR.yml +113 -22
  81. data/config/locales/pt.yml +5 -4
  82. data/config/locales/ro-RO.yml +1 -3
  83. data/config/locales/ru.yml +13 -0
  84. data/config/locales/sk.yml +6 -1
  85. data/config/locales/sl.yml +5 -0
  86. data/config/locales/sv.yml +26 -3
  87. data/config/locales/tr-TR.yml +3 -3
  88. data/config/locales/uk.yml +15 -0
  89. data/config/locales/zh-CN.yml +0 -4
  90. data/config/locales/zh-TW.yml +4 -4
  91. data/decidim-core.gemspec +78 -0
  92. data/lib/decidim/acts_as_tree.rb +14 -1
  93. data/lib/decidim/asset_router/storage.rb +4 -0
  94. data/lib/decidim/attribute_encryptor.rb +6 -4
  95. data/lib/decidim/core/engine.rb +7 -3
  96. data/lib/decidim/core/test/factories.rb +314 -95
  97. data/lib/decidim/core/test/shared_examples/amendable/amendment_created_event_examples.rb +6 -26
  98. data/lib/decidim/core/test/shared_examples/amendable/amendment_promoted_event_examples.rb +8 -26
  99. data/lib/decidim/core/test/shared_examples/comments_examples.rb +32 -0
  100. data/lib/decidim/core/test/shared_examples/embed_resource_examples.rb +187 -11
  101. data/lib/decidim/core/test/shared_examples/has_attachment_collections.rb +8 -6
  102. data/lib/decidim/core/test/shared_examples/has_attachments.rb +4 -4
  103. data/lib/decidim/core/test/shared_examples/has_category.rb +27 -0
  104. data/lib/decidim/core/test/shared_examples/has_reference.rb +1 -1
  105. data/lib/decidim/core/test/shared_examples/has_space_in_mcell_examples.rb +1 -2
  106. data/lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb +6 -3
  107. data/lib/decidim/core/test/shared_examples/resource_locator_presenter_examples.rb +134 -0
  108. data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +1 -1
  109. data/lib/decidim/core/test/shared_examples/simple_event.rb +50 -2
  110. data/lib/decidim/core/test.rb +1 -0
  111. data/lib/decidim/core/version.rb +1 -1
  112. data/lib/decidim/core.rb +1 -0
  113. data/lib/decidim/engine_router.rb +17 -4
  114. data/lib/decidim/events/base_event.rb +9 -2
  115. data/lib/decidim/events/simple_event.rb +3 -17
  116. data/lib/decidim/form_builder.rb +13 -1
  117. data/lib/decidim/has_category.rb +1 -1
  118. data/lib/decidim/has_conversations.rb +91 -0
  119. data/lib/decidim/organization_settings.rb +10 -2
  120. data/lib/decidim/participable.rb +17 -0
  121. data/lib/decidim/view_model.rb +1 -0
  122. data/lib/decidim/webpacker/webpack/.modernizrrc +9 -0
  123. data/lib/premailer/adapter/decidim.rb +5 -4
  124. data/lib/tasks/decidim_reminders_tasks.rake +1 -0
  125. data/lib/tasks/upgrade/decidim_fix_categorization.rake +15 -0
  126. metadata +29 -27
  127. data/config/environment.rb +0 -3
@@ -11,7 +11,7 @@ module Decidim
11
11
  #
12
12
  # Returns an HTML-safe String.
13
13
  def resource_path
14
- @resource_path ||= h.decidim_admin.oauth_application_path(resource)
14
+ @resource_path ||= h.decidim_system.oauth_application_path(resource)
15
15
  end
16
16
  end
17
17
  end
@@ -26,7 +26,7 @@ module Decidim
26
26
 
27
27
  def settings_attributes_mapping
28
28
  {
29
- name: :string,
29
+ name: :i18n,
30
30
  default_locale: :locale,
31
31
  reference_prefix: :string,
32
32
  twitter_handler: :string,
@@ -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
- h.translated_attribute extra["title"]
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
- # Returns the result of the dispatch or nil if user or subscription are empty
18
- def perform(notification)
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(notification.user.locale || notification.user.organization.default_locale) do
22
- notification.user.notifications_subscriptions.values.map do |subscription|
23
- message_params = notification_params(Decidim::PushNotificationPresenter.new(notification))
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 notification_params(notification)
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
- <h3><%= t(".tos_title") %></h3>
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
- <h3><%= t(".newsletter_title") %></h3>
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>
@@ -1,3 +1,5 @@
1
+ <% add_decidim_page_title t("decidim.links.warning.title") %>
2
+
1
3
  <div class="wrapper external-link-page-content">
2
4
  <h1 class="text-center"><%= t("decidim.links.warning.title") %></h1>
3
5
  <div class="row columns large-centered large-8">
@@ -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 geolocalizable.location %></strong><br>
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 geolocalizable.location_hints %></span>
6
+ <span><%= decidim_sanitize(translated_attribute(geolocalizable.location_hints)) %></span>
7
7
  <% end %>
@@ -1,5 +1,6 @@
1
1
  <%
2
2
  js_configs = {
3
+ api_path: decidim_api.root_path(locale: nil),
3
4
  icons_path: Decidim.cors_enabled ? "" : asset_pack_path("media/images/icons.svg"),
4
5
  messages: {
5
6
  "selfxssWarning": {
@@ -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>.