decidim-core 0.27.3 → 0.27.5

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 (137) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/activities_cell.rb +1 -7
  3. data/app/cells/decidim/collapsible_list/show.erb +1 -1
  4. data/app/cells/decidim/content_blocks/last_activity_cell.rb +1 -4
  5. data/app/cells/decidim/tags_cell.rb +13 -2
  6. data/app/cells/decidim/upload_modal/modal.erb +4 -1
  7. data/app/cells/decidim/upload_modal_cell.rb +8 -4
  8. data/app/cells/decidim/version_cell.rb +1 -1
  9. data/app/cells/decidim/versions_list_cell.rb +1 -1
  10. data/app/commands/decidim/create_omniauth_registration.rb +2 -2
  11. data/app/commands/decidim/endorse_resource.rb +2 -0
  12. data/app/commands/decidim/search.rb +1 -1
  13. data/app/commands/decidim/unendorse_resource.rb +1 -1
  14. data/app/controllers/concerns/decidim/force_authentication.rb +6 -2
  15. data/app/controllers/decidim/authorization_modals_controller.rb +1 -1
  16. data/app/controllers/decidim/devise/registrations_controller.rb +1 -1
  17. data/app/controllers/decidim/last_activities_controller.rb +1 -7
  18. data/app/controllers/decidim/links_controller.rb +1 -1
  19. data/app/controllers/decidim/searches_controller.rb +1 -1
  20. data/app/controllers/decidim/short_links_controller.rb +1 -1
  21. data/app/controllers/decidim/user_timeline_controller.rb +1 -1
  22. data/app/forms/decidim/account_form.rb +1 -1
  23. data/app/forms/decidim/notifications_settings_form.rb +1 -9
  24. data/app/forms/decidim/registration_form.rb +1 -1
  25. data/app/forms/url_validator.rb +1 -1
  26. data/app/helpers/decidim/decidim_form_helper.rb +1 -0
  27. data/app/helpers/decidim/layout_helper.rb +4 -1
  28. data/app/helpers/decidim/omniauth_helper.rb +2 -0
  29. data/app/helpers/decidim/resource_helper.rb +2 -0
  30. data/app/helpers/decidim/short_link_helper.rb +1 -1
  31. data/app/jobs/decidim/download_your_data_export_job.rb +2 -1
  32. data/app/jobs/decidim/open_data_job.rb +2 -0
  33. data/app/models/decidim/organization.rb +6 -0
  34. data/app/models/decidim/user.rb +13 -3
  35. data/app/packs/images/decidim/icons.svg +1 -1
  36. data/app/packs/images/decidim/vendor/social-share-button/x.svg +6 -0
  37. data/app/packs/src/decidim/autocomplete.js +11 -2
  38. data/app/packs/src/decidim/data_picker.js +1 -0
  39. data/app/packs/src/decidim/direct_uploads/upload_field.js +6 -4
  40. data/app/packs/src/decidim/direct_uploads/upload_modal.js +10 -8
  41. data/app/packs/src/decidim/direct_uploads/uploader.js +4 -1
  42. data/app/packs/src/decidim/geocoding/attach_input.js +4 -1
  43. data/app/packs/src/decidim/geocoding/provider/here.js +17 -21
  44. data/app/packs/src/decidim/geocoding/provider/photon.js +1 -1
  45. data/app/packs/src/decidim/input_character_counter.js +1 -1
  46. data/app/packs/src/decidim/map/controller/drag_marker.js +0 -2
  47. data/app/packs/src/decidim/map/controller/markers.js +0 -1
  48. data/app/packs/src/decidim/map/controller/static.js +0 -1
  49. data/app/packs/src/decidim/map/controller.js +0 -2
  50. data/app/packs/src/decidim/map/factory.js +4 -1
  51. data/app/packs/src/decidim/map/icon.js +0 -1
  52. data/app/packs/src/decidim/map/legacy.js +0 -1
  53. data/app/packs/src/decidim/map/provider/default.js +2 -0
  54. data/app/packs/src/decidim/map/provider/here.js +2 -1
  55. data/app/packs/src/decidim/utilities/text.js +17 -0
  56. data/app/packs/stylesheets/decidim/_variables.scss +1 -1
  57. data/app/packs/stylesheets/decidim/vendor/_social_share_button.scss +4 -0
  58. data/app/queries/decidim/last_activity.rb +96 -0
  59. data/app/queries/decidim/metrics/users_metric_manage.rb +6 -6
  60. data/app/queries/decidim/public_activities.rb +5 -57
  61. data/app/services/decidim/email_notification_generator.rb +7 -1
  62. data/app/services/decidim/send_push_notification.rb +1 -1
  63. data/app/uploaders/decidim/application_uploader.rb +2 -0
  64. data/app/views/decidim/notifications_settings/show.html.erb +1 -1
  65. data/app/views/decidim/scopes/_scopes_picker_input.html.erb +1 -1
  66. data/app/views/decidim/searches/_filters.html.erb +3 -1
  67. data/app/views/decidim/shared/_share_modal.html.erb +1 -1
  68. data/app/views/decidim/shared/participatory_space_filters/_filters.html.erb +1 -1
  69. data/app/views/layouts/decidim/_social_media_links.html.erb +2 -2
  70. data/config/environment.rb +3 -0
  71. data/config/locales/ar.yml +11 -17
  72. data/config/locales/bg.yml +8 -16
  73. data/config/locales/ca.yml +19 -14
  74. data/config/locales/cs.yml +31 -11
  75. data/config/locales/de.yml +113 -46
  76. data/config/locales/el.yml +157 -13
  77. data/config/locales/en.yml +6 -1
  78. data/config/locales/eo.yml +5 -3
  79. data/config/locales/es-MX.yml +16 -11
  80. data/config/locales/es-PY.yml +18 -13
  81. data/config/locales/es.yml +17 -12
  82. data/config/locales/eu.yml +494 -345
  83. data/config/locales/fi-plain.yml +29 -3
  84. data/config/locales/fi.yml +19 -14
  85. data/config/locales/fr-CA.yml +16 -11
  86. data/config/locales/fr.yml +17 -12
  87. data/config/locales/ga-IE.yml +9 -5
  88. data/config/locales/gl.yml +10 -20
  89. data/config/locales/hu.yml +46 -18
  90. data/config/locales/id-ID.yml +12 -19
  91. data/config/locales/is-IS.yml +7 -3
  92. data/config/locales/it.yml +14 -10
  93. data/config/locales/ja.yml +39 -21
  94. data/config/locales/kaa.yml +10 -0
  95. data/config/locales/lb.yml +16 -12
  96. data/config/locales/lt.yml +57 -9
  97. data/config/locales/lv.yml +8 -16
  98. data/config/locales/nl.yml +8 -8
  99. data/config/locales/no.yml +15 -11
  100. data/config/locales/pl.yml +24 -6
  101. data/config/locales/pt-BR.yml +164 -7
  102. data/config/locales/pt.yml +12 -8
  103. data/config/locales/ro-RO.yml +8 -7
  104. data/config/locales/ru.yml +6 -17
  105. data/config/locales/sk.yml +21 -19
  106. data/config/locales/sl.yml +0 -5
  107. data/config/locales/sq-AL.yml +1 -0
  108. data/config/locales/sr-CS.yml +8 -0
  109. data/config/locales/sv.yml +34 -16
  110. data/config/locales/th-TH.yml +1 -0
  111. data/config/locales/tr-TR.yml +21 -12
  112. data/config/locales/uk.yml +5 -14
  113. data/config/locales/zh-CN.yml +10 -7
  114. data/config/locales/zh-TW.yml +17 -9
  115. data/db/migrate/20181030090144_destroy_deleted_users_follows.rb +1 -1
  116. data/db/migrate/20181204110723_remove_following_users_count_from_users.rb +11 -2
  117. data/db/migrate/20181214101250_add_notification_types_to_users.rb +6 -1
  118. data/db/migrate/20190412131728_fix_user_names.rb +9 -2
  119. data/db/migrate/20200211173227_add_direct_message_types_to_users.rb +6 -1
  120. data/db/migrate/20210302150803_invalidate_all_sessions_for_deleted_users.rb +10 -3
  121. data/db/migrate/20210310120640_add_followable_counter_cache_to_users.rb +13 -3
  122. data/db/migrate/20231027142329_change_default_value_for_decidim_endorsements.rb +11 -0
  123. data/db/seeds.rb +5 -3
  124. data/lib/decidim/core/test/factories.rb +2 -1
  125. data/lib/decidim/core/test/shared_examples/comments_examples.rb +24 -0
  126. data/lib/decidim/core/test/shared_examples/errors.rb +2 -0
  127. data/lib/decidim/core/test/shared_examples/map_examples.rb +4 -1
  128. data/lib/decidim/core/version.rb +1 -1
  129. data/lib/decidim/core.rb +18 -1
  130. data/lib/decidim/endorsable.rb +1 -1
  131. data/lib/decidim/exporters.rb +10 -1
  132. data/lib/decidim/form_builder.rb +7 -13
  133. data/lib/decidim/has_category.rb +2 -2
  134. data/lib/tasks/upgrade/decidim_deduplicate_endorsements.rake +53 -0
  135. data/lib/tasks/upgrade/decidim_fix_short_url_resolver.rake +22 -0
  136. data/lib/tasks/upgrade/decidim_user_moderation.rake +14 -0
  137. metadata +22 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6577740d87b562e24f541c4723480ec774239f69a389d4434536ab72be3b116
4
- data.tar.gz: 8366df277375b9fadc5c96b4a9e647a0300057d7148eafcb672f3a57d3abd55f
3
+ metadata.gz: c9b09dc6caf48cd1318acfd39efaef6e9aa95ed3527ff40c3974a56f409eeff7
4
+ data.tar.gz: bb6ca8ea6d9b57a37d6793757cd8a12bbcffdf63afd27924216f67af1d8acb14
5
5
  SHA512:
6
- metadata.gz: f6f4e9e7bcf14ccc5943ec41d4468338d1cf62aec7d37b296d0fa37a3c1c7bc97711b06579d10b32167ce291b8d664989f90eecfcba9a94f228ff60e7e8698e0
7
- data.tar.gz: 4fcd0dacd12572c3a4b404709ec632dcc6c5cc964dfd9dc29d92a4dd03da2b10ddc3e5df57a6ed91cb3f90e0dac70c4668ba89040f8cf5788e34d1f8e857d3b8
6
+ metadata.gz: 4003252d8eeae3f86cb4056380f4fb7aefe8a8e97f3935e97a970513ccdd05e9d6b9ca8658b56147b7bff0e306608472e656db871eae5bbb50ab9cfc1e629d4b
7
+ data.tar.gz: ce5aec4bd84ee34b87b5b7cc3f1afb08a1e6bcc3c34ff5cf1afa87d3ded13fe012f29a6a882fead250413f64db4a9b643770ca2c0e643e186ea51bb57a2e6c87
@@ -27,13 +27,7 @@ module Decidim
27
27
  end
28
28
 
29
29
  def activities
30
- @activities ||= last_activities.select do |activity|
31
- activity.visible_for?(current_user)
32
- end
33
- end
34
-
35
- def last_activities
36
- @last_activities ||= model.map do |activity|
30
+ @activities ||= model.map do |activity|
37
31
  activity.organization_lazy
38
32
  activity.resource_lazy
39
33
  activity.participatory_space_lazy
@@ -16,7 +16,7 @@
16
16
  </span>
17
17
  </div>
18
18
  <% else %>
19
- <div class="collapsible-list <%= list_class %>">
19
+ <div class="<%= list_class %>">
20
20
  <% list.each do |element| %>
21
21
  <% if cell_name %>
22
22
  <%= cell cell_name, element, cell_options %>
@@ -56,10 +56,7 @@ module Decidim
56
56
  end
57
57
 
58
58
  def activities
59
- @activities ||= ActionLog.where(
60
- organization: current_organization,
61
- visibility: %w(public-only all)
62
- ).with_new_resource_type("all").order(created_at: :desc).limit(activities_to_show * 6)
59
+ @activities ||= Decidim::LastActivity.new(current_organization, current_user: current_user).query.limit(activities_to_show * 6)
63
60
  end
64
61
 
65
62
  def activities_to_show
@@ -55,7 +55,7 @@ module Decidim
55
55
  end
56
56
 
57
57
  def category_path
58
- resource_locator(model).index(filter: { category_id: [model.category.id.to_s] })
58
+ resource_locator(model).index(filter: { filter_param(:category) => [model.category.id.to_s] })
59
59
  end
60
60
 
61
61
  def scope?
@@ -86,7 +86,18 @@ module Decidim
86
86
  end
87
87
 
88
88
  def scope_path
89
- resource_locator(model).index(filter: { scope_id: [model.scope.id] })
89
+ resource_locator(model).index(filter: { filter_param(:scope) => [model.scope.id] })
90
+ end
91
+
92
+ def filter_param(name)
93
+ candidates = ["with_any_#{name}".to_sym, "with_#{name}".to_sym]
94
+ return candidates.first unless controller.respond_to?(:default_filter_params, true)
95
+
96
+ available_params = controller.send(:default_filter_params)
97
+ candidates.each do |candidate|
98
+ return candidate if available_params.has_key?(candidate)
99
+ end
100
+ candidates.first
90
101
  end
91
102
  end
92
103
  end
@@ -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
@@ -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
@@ -46,8 +46,6 @@ module Decidim
46
46
  attr_reader :form, :verified_email
47
47
 
48
48
  def create_or_find_user
49
- generated_password = SecureRandom.hex
50
-
51
49
  @user = User.find_or_initialize_by(
52
50
  email: verified_email,
53
51
  organization: organization
@@ -59,6 +57,8 @@ module Decidim
59
57
  # to be marked confirmed.
60
58
  @user.skip_confirmation! if !@user.confirmed? && @user.email == verified_email
61
59
  else
60
+ generated_password = SecureRandom.hex
61
+
62
62
  @user.email = (verified_email || form.email)
63
63
  @user.name = form.name
64
64
  @user.nickname = form.normalized_nickname
@@ -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
@@ -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
@@ -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
@@ -17,7 +17,7 @@ module Decidim
17
17
  end
18
18
 
19
19
  def current_component
20
- @current_component ||= Decidim::Component.find(params[:component_id])
20
+ @current_component ||= Decidim::Component.where(participatory_space: current_organization.participatory_spaces).find(params[:component_id])
21
21
  end
22
22
 
23
23
  def authorization_action
@@ -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
@@ -32,13 +32,7 @@ module Decidim
32
32
  end
33
33
 
34
34
  def search_collection
35
- ActionLog
36
- .where(
37
- organization: current_organization,
38
- visibility: %w(public-only all)
39
- )
40
- .with_new_resource_type("all")
41
- .order(created_at: :desc)
35
+ LastActivity.new(current_organization, current_user: current_user).query
42
36
  end
43
37
 
44
38
  def default_filter_params
@@ -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
 
@@ -29,7 +29,7 @@ module Decidim
29
29
  #
30
30
  # @return [Decidim::ShortLink] The short link matching the identifier
31
31
  def link
32
- @link ||= Decidim::ShortLink.find_by(identifier: params[:id])
32
+ @link ||= Decidim::ShortLink.find_by(identifier: params[:id], organization: current_organization)
33
33
  end
34
34
  end
35
35
  end
@@ -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
@@ -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,16 +44,8 @@ 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
- Rails.application.secrets.vapid[:enabled]
48
+ Rails.application.secrets.dig(:vapid, :enabled) || false
57
49
  end
58
50
  end
59
51
  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
@@ -6,7 +6,7 @@
6
6
  #
7
7
  class UrlValidator < ActiveModel::EachValidator
8
8
  def validate_each(record, attribute, value)
9
- record.errors.add attribute, (options[:message] || "must be a valid URL") unless url_valid?(value)
9
+ record.errors.add attribute, :url_format, **options unless url_valid?(value)
10
10
  end
11
11
 
12
12
  # a URL may be technically well-formed but may
@@ -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,
@@ -105,7 +105,10 @@ module Decidim
105
105
  # non-nil because otherwise it will be set to the asset host at
106
106
  # ActionView::Helpers::AssetUrlHelper#compute_asset_host.
107
107
  img_path = asset_pack_path(path, host: "", protocol: :relative)
108
- Rails.public_path.join(img_path.sub(%r{^/}, ""))
108
+ path = Rails.public_path.join(img_path.sub(%r{^/}, ""))
109
+ return unless File.exist?(path)
110
+
111
+ path
109
112
  rescue ::Webpacker::Manifest::MissingEntryError
110
113
  nil
111
114
  end
@@ -6,6 +6,8 @@ module Decidim
6
6
  # Public: normalize providers names to they can be used for buttons
7
7
  # and icons.
8
8
  def normalize_provider_name(provider)
9
+ return "x" if provider == :twitter
10
+
9
11
  provider.to_s.split("_").first
10
12
  end
11
13
 
@@ -67,6 +67,8 @@ module Decidim
67
67
 
68
68
  # Returns an instance of ResourceLocatorPresenter with the given resource
69
69
  def resource_locator(resource)
70
+ return resource.resource_locator if resource.respond_to?(:resource_locator)
71
+
70
72
  ::Decidim::ResourceLocatorPresenter.new(resource)
71
73
  end
72
74
 
@@ -21,7 +21,7 @@ module Decidim
21
21
  target ||= respond_to?(:current_organization) && current_organization
22
22
  target ||= Rails.application
23
23
 
24
- mounted_engine = EngineResolver.new(_routes).mounted_name
24
+ mounted_engine = target.try(:mounted_engine) || EngineResolver.new(_routes).mounted_name
25
25
  ShortLink.to(target, mounted_engine, **kwargs).short_url
26
26
  end
27
27
  end
@@ -11,7 +11,8 @@ module Decidim
11
11
 
12
12
  generate_zip_file(user, path, password, export_format)
13
13
  save_or_upload_file(user, path)
14
-
14
+ # Deletes temporary file
15
+ File.delete(path)
15
16
  ExportMailer.download_your_data_export(user, filename, password).deliver_later
16
17
  end
17
18
 
@@ -11,6 +11,8 @@ module Decidim
11
11
  raise "Couldn't generate Open Data export" unless exporter.export.positive?
12
12
 
13
13
  organization.open_data_file.attach(io: File.open(path, "rb"), filename: organization.open_data_file_path)
14
+ # Deletes the temporary file file
15
+ File.delete(path)
14
16
  end
15
17
  end
16
18
  end
@@ -87,6 +87,12 @@ module Decidim
87
87
  @top_scopes ||= scopes.top_level
88
88
  end
89
89
 
90
+ def participatory_spaces
91
+ @participatory_spaces ||= Decidim.participatory_space_manifests.flat_map do |manifest|
92
+ manifest.participatory_spaces.call(self)
93
+ end
94
+ end
95
+
90
96
  def public_participatory_spaces
91
97
  @public_participatory_spaces ||= Decidim.participatory_space_manifests.flat_map do |manifest|
92
98
  manifest.participatory_spaces.call(self).public_spaces
@@ -205,7 +205,7 @@ module Decidim
205
205
  end
206
206
 
207
207
  def admin_terms_accepted?
208
- return true if admin_terms_accepted_at
208
+ admin_terms_accepted_at.present?
209
209
  end
210
210
 
211
211
  # Whether this user can be verified against some authorization or not.
@@ -261,13 +261,22 @@ module Decidim
261
261
  end
262
262
 
263
263
  def needs_password_update?
264
+ return false if organization.users_registration_mode == "disabled"
264
265
  return false unless admin?
265
266
  return false unless Decidim.config.admin_password_strong
266
- return true if password_updated_at.blank?
267
+ return identities.none? if password_updated_at.blank?
267
268
 
268
269
  password_updated_at < Decidim.config.admin_password_expiration_days.days.ago
269
270
  end
270
271
 
272
+ def moderator?
273
+ Decidim.participatory_space_manifests.map do |manifest|
274
+ participatory_space_type = manifest.model_class_name.constantize
275
+ return true if participatory_space_type.moderators(organization).exists?(id: id)
276
+ end
277
+ false
278
+ end
279
+
271
280
  protected
272
281
 
273
282
  # Overrides devise email required validation.
@@ -293,7 +302,8 @@ module Decidim
293
302
  event: "decidim.events.core.welcome_notification",
294
303
  event_class: WelcomeNotificationEvent,
295
304
  resource: self,
296
- affected_users: [self]
305
+ affected_users: [self],
306
+ extra: { force_email: true }
297
307
  )
298
308
  end
299
309