decidim-core 0.27.0.rc1 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim-core might be problematic. Click here for more details.

Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/announcement_cell.rb +1 -1
  3. data/app/cells/decidim/content_blocks/cta/show.erb +1 -1
  4. data/app/cells/decidim/content_blocks/cta_cell.rb +1 -1
  5. data/app/cells/decidim/content_blocks/hero/show.erb +2 -2
  6. data/app/cells/decidim/content_blocks/hero_cell.rb +1 -0
  7. data/app/cells/decidim/content_blocks/highlighted_content_banner/show.erb +2 -2
  8. data/app/cells/decidim/content_blocks/stats_cell.rb +1 -0
  9. data/app/cells/decidim/content_blocks/sub_hero_cell.rb +1 -1
  10. data/app/cells/decidim/data_consent/category.erb +19 -19
  11. data/app/cells/decidim/data_consent/dialog.erb +12 -12
  12. data/app/cells/decidim/data_consent/modal.erb +13 -13
  13. data/app/cells/decidim/data_consent_cell.rb +3 -3
  14. data/app/commands/decidim/update_account.rb +3 -1
  15. data/app/controllers/concerns/decidim/resource_versions_concern.rb +4 -0
  16. data/app/controllers/decidim/devise/registrations_controller.rb +5 -1
  17. data/app/controllers/decidim/last_activities_controller.rb +1 -0
  18. data/app/events/decidim/resource_endorsed_event.rb +2 -1
  19. data/app/forms/decidim/account_form.rb +1 -1
  20. data/app/forms/decidim/user_group_form.rb +1 -1
  21. data/app/helpers/decidim/filters_helper.rb +5 -1
  22. data/app/helpers/decidim/sanitize_helper.rb +12 -3
  23. data/app/models/decidim/action_log.rb +9 -9
  24. data/app/models/decidim/notification.rb +11 -2
  25. data/app/models/decidim/user_base_entity.rb +1 -0
  26. data/app/packs/entrypoints/decidim_core.js +1 -1
  27. data/app/packs/src/decidim/account_form.js +68 -18
  28. data/app/packs/src/decidim/{cookie_consent → data_consent}/consent_manager.js +27 -24
  29. data/app/packs/src/decidim/data_consent/consent_manager.test.js +280 -0
  30. data/app/packs/src/decidim/{cookie_consent/cookie_consent.js → data_consent/index.js} +12 -12
  31. data/app/packs/src/decidim/input_character_counter.js +57 -34
  32. data/app/packs/src/decidim/sw/a2hs.js +10 -1
  33. data/app/packs/stylesheets/decidim/modules/_cards.scss +2 -0
  34. data/app/packs/stylesheets/decidim/modules/_comments.scss +2 -0
  35. data/app/packs/stylesheets/decidim/modules/{_cookie-consent.scss → _data-consent.scss} +10 -10
  36. data/app/packs/stylesheets/decidim/modules/_forms.scss +5 -0
  37. data/app/packs/stylesheets/decidim/modules/_modules.scss +1 -1
  38. data/app/permissions/decidim/permissions.rb +4 -2
  39. data/app/presenters/decidim/push_notification_presenter.rb +2 -1
  40. data/app/presenters/decidim/user_presenter.rb +4 -1
  41. data/app/scrubbers/decidim/admin_input_scrubber.rb +25 -0
  42. data/app/scrubbers/decidim/user_input_scrubber.rb +3 -5
  43. data/app/services/decidim/iframe_disabler.rb +2 -3
  44. data/app/services/decidim/notifications_digest_sending_decider.rb +6 -2
  45. data/app/services/decidim/send_push_notification.rb +14 -12
  46. data/app/views/decidim/account/_password_fields.html.erb +2 -2
  47. data/app/views/decidim/download_your_data/show.html.erb +1 -1
  48. data/app/views/decidim/notifications_settings/show.html.erb +65 -67
  49. data/app/views/decidim/pages/_standalone.html.erb +1 -1
  50. data/app/views/decidim/pages/_tabbed.html.erb +1 -1
  51. data/app/views/decidim/user_interests/show.html.erb +11 -13
  52. data/app/views/layouts/decidim/_application.html.erb +1 -1
  53. data/app/views/layouts/decidim/_data_consent_warning.html.erb +8 -0
  54. data/app/views/layouts/decidim/_main_footer.html.erb +1 -1
  55. data/config/locales/am-ET.yml +0 -1
  56. data/config/locales/ar.yml +0 -11
  57. data/config/locales/bg.yml +1 -10
  58. data/config/locales/ca.yml +20 -25
  59. data/config/locales/cs.yml +26 -31
  60. data/config/locales/da.yml +0 -1
  61. data/config/locales/de.yml +205 -11
  62. data/config/locales/el.yml +0 -9
  63. data/config/locales/en.yml +17 -22
  64. data/config/locales/es-MX.yml +21 -26
  65. data/config/locales/es-PY.yml +20 -25
  66. data/config/locales/es.yml +22 -27
  67. data/config/locales/et.yml +0 -1
  68. data/config/locales/eu.yml +4 -13
  69. data/config/locales/fi-plain.yml +17 -22
  70. data/config/locales/fi.yml +17 -22
  71. data/config/locales/fr-CA.yml +30 -21
  72. data/config/locales/fr.yml +43 -34
  73. data/config/locales/ga-IE.yml +1 -3
  74. data/config/locales/gl.yml +0 -11
  75. data/config/locales/hr.yml +0 -1
  76. data/config/locales/hu.yml +271 -10
  77. data/config/locales/id-ID.yml +0 -11
  78. data/config/locales/is-IS.yml +2 -1
  79. data/config/locales/it.yml +3 -12
  80. data/config/locales/ja.yml +31 -25
  81. data/config/locales/ko.yml +0 -1
  82. data/config/locales/lb.yml +0 -9
  83. data/config/locales/lt.yml +1949 -0
  84. data/config/locales/lv.yml +0 -9
  85. data/config/locales/mt.yml +0 -1
  86. data/config/locales/nl.yml +18 -12
  87. data/config/locales/no.yml +1 -10
  88. data/config/locales/oc-FR.yml +1 -0
  89. data/config/locales/om-ET.yml +0 -1
  90. data/config/locales/pl.yml +1 -10
  91. data/config/locales/pt-BR.yml +4 -13
  92. data/config/locales/pt.yml +1 -10
  93. data/config/locales/ro-RO.yml +0 -9
  94. data/config/locales/ru.yml +0 -2
  95. data/config/locales/si-LK.yml +0 -1
  96. data/config/locales/sk.yml +0 -12
  97. data/config/locales/so-SO.yml +0 -1
  98. data/config/locales/sv.yml +9 -14
  99. data/config/locales/sw-KE.yml +0 -1
  100. data/config/locales/ti-ER.yml +0 -1
  101. data/config/locales/tr-TR.yml +2 -11
  102. data/config/locales/uk.yml +1 -2
  103. data/config/locales/val-ES.yml +0 -1
  104. data/config/locales/vi.yml +0 -1
  105. data/config/locales/zh-CN.yml +2 -11
  106. data/config/locales/zh-TW.yml +0 -1
  107. data/config/routes.rb +20 -2
  108. data/lib/decidim/attributes/model.rb +9 -1
  109. data/lib/decidim/content_parsers/hashtag_parser.rb +1 -1
  110. data/lib/decidim/core/engine.rb +1 -1
  111. data/lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb +60 -0
  112. data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +40 -0
  113. data/lib/decidim/core/test/shared_examples/with_endorsable_permissions_examples.rb +1 -1
  114. data/lib/decidim/core/test.rb +2 -0
  115. data/lib/decidim/core/version.rb +1 -1
  116. data/lib/decidim/core.rb +52 -13
  117. data/lib/decidim/dependency_resolver.rb +272 -0
  118. data/lib/decidim/events/simple_event.rb +1 -0
  119. data/lib/decidim/has_resource_permission.rb +0 -2
  120. data/lib/decidim/map/provider/dynamic_map/here.rb +46 -1
  121. data/lib/decidim/nicknamizable.rb +1 -1
  122. data/lib/decidim/translatable_attributes.rb +8 -1
  123. data/lib/decidim/url_option_resolver.rb +1 -1
  124. metadata +18 -13
  125. data/app/views/decidim/devise/registrations/edit.html.erb +0 -41
  126. data/app/views/layouts/decidim/_cookie_warning.html.erb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db2049c9f719053d8344dc12a1cc1333b839c20c53de98b67e3ca27bb013e0be
4
- data.tar.gz: 139361af6d051e502902469fed8c2fb0ed5357cd30d3f41895f63040f2140c7c
3
+ metadata.gz: 4d066aea0f8b2cede42dcd7ac23f6a22d8685f45e776cd5f7e2a8a39a8498ee9
4
+ data.tar.gz: a5536659a0c2c25cedde842b9c3f747e428a9b9b667d69bbf04c64bb9ef98125
5
5
  SHA512:
6
- metadata.gz: 58f161196f88af069f757f01d0cb008a0a0821d5e6fe26b8151bdeb8aac7b5b9646435e0108ef1bb6a4438c91161fa8c8de6896a4dc61bf9e6aa283cf62128ec
7
- data.tar.gz: 070fbf34950a9c38c70aa55f877dcc18e86b19914ed587536e5711c4fa2e68a14f43fd786197e3b99e07e4f66c2482978279f8aa96499639f4db91fd216da2fd
6
+ metadata.gz: a818266bb8122ab36bedb0aac0991a98ac0eb460482b4d1c4188eab66136fadda00ffe7d8452735598a2ee8a2198670d25d57afe6a2b4c7a3761bd21cac41655
7
+ data.tar.gz: e5c1b93af9f057e33a773e443a3badc07c20af25be4f874ad1ed6219cbf92ed82bd0e91d9aeb48534ef90952087f0be26a718b872afe71254085ca9629e8dd25
@@ -62,7 +62,7 @@ module Decidim
62
62
  end
63
63
 
64
64
  def clean(value)
65
- decidim_sanitize(translated_attribute(value))
65
+ decidim_sanitize_admin(translated_attribute(value))
66
66
  end
67
67
  end
68
68
  end
@@ -1,5 +1,5 @@
1
1
  <section class="section">
2
- <div class="expanded hero" style="background-image:url(<%= background_image %>);">
2
+ <div class="expanded hero" style="background-image:url('<%= background_image %>');">
3
3
  <div class="hero__container">
4
4
  <div class="row">
5
5
  <div class="columns small-centered medium-6 text-center">
@@ -16,7 +16,7 @@ module Decidim
16
16
  end
17
17
 
18
18
  def translated_description
19
- @translated_description ||= decidim_sanitize_editor(translated_attribute(model.settings.description))
19
+ @translated_description ||= decidim_sanitize_editor_admin(translated_attribute(model.settings.description))
20
20
  end
21
21
 
22
22
  def button_url
@@ -1,4 +1,4 @@
1
- <section id="hero" class="extended hero home-section" style="background-image:url(<%= background_image %>);">
1
+ <section id="hero" class="extended hero home-section" style="background-image:url('<%= background_image %>');">
2
2
  <div class="hero__container">
3
3
  <div class="row">
4
4
  <div class="columns small-centered large-10">
@@ -6,7 +6,7 @@
6
6
  <% if translated_welcome_text.blank? %>
7
7
  <%= t("decidim.pages.home.hero.welcome", organization: current_organization.name) %>
8
8
  <% else %>
9
- <%= decidim_sanitize translated_welcome_text %>
9
+ <%= decidim_sanitize_admin translated_welcome_text %>
10
10
  <% end %>
11
11
  </h1>
12
12
  </div>
@@ -29,6 +29,7 @@ module Decidim
29
29
  hash << Digest::MD5.hexdigest(model.attributes.to_s)
30
30
  hash << current_organization.cache_key_with_version
31
31
  hash << I18n.locale.to_s
32
+ hash << background_image
32
33
 
33
34
  hash.join(Decidim.cache_key_separator)
34
35
  end
@@ -1,5 +1,5 @@
1
1
  <section id="highlighted_content_banner" class="extended highligted-content-banner home-section"
2
- style="background-image:url(<%= current_organization.attached_uploader(:highlighted_content_banner_image).path %>);">
2
+ style="background-image:url('<%= current_organization.attached_uploader(:highlighted_content_banner_image).path %>');">
3
3
  <div class="highligted-content-banner__container">
4
4
  <div class="row">
5
5
  <div class="columns large-10">
@@ -7,7 +7,7 @@
7
7
  <%= translated_attribute current_organization.highlighted_content_banner_title %>
8
8
  </h1>
9
9
  <div class="text-highlight">
10
- <%= decidim_sanitize_editor translated_attribute current_organization.highlighted_content_banner_short_description %>
10
+ <%= decidim_sanitize_editor_admin translated_attribute current_organization.highlighted_content_banner_short_description %>
11
11
  </div>
12
12
  </div>
13
13
  <div class="columns large-2">
@@ -12,6 +12,7 @@ module Decidim
12
12
  def cache_hash
13
13
  hash = []
14
14
  hash.push(I18n.locale)
15
+ hash.push(current_organization.cache_key)
15
16
  hash.join(Decidim.cache_key_separator)
16
17
  end
17
18
 
@@ -15,7 +15,7 @@ module Decidim
15
15
  private
16
16
 
17
17
  def organization_description
18
- desc = decidim_sanitize(translated_attribute(current_organization.description))
18
+ desc = decidim_sanitize_admin(translated_attribute(current_organization.description))
19
19
 
20
20
  # Strip the surrounding paragraph tag because it is not allowed within
21
21
  # a <hN> element.
@@ -1,60 +1,60 @@
1
1
  <div class="category-wrapper margin-vertical-1" data-id="<%= category[:slug] %>">
2
2
  <div class="category-row flex-center">
3
- <button class="cc-title padding-left-3">
4
- <span class="h5 cc-category-title">
3
+ <button class="dc-title padding-left-3">
4
+ <span class="h5 dc-category-title">
5
5
  <strong><%= category[:title] %></strong>
6
6
  </span>
7
7
  </button>
8
8
 
9
- <div class="cc-switch">
9
+ <div class="dc-switch">
10
10
  <input
11
11
  class="switch-input"
12
12
  <%= %(checked="checked") if category[:mandatory] %>
13
- id="cc-<%= category[:slug] %>"
13
+ id="dc-<%= category[:slug] %>"
14
14
  type="checkbox"
15
15
  name="<%= category[:slug] %>"
16
16
  <%= "disabled" if category[:mandatory] %>>
17
17
 
18
- <label class="switch-paddle" for="cc-<%= category[:slug] %>">
19
- <span class="show-for-sr"><%= t("layouts.decidim.cookie_consent.modal.toggle", consent_category: category[:title]) %></span>
18
+ <label class="switch-paddle" for="dc-<%= category[:slug] %>">
19
+ <span class="show-for-sr"><%= t("layouts.decidim.data_consent.modal.toggle", consent_category: category[:title]) %></span>
20
20
  </label>
21
21
  </div>
22
22
  </div>
23
- <div class="cc-description hide">
23
+ <div class="dc-description hide">
24
24
  <div class="description-text">
25
25
  <p><%= category[:description] %></p>
26
26
  </div>
27
27
 
28
- <% if category[:cookies].present? %>
29
- <div class="cookie-details-wrapper">
28
+ <% if category[:items].present? %>
29
+ <div class="dataconsent-details-wrapper">
30
30
  <div class="row detail-titles">
31
31
  <div class="columns small-2">
32
- <%= t("layouts.decidim.cookie_consent.cookie_details.columns.type") %>
32
+ <%= t("layouts.decidim.data_consent.details.columns.type") %>
33
33
  </div>
34
34
  <div class="columns small-2">
35
- <%= t("layouts.decidim.cookie_consent.cookie_details.columns.name") %>
35
+ <%= t("layouts.decidim.data_consent.details.columns.name") %>
36
36
  </div>
37
37
  <div class="columns small-2">
38
- <%= t("layouts.decidim.cookie_consent.cookie_details.columns.service") %>
38
+ <%= t("layouts.decidim.data_consent.details.columns.service") %>
39
39
  </div>
40
40
  <div class="columns small-6">
41
- <%= t("layouts.decidim.cookie_consent.cookie_details.columns.description") %>
41
+ <%= t("layouts.decidim.data_consent.details.columns.description") %>
42
42
  </div>
43
43
  </div>
44
44
 
45
- <% category[:cookies].each do |cookie| %>
46
- <div class="row cookie-detail-row">
45
+ <% category[:items].each do |item| %>
46
+ <div class="row dataconsent-detail-row">
47
47
  <div class="columns small-2">
48
- <%= t("layouts.decidim.cookie_consent.cookie_details.types.#{cookie[:type]}") %>
48
+ <%= t("layouts.decidim.data_consent.details.types.#{item[:type]}") %>
49
49
  </div>
50
50
  <div class="columns small-2">
51
- <%= cookie[:name] %>
51
+ <%= item[:name] %>
52
52
  </div>
53
53
  <div class="columns small-2">
54
- <%= t("layouts.decidim.cookie_consent.cookie_details.cookies.#{cookie[:name]}.service") %>
54
+ <%= t("layouts.decidim.data_consent.details.items.#{item[:name]}.service") %>
55
55
  </div>
56
56
  <div class="columns small-6">
57
- <%= t("layouts.decidim.cookie_consent.cookie_details.cookies.#{cookie[:name]}.description") %>
57
+ <%= t("layouts.decidim.data_consent.details.items.#{item[:name]}.description") %>
58
58
  </div>
59
59
  </div>
60
60
  <% end %>
@@ -1,26 +1,26 @@
1
- <div id="cc-dialog-wrapper" class="flex-center hide robots-noindex robots-nocontent noindex" data-nosnippet role="region">
2
- <div class="cc-dialog padding-vertical-1">
1
+ <div id="dc-dialog-wrapper" class="flex-center hide robots-noindex robots-nocontent noindex" data-nosnippet role="region">
2
+ <div class="dc-dialog padding-vertical-1">
3
3
  <div class="row expanded">
4
4
  <div class="columns medium-12 large-8">
5
- <div class="cc-content">
5
+ <div class="dc-content">
6
6
  <div class="h5">
7
- <%= t("layouts.decidim.cookie_consent.dialog.title") %>
7
+ <%= t("layouts.decidim.data_consent.dialog.title") %>
8
8
  </div>
9
9
  <div>
10
- <%= t("layouts.decidim.cookie_consent.dialog.description") %>
10
+ <%= t("layouts.decidim.data_consent.dialog.description") %>
11
11
  </div>
12
12
  </div>
13
13
  </div>
14
14
  <div class="columns medium-12 large-4">
15
- <div class="cc-button-wrapper flex-center">
16
- <button id="cc-dialog-accept" class="button">
17
- <%= t("layouts.decidim.cookie_consent.dialog.accept_all") %>
15
+ <div class="dc-button-wrapper flex-center">
16
+ <button id="dc-dialog-accept" class="button">
17
+ <%= t("layouts.decidim.data_consent.dialog.accept_all") %>
18
18
  </button>
19
- <button id="cc-dialog-reject" class="button hollow">
20
- <%= t("layouts.decidim.cookie_consent.dialog.accept_only_essential") %>
19
+ <button id="dc-dialog-reject" class="button hollow">
20
+ <%= t("layouts.decidim.data_consent.dialog.accept_only_essential") %>
21
21
  </button>
22
- <button id="cc-dialog-settings" class="button clear" data-open="cc-modal">
23
- <%= t("layouts.decidim.cookie_consent.dialog.cookie_settings") %>
22
+ <button id="dc-dialog-settings" class="button clear" data-open="dc-modal">
23
+ <%= t("layouts.decidim.data_consent.dialog.settings") %>
24
24
  </button>
25
25
  </div>
26
26
  </div>
@@ -1,14 +1,14 @@
1
- <div class="reveal cc-modal" id="cc-modal" role="dialog" data-close-on-click="false" data-close-on-esc="false" aria-modal="true" data-reveal>
1
+ <div class="reveal dc-modal" id="dc-modal" role="dialog" data-close-on-click="false" data-close-on-esc="false" aria-modal="true" data-reveal>
2
2
  <div class="reveal__header">
3
3
  <h3 class="reveal__title">
4
- <%= t("layouts.decidim.cookie_consent.modal.title") %>
4
+ <%= t("layouts.decidim.data_consent.modal.title") %>
5
5
  </h3>
6
6
  <p>
7
- <%= t("layouts.decidim.cookie_consent.modal.description") %>
7
+ <%= t("layouts.decidim.data_consent.modal.description") %>
8
8
  </p>
9
9
  </div>
10
10
 
11
- <div class="cc-categories">
11
+ <div class="dc-categories">
12
12
  <% categories.each do |category| %>
13
13
  <%= render(
14
14
  {
@@ -21,18 +21,18 @@
21
21
  <% end %>
22
22
  </div>
23
23
 
24
- <div class="cc-buttons-wrapper flex-center">
25
- <div class="cc-buttons-left">
26
- <button id="cc-modal-accept" class="button" data-close>
27
- <%= t("layouts.decidim.cookie_consent.modal.accept_all") %>
24
+ <div class="dc-buttons-wrapper flex-center">
25
+ <div class="dc-buttons-left">
26
+ <button id="dc-modal-accept" class="button" data-close>
27
+ <%= t("layouts.decidim.data_consent.modal.accept_all") %>
28
28
  </button>
29
- <button id="cc-modal-reject" class="button hollow" data-close>
30
- <%= t("layouts.decidim.cookie_consent.modal.accept_only_essential") %>
29
+ <button id="dc-modal-reject" class="button hollow" data-close>
30
+ <%= t("layouts.decidim.data_consent.modal.accept_only_essential") %>
31
31
  </button>
32
32
  </div>
33
- <div class="cc-buttons-right">
34
- <button id="cc-modal-save" class="button clear" data-close>
35
- <%= t("layouts.decidim.cookie_consent.modal.save_settings") %>
33
+ <div class="dc-buttons-right">
34
+ <button id="dc-modal-save" class="button clear" data-close>
35
+ <%= t("layouts.decidim.data_consent.modal.save_settings") %>
36
36
  </button>
37
37
  </div>
38
38
  </div>
@@ -10,10 +10,10 @@ module Decidim
10
10
  @categories ||= Decidim.consent_categories.map do |category|
11
11
  {
12
12
  slug: category[:slug],
13
- title: t("layouts.decidim.cookie_consent.modal.#{category[:slug]}.title"),
14
- description: t("layouts.decidim.cookie_consent.modal.#{category[:slug]}.description"),
13
+ title: t("layouts.decidim.data_consent.modal.#{category[:slug]}.title"),
14
+ description: t("layouts.decidim.data_consent.modal.#{category[:slug]}.description"),
15
15
  mandatory: category[:mandatory],
16
- cookies: category.has_key?(:cookies) ? category[:cookies] : []
16
+ items: category.has_key?(:items) ? category[:items] : []
17
17
  }
18
18
  end
19
19
  end
@@ -24,7 +24,9 @@ module Decidim
24
24
  notify_followers
25
25
  broadcast(:ok, @user.unconfirmed_email.present?)
26
26
  else
27
- @form.errors.add :avatar, @user.errors[:avatar] if @user.errors.has_key? :avatar
27
+ [:avatar, :password, :password_confirmation].each do |key|
28
+ @form.errors.add key, @user.errors[key] if @user.errors.has_key? key
29
+ end
28
30
  broadcast(:invalid)
29
31
  end
30
32
  end
@@ -10,6 +10,10 @@ module Decidim
10
10
  helper Decidim::TraceabilityHelper
11
11
  helper_method :current_version, :versioned_resource
12
12
 
13
+ def show
14
+ raise ActionController::RoutingError, "Not found" unless current_version
15
+ end
16
+
13
17
  private
14
18
 
15
19
  # Overwrite this method in your controller to define how to find the
@@ -39,7 +39,7 @@ module Decidim
39
39
  end
40
40
 
41
41
  on(:invalid) do
42
- flash.now[:alert] = @form.errors[:base].join(", ") if @form.errors[:base].any?
42
+ flash.now[:alert] = @form.errors.full_messages.join(", ") if @form.errors.full_messages.any?
43
43
  render :new
44
44
  end
45
45
  end
@@ -60,6 +60,10 @@ module Decidim
60
60
  super(hash)
61
61
  resource.organization = current_organization
62
62
  end
63
+
64
+ def devise_mapping
65
+ ::Devise.mappings[:user]
66
+ end
63
67
  end
64
68
  end
65
69
  end
@@ -35,6 +35,7 @@ module Decidim
35
35
  ActionLog
36
36
  .where(visibility: %w(public-only all))
37
37
  .where(organization: current_organization)
38
+ .order(created_at: :desc)
38
39
  end
39
40
 
40
41
  def default_filter_params
@@ -15,7 +15,8 @@ module Decidim
15
15
  end
16
16
 
17
17
  def resource_text
18
- resource.body
18
+ return resource.body if resource.respond_to? :body
19
+ return resource.description if resource.respond_to? :description
19
20
  end
20
21
 
21
22
  def resource_type
@@ -14,7 +14,7 @@ module Decidim
14
14
  attribute :email
15
15
  attribute :password
16
16
  attribute :password_confirmation
17
- attribute :avatar
17
+ attribute :avatar, Decidim::Attributes::Blob
18
18
  attribute :remove_avatar, Boolean, default: false
19
19
  attribute :personal_url
20
20
  attribute :about
@@ -10,7 +10,7 @@ module Decidim
10
10
  attribute :name
11
11
  attribute :nickname
12
12
  attribute :email
13
- attribute :avatar
13
+ attribute :avatar, Decidim::Attributes::Blob
14
14
  attribute :about
15
15
  attribute :document_number
16
16
  attribute :phone
@@ -24,7 +24,11 @@ module Decidim
24
24
  remote: true,
25
25
  html: { id: nil }.merge(html_options)
26
26
  ) do |form|
27
- yield form
27
+ # Cannot use `concat()` here because it's not available in cells
28
+ inner = []
29
+ inner << hidden_field_tag("per_page", params[:per_page], id: nil) if params[:per_page]
30
+ inner << capture { yield form }
31
+ inner.join.html_safe
28
32
  end
29
33
  end
30
34
  end
@@ -16,13 +16,18 @@ module Decidim
16
16
  #
17
17
  # Returns an HTML-safe String.
18
18
  def decidim_sanitize(html, options = {})
19
+ scrubber = options[:scrubber] || Decidim::UserInputScrubber.new
19
20
  if options[:strip_tags]
20
- strip_tags sanitize(html, scrubber: Decidim::UserInputScrubber.new)
21
+ strip_tags sanitize(html, scrubber: scrubber)
21
22
  else
22
- sanitize(html, scrubber: Decidim::UserInputScrubber.new)
23
+ sanitize(html, scrubber: scrubber)
23
24
  end
24
25
  end
25
26
 
27
+ def decidim_sanitize_admin(html, options = {})
28
+ decidim_sanitize(html, { scrubber: Decidim::AdminInputScrubber.new }.merge(options))
29
+ end
30
+
26
31
  def decidim_sanitize_newsletter(html, options = {})
27
32
  if options[:strip_tags]
28
33
  strip_tags sanitize(html, scrubber: Decidim::NewsletterScrubber.new)
@@ -32,10 +37,14 @@ module Decidim
32
37
  end
33
38
 
34
39
  def decidim_sanitize_editor(html, options = {})
35
- html = Decidim::IframeDisabler.new(html, options).perform
36
40
  content_tag(:div, decidim_sanitize(html, options), class: %w(ql-editor ql-reset-decidim))
37
41
  end
38
42
 
43
+ def decidim_sanitize_editor_admin(html, options = {})
44
+ html = Decidim::IframeDisabler.new(html, options).perform
45
+ decidim_sanitize_editor(html, { scrubber: Decidim::AdminInputScrubber.new }.merge(options))
46
+ end
47
+
39
48
  def decidim_html_escape(text)
40
49
  ERB::Util.unwrapped_html_escape(text.to_str)
41
50
  end
@@ -214,16 +214,16 @@ module Decidim
214
214
  end
215
215
 
216
216
  # Whether this activity or log is visible for a given user (can also be nil)
217
- #
218
- # Returns a True/False.
219
217
  def visible_for?(user)
220
- return false if resource_lazy.blank?
221
- return false if participatory_space_lazy.blank?
222
- return false if resource_lazy.respond_to?(:deleted?) && resource_lazy.deleted?
223
- return false if resource_lazy.respond_to?(:hidden?) && resource_lazy.hidden?
224
- return false if resource_lazy.respond_to?(:can_participate?) && !resource_lazy.can_participate?(user)
225
-
226
- true
218
+ resource_lazy.present? &&
219
+ participatory_space_lazy.present? &&
220
+ !resource_lazy.try(:deleted?) &&
221
+ !resource_lazy.try(:hidden?) &&
222
+ (!resource_lazy.respond_to?(:can_participate?) || resource_lazy.try(:can_participate?, user))
223
+ rescue NameError => e
224
+ Rails.logger.warn "Failed resource for #{self.class.name}(id=#{id}): #{e.message}"
225
+
226
+ false
227
227
  end
228
228
  end
229
229
  end
@@ -7,8 +7,17 @@ module Decidim
7
7
  belongs_to :resource, foreign_key: "decidim_resource_id", foreign_type: "decidim_resource_type", polymorphic: true
8
8
  belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User"
9
9
 
10
- scope :daily, ->(time: Time.now.utc - 1.day) { where(created_at: time.all_day) }
11
- scope :weekly, ->(time: Time.now.utc) { where(created_at: (time - 7.days)..time) }
10
+ # Daily notifications should contain all notifications within the previous
11
+ # day from the given day.
12
+ scope :daily, ->(time: Time.now.utc) { where(created_at: (time - 1.day).all_day) }
13
+
14
+ # Weekly notifications should contain all notifications within the previous
15
+ # week counting from the end of the previous day until the start of the day
16
+ # 1 week ago from the previous day.
17
+ scope :weekly, lambda { |time: Time.now.utc|
18
+ end_of_previous_day = (time - 1.day).end_of_day
19
+ where(created_at: (end_of_previous_day - 7.days).beginning_of_day..end_of_previous_day)
20
+ }
12
21
 
13
22
  def event_class_instance
14
23
  @event_class_instance ||= event_class.constantize.new(
@@ -30,6 +30,7 @@ module Decidim
30
30
 
31
31
  scope :blocked, -> { where(blocked: true) }
32
32
  scope :not_blocked, -> { where(blocked: false) }
33
+ scope :available, -> { where(deleted_at: nil, blocked: false, managed: false) }
33
34
 
34
35
  # Public: Returns a collection with all the public entities this user is following.
35
36
  #
@@ -58,7 +58,7 @@ import "src/decidim/identity_selector_dialog"
58
58
  import "src/decidim/gallery"
59
59
  import "src/decidim/direct_uploads/upload_field"
60
60
  import "src/decidim/back_to_list"
61
- import "src/decidim/cookie_consent/cookie_consent"
61
+ import "src/decidim/data_consent"
62
62
 
63
63
  // CSS
64
64
  import "entrypoints/decidim_core.scss"
@@ -1,27 +1,77 @@
1
+ /**
2
+ * Initializes the edit account form to control the password field elements
3
+ * which should only be required when they are visible.
4
+ *
5
+ * @returns {void}
6
+ */
7
+ const initializeAccountForm = () => {
8
+ const editUserForm = document.querySelector("form.edit_user");
9
+ if (!editUserForm) {
10
+ return;
11
+ }
12
+
13
+ const passwordChange = editUserForm.querySelector("#passwordChange");
14
+ if (!passwordChange) {
15
+ return;
16
+ }
17
+
18
+ const passwordFields = passwordChange.querySelectorAll("input[type='password']");
19
+ if (passwordFields.length < 1) {
20
+ return;
21
+ }
22
+
23
+ // Foundation uses jQuery so these have to be bound using jQuery and the
24
+ // attribute value needs to be set through jQuery.
25
+ const togglePasswordFieldValidators = (enabled) => {
26
+ $(passwordFields).attr("required", enabled);
27
+
28
+ if (!enabled) {
29
+ passwordFields.forEach((field) => (field.value = ""));
30
+ }
31
+ }
32
+
33
+ $(passwordChange).on("on.zf.toggler", () => {
34
+ togglePasswordFieldValidators(true);
35
+ });
36
+ $(passwordChange).on("off.zf.toggler", () => {
37
+ togglePasswordFieldValidators(false);
38
+ });
39
+ togglePasswordFieldValidators(false);
40
+ };
41
+
1
42
  /**
2
43
  * Since the delete account has a modal to confirm it we need to copy the content of the
3
44
  * reason field to the hidden field in the form inside the modal.
45
+ *
46
+ * @return {void}
4
47
  */
5
- $(() => {
48
+ const initializeDeleteAccount = () => {
6
49
  const $deleteAccountForm = $(".delete-account");
7
50
  const $deleteAccountModalForm = $(".delete-account-modal");
8
51
 
9
- if ($deleteAccountForm.length > 0) {
10
- const $openModalButton = $(".open-modal-button");
11
- const $modal = $("#deleteConfirm");
12
-
13
- $openModalButton.on("click", (event) => {
14
- try {
15
- const reasonValue = $deleteAccountForm.find("textarea#delete_account_delete_reason").val();
16
- $deleteAccountModalForm.find("input#delete_account_delete_reason").val(reasonValue);
17
- $modal.foundation("open");
18
- } catch (error) {
19
- console.error(error); // eslint-disable-line no-console
20
- }
21
-
22
- event.preventDefault();
23
- event.stopPropagation();
24
- return false;
25
- });
52
+ if ($deleteAccountForm.length < 1) {
53
+ return;
26
54
  }
55
+
56
+ const $openModalButton = $(".open-modal-button");
57
+ const $modal = $("#deleteConfirm");
58
+
59
+ $openModalButton.on("click", (event) => {
60
+ try {
61
+ const reasonValue = $deleteAccountForm.find("textarea#delete_account_delete_reason").val();
62
+ $deleteAccountModalForm.find("input#delete_account_delete_reason").val(reasonValue);
63
+ $modal.foundation("open");
64
+ } catch (error) {
65
+ console.error(error); // eslint-disable-line no-console
66
+ }
67
+
68
+ event.preventDefault();
69
+ event.stopPropagation();
70
+ return false;
71
+ });
72
+ };
73
+
74
+ $(() => {
75
+ initializeAccountForm();
76
+ initializeDeleteAccount();
27
77
  });