decidim-core 0.27.6 → 0.27.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/follow_button_cell.rb +1 -1
  3. data/app/cells/decidim/notification/moderated.erb +24 -0
  4. data/app/cells/decidim/notification_cell.rb +5 -1
  5. data/app/controllers/concerns/decidim/force_authentication.rb +1 -1
  6. data/app/controllers/concerns/decidim/use_organization_time_zone.rb +1 -1
  7. data/app/controllers/decidim/links_controller.rb +13 -1
  8. data/app/mailers/decidim/application_mailer.rb +40 -6
  9. data/app/presenters/decidim/admin_log/organization_presenter.rb +1 -1
  10. data/app/presenters/decidim/log/resource_presenter.rb +7 -1
  11. data/app/services/decidim/log/diff_changeset_calculator.rb +1 -1
  12. data/app/views/decidim/links/new.html.erb +2 -0
  13. data/config/locales/ar.yml +0 -1
  14. data/config/locales/bg.yml +410 -1
  15. data/config/locales/ca.yml +1 -0
  16. data/config/locales/cs.yml +0 -1
  17. data/config/locales/de.yml +3 -2
  18. data/config/locales/el.yml +4 -1
  19. data/config/locales/en.yml +1 -0
  20. data/config/locales/eo.yml +3 -0
  21. data/config/locales/es-MX.yml +5 -4
  22. data/config/locales/es-PY.yml +5 -4
  23. data/config/locales/es.yml +5 -4
  24. data/config/locales/eu.yml +1 -0
  25. data/config/locales/fi-plain.yml +1 -0
  26. data/config/locales/fi.yml +1 -0
  27. data/config/locales/fr-CA.yml +3 -2
  28. data/config/locales/fr.yml +1 -0
  29. data/config/locales/ga-IE.yml +5 -0
  30. data/config/locales/hu.yml +0 -1
  31. data/config/locales/it.yml +4 -1
  32. data/config/locales/ja.yml +2 -1
  33. data/config/locales/lb.yml +4 -1
  34. data/config/locales/lt.yml +4 -1
  35. data/config/locales/lv.yml +4 -1
  36. data/config/locales/nl.yml +4 -1
  37. data/config/locales/no.yml +4 -1
  38. data/config/locales/pl.yml +31 -0
  39. data/config/locales/pt-BR.yml +0 -1
  40. data/config/locales/pt.yml +4 -1
  41. data/config/locales/ro-RO.yml +1 -0
  42. data/config/locales/ru.yml +4 -0
  43. data/config/locales/sk.yml +4 -1
  44. data/config/locales/sl.yml +5 -0
  45. data/config/locales/sv.yml +4 -1
  46. data/config/locales/tr-TR.yml +2 -0
  47. data/config/locales/uk.yml +1 -0
  48. data/config/locales/zh-CN.yml +0 -1
  49. data/config/locales/zh-TW.yml +4 -1
  50. data/lib/decidim/core/test/factories.rb +9 -3
  51. data/lib/decidim/core/test/shared_examples/has_attachment_collections.rb +3 -3
  52. data/lib/decidim/core/test/shared_examples/has_attachments.rb +1 -1
  53. data/lib/decidim/core/version.rb +1 -1
  54. data/lib/decidim/events/base_event.rb +4 -0
  55. data/lib/decidim/form_builder.rb +13 -1
  56. data/lib/decidim/organization_settings.rb +10 -2
  57. metadata +11 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99119ce695e1aa34d4a744deca10b822209b52253058e77548a6399cd78f0069
4
- data.tar.gz: '052746495077e884e4cb8e5bc33c8bcb6af257efbee57b385b39f62404530fd5'
3
+ metadata.gz: 71d8e583cc9dcd7338a03de09eb24a8a06a913f5e411b74bf16e5c42d9802639
4
+ data.tar.gz: c7028f8e3b04ab7c04afb94e6c74cbc114af7f734b5e65ff53d6a31bc0b6683e
5
5
  SHA512:
6
- metadata.gz: e5b7a3d7779697415e7ec9badd7d4d00bd408a1f42e7c667f01b797558ba22524231273b94f3f6beeb644f7aee8692bd5d2d580a7493c84dfaa5eb563241bc58
7
- data.tar.gz: 193b200909cc1fa784ccad5583b3c9593b8e6a9be31c10ab03c90ee9153075ac0d168566e7fe275bb9140c1bc53a8a42e58f84ffc9b852fe91269deef496d5a3
6
+ metadata.gz: f7df735fa2c671d915577eee036cb64b06c3ef85f4ecd1c95a65e22affb625f2a136c1596e55a7250f473397165f2364db867bad3287ecc3ffe5231e234cdc44
7
+ data.tar.gz: fd264b6e1db71ec2e9b1fb0cc31a73ddadf7c3e2a3dbe7209001f87f52a3840bae8f4bd406f5c84767460fea73fbcbf18a9f950b82d91d5b23c47b1bd02f60fa
@@ -46,7 +46,7 @@ module Decidim
46
46
 
47
47
  def render_screen_reader_title_for(resource)
48
48
  content_tag :span, class: "show-for-sr" do
49
- decidim_html_escape(resource_title(resource))
49
+ decidim_sanitize_translated(resource_title(resource))
50
50
  end
51
51
  end
52
52
 
@@ -0,0 +1,24 @@
1
+ <div class="card card--widget">
2
+ <ul class="card-data">
3
+ <li class="card-data__item">
4
+ <div class="card__link text-center">
5
+ <%= resource_icon notification.resource, class: "icon--large" %>
6
+ <span class="text-medium mt-xs" title="<%= l(notification.created_at) %>" data-tooltip="true" data-disable-hover="false">
7
+ <%= notification.created_at_in_words %>
8
+ </span>
9
+ </div>
10
+ </li>
11
+ <li class="card-data__item card-data__item--expand absolutes">
12
+ <div class="mr-s">
13
+ <span class="text-small"><%= notification.event_class.constantize.model_name.human %></span>
14
+ <br>
15
+ <%= t("decidim.notifications.show.moderated") %>
16
+ </div>
17
+ <div class="right center mr-s">
18
+ <%= link_to model, remote: true, method: :delete, class: "mark-as-read-button" do %>
19
+ <%= icon "circle-x", class: "card__link", aria_label: t("mark_as_read", scope: "layouts.decidim.notifications_dashboard"), role: "img" %>
20
+ <% end %>
21
+ </div>
22
+ </li>
23
+ </ul>
24
+ </div>
@@ -8,7 +8,11 @@ module Decidim
8
8
  include Decidim::Core::Engine.routes.url_helpers
9
9
 
10
10
  def show
11
- render :show
11
+ if notification.event_class_instance.try(:hidden_resource?)
12
+ render :moderated
13
+ else
14
+ render :show
15
+ end
12
16
  end
13
17
 
14
18
  def notification_title
@@ -17,7 +17,7 @@ module Decidim
17
17
  # Breaks the request lifecycle, if user is not authenticated.
18
18
  # Otherwise returns.
19
19
  def ensure_authenticated!
20
- return true unless current_organization.force_users_to_authenticate_before_access_organization
20
+ return true unless current_organization&.force_users_to_authenticate_before_access_organization
21
21
 
22
22
  # Next stop: Let's check whether auth is ok
23
23
  unless user_signed_in?
@@ -25,7 +25,7 @@ module Decidim
25
25
  #
26
26
  # Returns a String.
27
27
  def organization_time_zone
28
- @organization_time_zone ||= current_organization.time_zone
28
+ @organization_time_zone ||= current_organization&.time_zone
29
29
  end
30
30
  end
31
31
  end
@@ -35,7 +35,19 @@ module Decidim
35
35
  end
36
36
 
37
37
  def external_url
38
- @external_url ||= URI.parse(URI::Parser.new.escape(params[:external_url]))
38
+ @external_url ||= URI.parse(escape_url(params[:external_url]))
39
+ end
40
+
41
+ def escape_url(external_url)
42
+ before_fragment, fragment = external_url.split("#", 2)
43
+ escaped_before_fragment = URI::Parser.new.escape(before_fragment)
44
+
45
+ if fragment
46
+ escaped_fragment = URI::Parser.new.escape(fragment)
47
+ "#{escaped_before_fragment}##{escaped_fragment}"
48
+ else
49
+ escaped_before_fragment
50
+ end
39
51
  end
40
52
  end
41
53
  end
@@ -7,23 +7,57 @@ module Decidim
7
7
  include LocalisedMailer
8
8
  include MultitenantAssetHost
9
9
  after_action :set_smtp
10
+ after_action :set_from
10
11
 
11
12
  default from: Decidim.config.mailer_sender
12
13
  layout "decidim/mailer"
13
14
 
14
15
  private
15
16
 
17
+ attr_reader :organization
18
+
16
19
  def set_smtp
17
- return if @organization.nil? || @organization.smtp_settings.blank?
20
+ return if organization.nil? || organization.smtp_settings.blank? || organization.smtp_settings.except("from", "from_label", "from_email").all?(&:blank?)
18
21
 
19
- mail.from = @organization.smtp_settings["from"].presence || mail.from
20
22
  mail.reply_to = mail.reply_to || Decidim.config.mailer_reply
21
23
  mail.delivery_method.settings.merge!(
22
- address: @organization.smtp_settings["address"],
23
- port: @organization.smtp_settings["port"],
24
- user_name: @organization.smtp_settings["user_name"],
25
- password: Decidim::AttributeEncryptor.decrypt(@organization.smtp_settings["encrypted_password"])
24
+ address: organization.smtp_settings["address"],
25
+ port: organization.smtp_settings["port"],
26
+ user_name: organization.smtp_settings["user_name"],
27
+ password: Decidim::AttributeEncryptor.decrypt(organization.smtp_settings["encrypted_password"])
26
28
  ) { |_k, o, v| v.presence || o }.compact_blank!
27
29
  end
30
+
31
+ def set_from
32
+ return if organization.nil?
33
+ return if already_defined_name_in_mail?(mail.from.first)
34
+
35
+ mail.from = sender
36
+ end
37
+
38
+ def sender
39
+ return Decidim.config.mailer_sender if return_mailer_sender?
40
+ return default_sender if organization.smtp_settings.blank?
41
+ return default_sender if organization.smtp_settings["from"].nil?
42
+ return default_sender if organization.smtp_settings["from"].empty?
43
+
44
+ smtp_settings_from = organization.smtp_settings["from"]
45
+ return smtp_settings_from if already_defined_name_in_mail?(smtp_settings_from)
46
+
47
+ email_address_with_name(smtp_settings_from, organization.name)
48
+ end
49
+
50
+ def default_sender
51
+ email_address_with_name(Decidim.config.mailer_sender, organization.name)
52
+ end
53
+
54
+ def already_defined_name_in_mail?(mail_address)
55
+ # if there is an space, there is already a name in the address
56
+ mail_address.match?(/ /)
57
+ end
58
+
59
+ def return_mailer_sender?
60
+ already_defined_name_in_mail?(Decidim.config.mailer_sender) && organization.smtp_settings.present?
61
+ end
28
62
  end
29
63
  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
@@ -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)
@@ -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">
@@ -333,7 +333,6 @@ ar:
333
333
  '1': إنشاء التعديل الخاص بك
334
334
  '2': قارن تعديلك
335
335
  '3': اكمل تعديلك
336
- '4': انشر تعديلك
337
336
  anonymous_user: مجهول
338
337
  application:
339
338
  collection: