decidim-core 0.27.4 → 0.27.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.
Files changed (168) 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/scopes_picker/scope_picker_values.erb +1 -1
  7. data/app/cells/decidim/tags_cell.rb +3 -1
  8. data/app/cells/decidim/upload_modal/modal.erb +4 -1
  9. data/app/cells/decidim/upload_modal_cell.rb +8 -4
  10. data/app/cells/decidim/user_profile_cell.rb +1 -1
  11. data/app/cells/decidim/version_cell.rb +1 -1
  12. data/app/cells/decidim/versions_list_cell.rb +1 -1
  13. data/app/commands/decidim/create_omniauth_registration.rb +2 -4
  14. data/app/commands/decidim/endorse_resource.rb +2 -0
  15. data/app/commands/decidim/messaging/reply_to_conversation.rb +3 -0
  16. data/app/commands/decidim/messaging/start_conversation.rb +3 -0
  17. data/app/commands/decidim/search.rb +1 -1
  18. data/app/commands/decidim/unendorse_resource.rb +1 -1
  19. data/app/controllers/concerns/decidim/devise_authentication_methods.rb +36 -0
  20. data/app/controllers/concerns/decidim/force_authentication.rb +6 -2
  21. data/app/controllers/concerns/decidim/paginable.rb +1 -1
  22. data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +1 -22
  23. data/app/controllers/decidim/devise/registrations_controller.rb +1 -1
  24. data/app/controllers/decidim/devise/sessions_controller.rb +1 -24
  25. data/app/controllers/decidim/links_controller.rb +1 -1
  26. data/app/controllers/decidim/searches_controller.rb +1 -1
  27. data/app/controllers/decidim/user_timeline_controller.rb +1 -1
  28. data/app/controllers/decidim/widgets_controller.rb +6 -0
  29. data/app/events/decidim/welcome_notification_event.rb +6 -9
  30. data/app/forms/decidim/account_form.rb +1 -1
  31. data/app/forms/decidim/notifications_settings_form.rb +0 -8
  32. data/app/forms/decidim/registration_form.rb +1 -1
  33. data/app/helpers/decidim/cells_paginate_helper.rb +1 -1
  34. data/app/helpers/decidim/check_boxes_tree_helper.rb +4 -4
  35. data/app/helpers/decidim/decidim_form_helper.rb +1 -0
  36. data/app/helpers/decidim/newsletters_helper.rb +83 -16
  37. data/app/helpers/decidim/omniauth_helper.rb +2 -0
  38. data/app/helpers/decidim/resource_helper.rb +3 -1
  39. data/app/helpers/decidim/sanitize_helper.rb +9 -0
  40. data/app/helpers/decidim/short_link_helper.rb +1 -1
  41. data/app/helpers/decidim/user_profile_helper.rb +7 -2
  42. data/app/jobs/decidim/download_your_data_export_job.rb +2 -1
  43. data/app/jobs/decidim/open_data_job.rb +2 -0
  44. data/app/mailers/decidim/messaging/conversation_mailer.rb +3 -72
  45. data/app/models/decidim/push_notification_message.rb +39 -0
  46. data/app/models/decidim/user.rb +9 -1
  47. data/app/packs/images/decidim/icons.svg +1 -1
  48. data/app/packs/images/decidim/vendor/social-share-button/x.svg +6 -0
  49. data/app/packs/src/decidim/autocomplete.js +11 -2
  50. data/app/packs/src/decidim/data_picker.js +1 -0
  51. data/app/packs/src/decidim/direct_uploads/upload_field.js +6 -4
  52. data/app/packs/src/decidim/direct_uploads/upload_modal.js +10 -8
  53. data/app/packs/src/decidim/direct_uploads/uploader.js +4 -1
  54. data/app/packs/src/decidim/geocoding/attach_input.js +4 -1
  55. data/app/packs/src/decidim/geocoding/provider/here.js +17 -21
  56. data/app/packs/src/decidim/geocoding/provider/photon.js +1 -1
  57. data/app/packs/src/decidim/input_hashtags.js +1 -1
  58. data/app/packs/src/decidim/input_mentions.js +1 -1
  59. data/app/packs/src/decidim/input_multiple_mentions.js +1 -1
  60. data/app/packs/src/decidim/utilities/text.js +17 -0
  61. data/app/packs/src/decidim/vizzs/index.js +1 -1
  62. data/app/packs/stylesheets/decidim/_variables.scss +1 -1
  63. data/app/packs/stylesheets/decidim/plugins/leaflet.scss +118 -114
  64. data/app/packs/stylesheets/decidim/vendor/_social_share_button.scss +4 -0
  65. data/app/presenters/decidim/admin_log/oauth_application_resource_presenter.rb +1 -1
  66. data/app/presenters/decidim/notification_to_mailer_presenter.rb +9 -0
  67. data/app/services/decidim/events_manager.rb +6 -0
  68. data/app/services/decidim/push_notification_message_sender.rb +36 -0
  69. data/app/services/decidim/send_push_notification.rb +22 -8
  70. data/app/views/decidim/devise/registrations/new.html.erb +2 -2
  71. data/app/views/decidim/notifications_digest_mailer/_email_content.html.erb +7 -0
  72. data/app/views/decidim/notifications_settings/show.html.erb +1 -1
  73. data/app/views/decidim/scopes/_scopes_picker_input.html.erb +1 -1
  74. data/app/views/decidim/searches/_filters.html.erb +3 -1
  75. data/app/views/decidim/shared/_address_details.html.erb +2 -2
  76. data/app/views/decidim/shared/_share_modal.html.erb +1 -1
  77. data/app/views/decidim/shared/participatory_space_filters/_filters.html.erb +1 -1
  78. data/app/views/layouts/decidim/_js_configuration.html.erb +1 -0
  79. data/app/views/layouts/decidim/_social_media_links.html.erb +2 -2
  80. data/config/locales/ar.yml +12 -16
  81. data/config/locales/bg.yml +77 -15
  82. data/config/locales/ca.yml +34 -30
  83. data/config/locales/cs.yml +18 -14
  84. data/config/locales/de.yml +62 -58
  85. data/config/locales/el.yml +11 -16
  86. data/config/locales/en.yml +5 -1
  87. data/config/locales/eo.yml +2 -3
  88. data/config/locales/es-MX.yml +15 -11
  89. data/config/locales/es-PY.yml +15 -11
  90. data/config/locales/es.yml +30 -26
  91. data/config/locales/eu.yml +500 -342
  92. data/config/locales/fi-plain.yml +7 -3
  93. data/config/locales/fi.yml +21 -17
  94. data/config/locales/fr-CA.yml +17 -13
  95. data/config/locales/fr.yml +12 -8
  96. data/config/locales/ga-IE.yml +5 -5
  97. data/config/locales/gl.yml +5 -19
  98. data/config/locales/he-IL.yml +1 -0
  99. data/config/locales/hu.yml +63 -23
  100. data/config/locales/id-ID.yml +4 -19
  101. data/config/locales/is-IS.yml +4 -2
  102. data/config/locales/it.yml +15 -17
  103. data/config/locales/ja.yml +26 -22
  104. data/config/locales/lb.yml +15 -17
  105. data/config/locales/lt.yml +55 -10
  106. data/config/locales/lv.yml +4 -16
  107. data/config/locales/nl.yml +12 -12
  108. data/config/locales/no.yml +8 -10
  109. data/config/locales/pl.yml +151 -1
  110. data/config/locales/pt-BR.yml +267 -22
  111. data/config/locales/pt.yml +8 -10
  112. data/config/locales/ro-RO.yml +4 -10
  113. data/config/locales/ru.yml +13 -17
  114. data/config/locales/sk.yml +7 -17
  115. data/config/locales/sl.yml +0 -5
  116. data/config/locales/sq-AL.yml +1 -0
  117. data/config/locales/sv.yml +55 -17
  118. data/config/locales/th-TH.yml +1 -0
  119. data/config/locales/tr-TR.yml +18 -15
  120. data/config/locales/uk.yml +17 -14
  121. data/config/locales/zh-CN.yml +6 -10
  122. data/config/locales/zh-TW.yml +0 -9
  123. data/db/migrate/20231027142329_change_default_value_for_decidim_endorsements.rb +11 -0
  124. data/db/seeds.rb +1 -0
  125. data/decidim-core.gemspec +78 -0
  126. data/lib/decidim/acts_as_tree.rb +14 -1
  127. data/lib/decidim/asset_router/storage.rb +4 -0
  128. data/lib/decidim/attribute_encryptor.rb +6 -4
  129. data/lib/decidim/core/engine.rb +7 -3
  130. data/lib/decidim/core/test/factories.rb +309 -95
  131. data/lib/decidim/core/test/shared_examples/amendable/amendment_created_event_examples.rb +6 -26
  132. data/lib/decidim/core/test/shared_examples/amendable/amendment_promoted_event_examples.rb +8 -26
  133. data/lib/decidim/core/test/shared_examples/comments_examples.rb +56 -0
  134. data/lib/decidim/core/test/shared_examples/embed_resource_examples.rb +187 -11
  135. data/lib/decidim/core/test/shared_examples/errors.rb +2 -0
  136. data/lib/decidim/core/test/shared_examples/has_attachment_collections.rb +8 -6
  137. data/lib/decidim/core/test/shared_examples/has_attachments.rb +4 -4
  138. data/lib/decidim/core/test/shared_examples/has_category.rb +27 -0
  139. data/lib/decidim/core/test/shared_examples/has_reference.rb +1 -1
  140. data/lib/decidim/core/test/shared_examples/has_space_in_mcell_examples.rb +1 -2
  141. data/lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb +6 -3
  142. data/lib/decidim/core/test/shared_examples/resource_locator_presenter_examples.rb +134 -0
  143. data/lib/decidim/core/test/shared_examples/searchable_results_examples.rb +1 -1
  144. data/lib/decidim/core/test/shared_examples/simple_event.rb +50 -2
  145. data/lib/decidim/core/test.rb +1 -0
  146. data/lib/decidim/core/version.rb +1 -1
  147. data/lib/decidim/core.rb +2 -1
  148. data/lib/decidim/endorsable.rb +1 -1
  149. data/lib/decidim/engine_router.rb +17 -4
  150. data/lib/decidim/events/base_event.rb +5 -2
  151. data/lib/decidim/events/simple_event.rb +3 -17
  152. data/lib/decidim/exporters.rb +10 -1
  153. data/lib/decidim/form_builder.rb +1 -0
  154. data/lib/decidim/has_category.rb +3 -3
  155. data/lib/decidim/has_conversations.rb +91 -0
  156. data/lib/decidim/participable.rb +17 -0
  157. data/lib/decidim/view_model.rb +1 -0
  158. data/lib/decidim/webpacker/webpack/.modernizrrc +9 -0
  159. data/lib/premailer/adapter/decidim.rb +5 -4
  160. data/lib/tasks/decidim_reminders_tasks.rake +1 -0
  161. data/lib/tasks/upgrade/decidim_deduplicate_endorsements.rake +53 -0
  162. data/lib/tasks/upgrade/decidim_fix_categorization.rake +15 -0
  163. data/lib/tasks/upgrade/decidim_fix_short_url_resolver.rake +22 -0
  164. metadata +37 -32
  165. data/app/helpers/decidim/layout_helper.rb.orig +0 -225
  166. data/app/packs/stylesheets/decidim/modules/_dropdown_menu.scss +0 -9
  167. data/app/views/decidim/devise/registrations/new.html.erb.orig +0 -231
  168. /data/{config/environment.rb → app/packs/images/decidim/.keep} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d976829c2218ab34a1bf7c2ad99443edd61c4f37bb56963c8bb21a3e74afddef
4
- data.tar.gz: acbaa2ce577af7e32648ce22941616e258f48bdbfb304e754344770fafaf9ef4
3
+ metadata.gz: 99119ce695e1aa34d4a744deca10b822209b52253058e77548a6399cd78f0069
4
+ data.tar.gz: '052746495077e884e4cb8e5bc33c8bcb6af257efbee57b385b39f62404530fd5'
5
5
  SHA512:
6
- metadata.gz: 868d324e0f83442b37750933c39985dffdba9bfd06a2f47ad00836b7c9b89164bafff5d2083d5e24d7f01eb9c47dac46f564a375bacaa17726fe5d472bf6c86b
7
- data.tar.gz: 1af449d8a281aa2ae5db6c0f03a7be077f7a7eeaa2a300e8bc2a2d36622cd4be5aafb4245878a24e4bd2496542d0166a84287974e72cdeb294acdcd021144b00
6
+ metadata.gz: e5b7a3d7779697415e7ec9badd7d4d00bd408a1f42e7c667f01b797558ba22524231273b94f3f6beeb644f7aee8692bd5d2d580a7493c84dfaa5eb563241bc58
7
+ data.tar.gz: 193b200909cc1fa784ccad5583b3c9593b8e6a9be31c10ab03c90ee9153075ac0d168566e7fe275bb9140c1bc53a8a42e58f84ffc9b852fe91269deef496d5a3
@@ -38,9 +38,9 @@ module Decidim
38
38
 
39
39
  case resource_title
40
40
  when String
41
- resource_title
41
+ decidim_html_escape(resource_title)
42
42
  when Hash
43
- translated_attribute(resource_title)
43
+ decidim_escape_translated(resource_title)
44
44
  end
45
45
  end
46
46
 
@@ -28,11 +28,11 @@ module Decidim
28
28
  end
29
29
 
30
30
  def title
31
- model.try(:title) || model.try(:name) || ""
31
+ decidim_escape_translated(model.try(:title) || model.try(:name) || "")
32
32
  end
33
33
 
34
34
  def body
35
- model.try(:body) || model.try(:about) || ""
35
+ decidim_escape_translated(model.try(:body) || model.try(:about) || "")
36
36
  end
37
37
 
38
38
  def resource_manifest
@@ -1,7 +1,7 @@
1
1
  <div class="card__top">
2
2
  <% if render_space? %>
3
3
  <div class="card__content text-small">
4
- <span class="muted"><%= searchable_resource_human_name(model.participatory_space.class, count: 1) %>:</span>&nbsp;<%= link_to translated_attribute(model.participatory_space.title), Decidim::ResourceLocatorPresenter.new(model.participatory_space).path, class: "card__link text-ellipsis" %>
4
+ <span class="muted"><%= searchable_resource_human_name(model.participatory_space.class, count: 1) %>:</span>&nbsp;<%= link_to decidim_escape_translated(model.participatory_space.title), Decidim::ResourceLocatorPresenter.new(model.participatory_space).path, class: "card__link text-ellipsis" %>
5
5
  </div>
6
6
  <% end %>
7
7
  </div>
@@ -57,7 +57,7 @@ module Decidim
57
57
  end
58
58
 
59
59
  def title
60
- decidim_html_escape(translated_attribute(model.title))
60
+ decidim_escape_translated(model.title)
61
61
  end
62
62
 
63
63
  def description
@@ -1,5 +1,5 @@
1
1
  <div class="picker-values">
2
2
  <%- scopes.each do |scope, params| %>
3
- <div><%= link_to params[:text], params[:url], data: { picker_value: scope.id } %></div>
3
+ <div><%= link_to decidim_html_escape(params[:text]), params[:url], data: { picker_value: scope.id } %></div>
4
4
  <% end %>
5
5
  </div>
@@ -9,6 +9,8 @@ module Decidim
9
9
  # <%= cell("decidim/category", model.category, context: {resource: model}) %>
10
10
  #
11
11
  class TagsCell < Decidim::ViewModel
12
+ include Decidim::SanitizeHelper
13
+
12
14
  def show
13
15
  render if category? || scope?
14
16
  end
@@ -51,7 +53,7 @@ module Decidim
51
53
  end
52
54
 
53
55
  def category_name
54
- model.category.translated_name
56
+ decidim_html_escape model.category.translated_name
55
57
  end
56
58
 
57
59
  def category_path
@@ -35,7 +35,10 @@
35
35
  label: false,
36
36
  multiple: true,
37
37
  direct_upload: true,
38
- data: { direct_upload_url: direct_upload_url } %>
38
+ data: {
39
+ direct_upload_url: direct_upload_url,
40
+ upload_validations_url: upload_validations_url
41
+ } %>
39
42
  <span><%= t("decidim.forms.upload_help.dropzone") %></span>
40
43
  </label>
41
44
  </div>
@@ -156,15 +156,15 @@ module Decidim
156
156
  end
157
157
 
158
158
  def truncated_file_name_for(attachment, max_length = 31)
159
- filename = file_name_for(attachment)
160
- return filename if filename.length <= max_length
159
+ filename = determine_filename(attachment)
160
+ return decidim_html_escape(filename).html_safe if filename.length <= max_length
161
161
 
162
162
  name = File.basename(filename, File.extname(filename))
163
- name.truncate(max_length, omission: "...#{name.last((max_length / 2) - 3)}#{File.extname(filename)}")
163
+ decidim_html_escape(name.truncate(max_length, omission: "...#{name.last((max_length / 2) - 3)}#{File.extname(filename)}")).html_safe
164
164
  end
165
165
 
166
166
  def file_name_for(attachment)
167
- determine_filename(attachment)
167
+ decidim_html_escape(determine_filename(attachment)).html_safe
168
168
  end
169
169
 
170
170
  def determine_filename(attachment)
@@ -205,6 +205,10 @@ module Decidim
205
205
  Rails.application.class.routes.url_helpers.rails_direct_uploads_path
206
206
  end
207
207
 
208
+ def upload_validations_url
209
+ Decidim::Core::Engine.routes.url_helpers.upload_validations_path
210
+ end
211
+
208
212
  def form_object_class
209
213
  form.object.class.to_s
210
214
  end
@@ -29,7 +29,7 @@ module Decidim
29
29
  delegate :badge, to: :presented_resource
30
30
 
31
31
  def description
32
- html_truncate(decidim_html_escape(user.about.to_s), length: 100)
32
+ html_truncate(decidim_escape_translated(user.about), length: 100)
33
33
  end
34
34
 
35
35
  def avatar
@@ -66,7 +66,7 @@ module Decidim
66
66
  end
67
67
 
68
68
  def resource_path
69
- resource_locator(versioned_resource).path
69
+ Decidim::ResourceLocatorPresenter.new(versioned_resource).path
70
70
  end
71
71
  end
72
72
  end
@@ -13,7 +13,7 @@ module Decidim
13
13
  end
14
14
 
15
15
  def resource_path
16
- resource_locator(versioned_resource).path
16
+ Decidim::ResourceLocatorPresenter.new(versioned_resource).path
17
17
  end
18
18
 
19
19
  def i18n_changes_title
@@ -57,14 +57,12 @@ module Decidim
57
57
  # to be marked confirmed.
58
58
  @user.skip_confirmation! if !@user.confirmed? && @user.email == verified_email
59
59
  else
60
- generated_password = SecureRandom.hex
61
-
62
60
  @user.email = (verified_email || form.email)
63
61
  @user.name = form.name
64
62
  @user.nickname = form.normalized_nickname
65
63
  @user.newsletter_notifications_at = nil
66
- @user.password = generated_password
67
- @user.password_confirmation = generated_password
64
+ @user.password = SecureRandom.hex
65
+ @user.password_confirmation = @user.password
68
66
  if form.avatar_url.present?
69
67
  url = URI.parse(form.avatar_url)
70
68
  filename = File.basename(url.path)
@@ -31,6 +31,8 @@ module Decidim
31
31
  else
32
32
  broadcast(:invalid)
33
33
  end
34
+ rescue ActiveRecord::RecordNotUnique
35
+ broadcast(:invalid)
34
36
  end
35
37
 
36
38
  private
@@ -54,11 +54,13 @@ module Decidim
54
54
  notify(manager) do
55
55
  ConversationMailer.new_group_message(sender, manager, conversation, message, recipient).deliver_later
56
56
  end
57
+ Decidim::PushNotificationMessageSender.new.new_group_message(sender, manager, conversation, message, recipient).deliver
57
58
  end
58
59
  else
59
60
  notify(recipient) do
60
61
  ConversationMailer.new_message(sender, recipient, conversation, message).deliver_later
61
62
  end
63
+ Decidim::PushNotificationMessageSender.new.new_message(sender, recipient, conversation, message).deliver
62
64
  end
63
65
  end
64
66
  end
@@ -68,6 +70,7 @@ module Decidim
68
70
  notify(recipient) do
69
71
  ConversationMailer.comanagers_new_message(sender, recipient, conversation, message, form.context.current_user).deliver_later
70
72
  end
73
+ Decidim::PushNotificationMessageSender.new.comanagers_new_message(sender, recipient, conversation, message, form.context.current_user).deliver
71
74
  end
72
75
  end
73
76
 
@@ -54,11 +54,13 @@ module Decidim
54
54
  notify(manager) do
55
55
  ConversationMailer.new_group_conversation(originator, manager, conversation, recipient).deliver_later
56
56
  end
57
+ Decidim::PushNotificationMessageSender.new.new_group_conversation(originator, manager, conversation, recipient).deliver
57
58
  end
58
59
  else
59
60
  notify(recipient) do
60
61
  ConversationMailer.new_conversation(originator, recipient, conversation).deliver_later
61
62
  end
63
+ Decidim::PushNotificationMessageSender.new.new_conversation(originator, recipient, conversation).deliver
62
64
  end
63
65
  end
64
66
  end
@@ -68,6 +70,7 @@ module Decidim
68
70
  notify(recipient) do
69
71
  ConversationMailer.comanagers_new_conversation(originator, recipient, conversation, form.context.current_user).deliver_later
70
72
  end
73
+ Decidim::PushNotificationMessageSender.new.comanagers_new_conversation(originator, recipient, conversation, form.context.current_user).deliver
71
74
  end
72
75
  end
73
76
 
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  # A command that will act as a search service, with all the business logic for performing searches.
5
5
  class Search < Decidim::Command
6
- ACCEPTED_FILTERS = [:decidim_scope_id_eq].freeze
6
+ ACCEPTED_FILTERS = [:decidim_scope_id_in].freeze
7
7
  HIGHLIGHTED_RESULTS_COUNT = 4
8
8
 
9
9
  # Public: Initializes the command.
@@ -31,7 +31,7 @@ module Decidim
31
31
  query = if @current_group.present?
32
32
  @resource.endorsements.where(decidim_user_group_id: @current_group&.id)
33
33
  else
34
- @resource.endorsements.where(author: @current_user, decidim_user_group_id: nil)
34
+ @resource.endorsements.where(author: @current_user, decidim_user_group_id: 0)
35
35
  end
36
36
  query.destroy_all
37
37
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/concern"
4
+
5
+ module Decidim
6
+ module DeviseAuthenticationMethods
7
+ extend ActiveSupport::Concern
8
+ include Decidim::UserBlockedChecker
9
+
10
+ included do
11
+ def after_sign_in_path_for(user)
12
+ if user.present? && user.blocked?
13
+ check_user_block_status(user)
14
+ elsif user.needs_password_update?
15
+ change_password_path
16
+ elsif first_login_and_not_authorized?(user) && !user.admin? && !pending_redirect?(user)
17
+ decidim_verifications.first_login_authorizations_path
18
+ else
19
+ super
20
+ end
21
+ end
22
+
23
+ # Calling the `stored_location_for` method removes the key, so in order
24
+ # to check if there is any pending redirect after login I need to call
25
+ # this method and use the value to set a pending redirect. This is the
26
+ # only way to do this without checking the session directly.
27
+ def pending_redirect?(user)
28
+ store_location_for(user, stored_location_for(user))
29
+ end
30
+
31
+ def first_login_and_not_authorized?(user)
32
+ user.is_a?(User) && user.sign_in_count == 1 && current_organization.available_authorizations.any? && user.verifiable?
33
+ end
34
+ end
35
+ end
36
+ end
@@ -35,11 +35,15 @@ module Decidim
35
35
  end
36
36
 
37
37
  def unauthorized_paths
38
- # /locale is for changing the locale
39
- %w(/locale) + Decidim::StaticPage.where(
38
+ default_unauthorized_paths + Decidim::StaticPage.where(
40
39
  organization: current_organization,
41
40
  allow_public_access: true
42
41
  ).pluck(Arel.sql("CONCAT('/pages/', slug)"))
43
42
  end
43
+
44
+ def default_unauthorized_paths
45
+ # /locale is for changing the locale and /manifest.webmanifest to request PWA manifest
46
+ %w(/locale /manifest.webmanifest)
47
+ end
44
48
  end
45
49
  end
@@ -19,7 +19,7 @@ module Decidim
19
19
 
20
20
  def per_page
21
21
  if OPTIONS.include?(params[:per_page])
22
- params[:per_page]
22
+ params[:per_page].to_i
23
23
  elsif params[:per_page]
24
24
  sorted = OPTIONS.sort
25
25
  params[:per_page].to_i.clamp(sorted.first, sorted.last)
@@ -6,6 +6,7 @@ module Decidim
6
6
  class OmniauthRegistrationsController < ::Devise::OmniauthCallbacksController
7
7
  include FormFactory
8
8
  include Decidim::DeviseControllers
9
+ include Decidim::DeviseAuthenticationMethods
9
10
 
10
11
  def new
11
12
  @form = form(OmniauthRegistrationForm).from_params(params[:user])
@@ -45,28 +46,6 @@ module Decidim
45
46
  end
46
47
  end
47
48
 
48
- def after_sign_in_path_for(user)
49
- if user.present? && user.blocked?
50
- check_user_block_status(user)
51
- elsif !pending_redirect?(user) && first_login_and_not_authorized?(user)
52
- decidim_verifications.authorizations_path
53
- else
54
- super
55
- end
56
- end
57
-
58
- # Calling the `stored_location_for` method removes the key, so in order
59
- # to check if there's any pending redirect after login I need to call
60
- # this method and use the value to set a pending redirect. This is the
61
- # only way to do this without checking the session directly.
62
- def pending_redirect?(user)
63
- store_location_for(user, stored_location_for(user))
64
- end
65
-
66
- def first_login_and_not_authorized?(user)
67
- user.is_a?(User) && user.sign_in_count == 1 && Decidim::Verifications.workflows.any? && user.verifiable?
68
- end
69
-
70
49
  def action_missing(action_name)
71
50
  return send(:create) if devise_mapping.omniauthable? && current_organization.enabled_omniauth_providers.keys.include?(action_name.to_sym)
72
51
 
@@ -39,7 +39,7 @@ module Decidim
39
39
  end
40
40
 
41
41
  on(:invalid) do
42
- flash.now[:alert] = @form.errors.full_messages.join(", ") if @form.errors.full_messages.any?
42
+ flash.now[:alert] = t("error", scope: "decidim.devise.registrations.create")
43
43
  render :new
44
44
  end
45
45
  end
@@ -5,6 +5,7 @@ module Decidim
5
5
  # Custom Devise SessionsController to avoid namespace problems.
6
6
  class SessionsController < ::Devise::SessionsController
7
7
  include Decidim::DeviseControllers
8
+ include Decidim::DeviseAuthenticationMethods
8
9
 
9
10
  before_action :check_sign_in_enabled, only: :create
10
11
 
@@ -35,30 +36,6 @@ module Decidim
35
36
  end
36
37
  end
37
38
 
38
- def after_sign_in_path_for(user)
39
- if user.present? && user.blocked?
40
- check_user_block_status(user)
41
- elsif user.needs_password_update?
42
- change_password_path
43
- elsif first_login_and_not_authorized?(user) && !user.admin? && !pending_redirect?(user)
44
- decidim_verifications.first_login_authorizations_path
45
- else
46
- super
47
- end
48
- end
49
-
50
- # Calling the `stored_location_for` method removes the key, so in order
51
- # to check if there's any pending redirect after login I need to call
52
- # this method and use the value to set a pending redirect. This is the
53
- # only way to do this without checking the session directly.
54
- def pending_redirect?(user)
55
- store_location_for(user, stored_location_for(user))
56
- end
57
-
58
- def first_login_and_not_authorized?(user)
59
- user.is_a?(User) && user.sign_in_count == 1 && current_organization.available_authorizations.any? && user.verifiable?
60
- end
61
-
62
39
  def after_sign_out_path_for(user)
63
40
  request.referer || super
64
41
  end
@@ -35,7 +35,7 @@ module Decidim
35
35
  end
36
36
 
37
37
  def external_url
38
- @external_url ||= URI.parse(params[:external_url])
38
+ @external_url ||= URI.parse(URI::Parser.new.escape(params[:external_url]))
39
39
  end
40
40
  end
41
41
  end
@@ -26,7 +26,7 @@ module Decidim
26
26
  term: params[:term],
27
27
  with_resource_type: nil,
28
28
  with_space_state: nil,
29
- decidim_scope_id_eq: nil
29
+ decidim_scope_id_in: nil
30
30
  }
31
31
  end
32
32
 
@@ -12,7 +12,7 @@ module Decidim
12
12
  helper_method :activities, :resource_types, :user
13
13
 
14
14
  def index
15
- raise ActionController::RoutingError, "Not Found" if current_user != user
15
+ raise ActionController::RoutingError, "Not Found" unless user && current_user == user
16
16
  end
17
17
 
18
18
  private
@@ -11,6 +11,8 @@ module Decidim
11
11
  helper_method :model, :iframe_url, :current_participatory_space
12
12
 
13
13
  def show
14
+ raise ActionController::RoutingError, "Not Found" if model.nil?
15
+
14
16
  respond_to do |format|
15
17
  format.js { render "decidim/widgets/show" }
16
18
  format.html
@@ -19,6 +21,10 @@ module Decidim
19
21
 
20
22
  private
21
23
 
24
+ def current_component
25
+ @current_component ||= request.env["decidim.current_component"]
26
+ end
27
+
22
28
  def current_participatory_space
23
29
  @current_participatory_space ||= model.component.participatory_space
24
30
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "mustache"
4
-
5
3
  module Decidim
6
4
  class WelcomeNotificationEvent < Decidim::Events::BaseEvent
7
5
  include Decidim::Events::EmailEvent
@@ -46,13 +44,12 @@ module Decidim
46
44
  private
47
45
 
48
46
  def interpolate(template)
49
- Mustache.render(
50
- template.to_s,
51
- organization: organization.name,
52
- name: user.name,
53
- help_url: url_helpers.pages_url(host: organization.host),
54
- badges_url: url_helpers.gamification_badges_url(host: organization.host)
55
- ).html_safe
47
+ template
48
+ .gsub("{{name}}", user.name)
49
+ .gsub("{{organization}}", organization.name)
50
+ .gsub("{{help_url}}", url_helpers.pages_url(host: organization.host))
51
+ .gsub("{{badges_url}}", url_helpers.gamification_badges_url(host: organization.host))
52
+ .html_safe
56
53
  end
57
54
  end
58
55
  end
@@ -24,7 +24,7 @@ module Decidim
24
24
  validates :nickname, presence: true, format: { with: Decidim::User::REGEXP_NICKNAME }
25
25
 
26
26
  validates :nickname, length: { maximum: Decidim::User.nickname_max_length, allow_blank: true }
27
- validates :password, confirmation: true
27
+ validates :password, confirmation: { message: I18n.t("errors.messages.password_confirmation_message") }
28
28
  validates :password, password: { name: :name, email: :email, username: :nickname }, if: -> { password.present? }
29
29
  validates :password_confirmation, presence: true, if: :password_present
30
30
  validates :avatar, passthru: { to: Decidim::User }
@@ -44,14 +44,6 @@ module Decidim
44
44
  allow_public_contact ? "all" : "followed-only"
45
45
  end
46
46
 
47
- def user_is_moderator?(user)
48
- Decidim.participatory_space_manifests.map do |manifest|
49
- participatory_space_type = manifest.model_class_name.constantize
50
- return true if participatory_space_type.moderators(user.organization).exists?(id: user.id)
51
- end
52
- false
53
- end
54
-
55
47
  def meet_push_notifications_requirements?
56
48
  Rails.application.secrets.dig(:vapid, :enabled) || false
57
49
  end
@@ -17,7 +17,7 @@ module Decidim
17
17
  validates :name, presence: true, format: { with: Decidim::User::REGEXP_NAME }
18
18
  validates :nickname, presence: true, format: { with: Decidim::User::REGEXP_NICKNAME }, length: { maximum: Decidim::User.nickname_max_length }
19
19
  validates :email, presence: true, "valid_email_2/email": { disposable: true }
20
- validates :password, confirmation: true
20
+ validates :password, confirmation: { message: I18n.t("errors.messages.password_confirmation_message") }
21
21
  validates :password, password: { name: :name, email: :email, username: :nickname }
22
22
  validates :password_confirmation, presence: true
23
23
  validates :tos_agreement, allow_nil: false, acceptance: true
@@ -14,7 +14,7 @@ module Decidim
14
14
  end
15
15
 
16
16
  def per_page
17
- params[:per_page] || Decidim::Paginable::OPTIONS.first
17
+ params[:per_page].to_i || Decidim::Paginable::OPTIONS.first
18
18
  end
19
19
  end
20
20
  end
@@ -50,20 +50,20 @@ module Decidim
50
50
  organization = current_participatory_space.organization
51
51
 
52
52
  sorted_main_categories = current_participatory_space.categories.first_class.includes(:subcategories).sort_by do |category|
53
- [category.weight, translated_attribute(category.name, organization)]
53
+ [category.weight, decidim_html_escape(translated_attribute(category.name, organization))]
54
54
  end
55
55
 
56
56
  categories_values = sorted_main_categories.flat_map do |category|
57
57
  sorted_descendant_categories = category.descendants.includes(:subcategories).sort_by do |subcategory|
58
- [subcategory.weight, translated_attribute(subcategory.name, organization)]
58
+ [subcategory.weight, decidim_html_escape(translated_attribute(subcategory.name, organization))]
59
59
  end
60
60
 
61
61
  subcategories = sorted_descendant_categories.flat_map do |subcategory|
62
- TreePoint.new(subcategory.id.to_s, translated_attribute(subcategory.name, organization))
62
+ TreePoint.new(subcategory.id.to_s, decidim_html_escape(translated_attribute(subcategory.name, organization)))
63
63
  end
64
64
 
65
65
  TreeNode.new(
66
- TreePoint.new(category.id.to_s, translated_attribute(category.name, organization)),
66
+ TreePoint.new(category.id.to_s, decidim_html_escape(translated_attribute(category.name, organization))),
67
67
  subcategories
68
68
  )
69
69
  end
@@ -84,6 +84,7 @@ module Decidim
84
84
 
85
85
  template = ""
86
86
  template += render("decidim/scopes/scopes_picker_input",
87
+ values_options: { delete_button: false },
87
88
  picker_options: picker_options,
88
89
  prompt_params: prompt_params,
89
90
  scopes: scopes,