decidim-core 0.26.7 → 0.26.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/collapsible_list/show.erb +1 -1
  3. data/app/cells/decidim/version_cell.rb +1 -1
  4. data/app/cells/decidim/versions_list_cell.rb +1 -1
  5. data/app/commands/decidim/endorse_resource.rb +2 -0
  6. data/app/commands/decidim/unendorse_resource.rb +1 -1
  7. data/app/controllers/decidim/authorization_modals_controller.rb +1 -1
  8. data/app/controllers/decidim/devise/registrations_controller.rb +1 -1
  9. data/app/controllers/decidim/links_controller.rb +1 -1
  10. data/app/controllers/decidim/user_timeline_controller.rb +1 -1
  11. data/app/forms/decidim/account_form.rb +1 -1
  12. data/app/forms/decidim/notifications_settings_form.rb +0 -8
  13. data/app/forms/decidim/registration_form.rb +1 -1
  14. data/app/forms/url_validator.rb +1 -1
  15. data/app/helpers/decidim/layout_helper.rb +15 -4
  16. data/app/helpers/decidim/resource_helper.rb +2 -0
  17. data/app/jobs/decidim/data_portability_export_job.rb +3 -0
  18. data/app/jobs/decidim/open_data_job.rb +2 -0
  19. data/app/models/decidim/organization.rb +6 -0
  20. data/app/models/decidim/user.rb +9 -1
  21. data/app/packs/src/decidim/geocoding/attach_input.js +4 -1
  22. data/app/packs/src/decidim/geocoding/provider/here.js +17 -21
  23. data/app/packs/src/decidim/geocoding/provider/photon.js +1 -1
  24. data/app/packs/src/decidim/map/controller/drag_marker.js +0 -2
  25. data/app/packs/src/decidim/map/controller/markers.js +0 -1
  26. data/app/packs/src/decidim/map/controller/static.js +0 -1
  27. data/app/packs/src/decidim/map/controller.js +0 -2
  28. data/app/packs/src/decidim/map/factory.js +4 -1
  29. data/app/packs/src/decidim/map/icon.js +0 -1
  30. data/app/packs/src/decidim/map/legacy.js +0 -1
  31. data/app/packs/src/decidim/map/provider/default.js +2 -0
  32. data/app/packs/src/decidim/map/provider/here.js +2 -1
  33. data/app/queries/decidim/metrics/users_metric_manage.rb +6 -6
  34. data/app/views/decidim/notifications_settings/show.html.erb +1 -1
  35. data/config/environment.rb +3 -0
  36. data/config/locales/ar.yml +10 -15
  37. data/config/locales/bg.yml +0 -16
  38. data/config/locales/ca.yml +15 -11
  39. data/config/locales/cs.yml +28 -9
  40. data/config/locales/de.yml +84 -46
  41. data/config/locales/el.yml +106 -12
  42. data/config/locales/en.yml +4 -0
  43. data/config/locales/eo.yml +5 -3
  44. data/config/locales/es-MX.yml +13 -9
  45. data/config/locales/es-PY.yml +15 -11
  46. data/config/locales/es.yml +14 -10
  47. data/config/locales/eu.yml +383 -343
  48. data/config/locales/fi-plain.yml +27 -2
  49. data/config/locales/fi.yml +17 -13
  50. data/config/locales/fr-CA.yml +13 -9
  51. data/config/locales/fr.yml +14 -10
  52. data/config/locales/ga-IE.yml +0 -5
  53. data/config/locales/gl.yml +6 -18
  54. data/config/locales/hu.yml +31 -14
  55. data/config/locales/id-ID.yml +4 -19
  56. data/config/locales/is-IS.yml +4 -3
  57. data/config/locales/it.yml +4 -9
  58. data/config/locales/ja.yml +35 -18
  59. data/config/locales/kaa.yml +4 -0
  60. data/config/locales/lb.yml +6 -11
  61. data/config/locales/lt.yml +53 -8
  62. data/config/locales/lv.yml +0 -16
  63. data/config/locales/nl.yml +2 -7
  64. data/config/locales/no.yml +5 -10
  65. data/config/locales/pl.yml +14 -5
  66. data/config/locales/pt-BR.yml +50 -7
  67. data/config/locales/pt.yml +2 -7
  68. data/config/locales/ro-RO.yml +1 -6
  69. data/config/locales/ru.yml +2 -17
  70. data/config/locales/sk.yml +13 -19
  71. data/config/locales/sl.yml +0 -5
  72. data/config/locales/sq-AL.yml +1 -0
  73. data/config/locales/sr-CS.yml +8 -0
  74. data/config/locales/sv.yml +23 -13
  75. data/config/locales/th-TH.yml +1 -0
  76. data/config/locales/tr-TR.yml +9 -11
  77. data/config/locales/uk.yml +2 -14
  78. data/config/locales/zh-CN.yml +0 -6
  79. data/config/locales/zh-TW.yml +16 -7
  80. data/db/migrate/20181030090144_destroy_deleted_users_follows.rb +1 -1
  81. data/db/migrate/20181204110723_remove_following_users_count_from_users.rb +11 -2
  82. data/db/migrate/20181214101250_add_notification_types_to_users.rb +6 -1
  83. data/db/migrate/20190412131728_fix_user_names.rb +13 -6
  84. data/db/migrate/20200211173227_add_direct_message_types_to_users.rb +6 -1
  85. data/db/migrate/20210302150803_invalidate_all_sessions_for_deleted_users.rb +10 -3
  86. data/db/migrate/20210310120640_add_followable_counter_cache_to_users.rb +13 -3
  87. data/db/migrate/20231027142329_change_default_value_for_decidim_endorsements.rb +11 -0
  88. data/db/seeds.rb +1 -0
  89. data/lib/decidim/core/test/shared_examples/comments_examples.rb +24 -0
  90. data/lib/decidim/core/test/shared_examples/errors.rb +2 -0
  91. data/lib/decidim/core/test/shared_examples/map_examples.rb +4 -1
  92. data/lib/decidim/core/version.rb +1 -1
  93. data/lib/decidim/core.rb +44 -1
  94. data/lib/decidim/dependency_resolver.rb +278 -0
  95. data/lib/decidim/endorsable.rb +1 -1
  96. data/lib/decidim/exporters.rb +10 -1
  97. data/lib/decidim/form_builder.rb +6 -13
  98. data/lib/tasks/upgrade/decidim_deduplicate_endorsements.rake +53 -0
  99. data/lib/tasks/upgrade/decidim_user_moderation.rake +14 -0
  100. metadata +13 -6
data/lib/decidim/core.rb CHANGED
@@ -97,6 +97,7 @@ module Decidim
97
97
  autoload :AttachmentAttributes, "decidim/attachment_attributes"
98
98
  autoload :CarrierWaveMigratorService, "decidim/carrier_wave_migrator_service"
99
99
  autoload :CommonPasswords, "decidim/common_passwords"
100
+ autoload :DependencyResolver, "decidim/dependency_resolver"
100
101
 
101
102
  include ActiveSupport::Configurable
102
103
  # Loads seeds from all engines.
@@ -484,7 +485,7 @@ module Decidim
484
485
  #
485
486
  # Returns an Array[ComponentManifest].
486
487
  def self.component_manifests
487
- component_registry.manifests
488
+ component_registry.manifests.sort_by(&:name)
488
489
  end
489
490
 
490
491
  # Public: Finds all registered participatory space manifest's via the
@@ -625,4 +626,46 @@ module Decidim
625
626
  def self.register_assets_path(path)
626
627
  Rails.autoloaders.main.ignore(path) if Rails.configuration.autoloader == :zeitwerk
627
628
  end
629
+
630
+ # Checks if a particular decidim gem is installed and needed by this
631
+ # particular instance. Preferrably this happens through bundler by inspecting
632
+ # the Gemfile of the instance but when Decidim is used without bundler, this
633
+ # will check:
634
+ # 1. If the gem is globally available or not in the loaded specs, i.e. the
635
+ # gems available in the gem install directory/directories.
636
+ # 2. If the gem has been required through `require "decidim/foo"`.
637
+ #
638
+ # Using bundler is suggested as it will provide more accurate results
639
+ # regarding what is actually needed. It will resolve all the gems listed in
640
+ # the Gemfile and also their dependencies which provides us accurate
641
+ # information whether a gem is needed by the instance or not.
642
+ #
643
+ # Note that using something like defined?(Decidim::Foo) will not work because
644
+ # the way the Decidim handles version definitions for each gem. After the gems
645
+ # are loaded, this would always return true because the version definition
646
+ # files of each module define that module which means it is available at
647
+ # runtime if the gem is installed in the gem load path. In some situations it
648
+ # can be installed there through other projects or through the command line
649
+ # even if the instance does not require that module or even through
650
+ # installing gems from git sources or from file paths.
651
+ #
652
+ # When a gem is reported as "needed" by the dependency resolver, this will
653
+ # also require that module ensuring its availability for the initialization
654
+ # code.
655
+ #
656
+ # @param mod [Symbol, String] The module name to check, e.g. `:proposals`.
657
+ # @return [Boolean] A boolean indicating whether the module is installed.
658
+ def self.module_installed?(mod)
659
+ return false unless Decidim::DependencyResolver.instance.needed?("decidim-#{mod}")
660
+
661
+ # The dependency may not be automatically loaded through the Gemfile if the
662
+ # user lists e.g. "decidim-core" and "decidim-budgets" in it. In this
663
+ # situation, "decidim-comments" is also needed because it is a dependency
664
+ # for "decidim-budgets".
665
+ require "decidim/#{mod}"
666
+
667
+ true
668
+ rescue LoadError
669
+ false
670
+ end
628
671
  end
@@ -0,0 +1,278 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # The dependency resolver provides information about the Decidim module
5
+ # dependencies. For instance, it can be used to check if a particular Decidim
6
+ # module is needed by the instance or not.
7
+ #
8
+ # This is a singleton utility in order to make it perform better when it is
9
+ # called from different places throughout the application.
10
+ #
11
+ # @example Checking whether a module is needed by the instance
12
+ # Decidim::DependencyResolver.instance.needed?("decidim-proposals")
13
+ class DependencyResolver
14
+ include Singleton
15
+
16
+ def initialize
17
+ @cache = []
18
+ end
19
+
20
+ # Finds a gem specification for the gem with the name provided as the
21
+ # argument.
22
+ #
23
+ # When bundler is available, searches whether the gem is listed in the
24
+ # Gemfile or required as a dependency for one of the gems in the Gemfile or
25
+ # their dependencies.
26
+ #
27
+ # When bundler is not available, gets the gem specification from the loaded
28
+ # specs which means any gems available in the gem install folder.
29
+ #
30
+ # @param gem [String] The name for the gem to be looked up.
31
+ # @return [Gem::Specification, nil] Returns the gem specification for the
32
+ # given gem name. The specification implements the necessary methods for
33
+ # the other checks. In both cases returns nil if the gem is not found.
34
+ def lookup(gem)
35
+ # In case the lookup method is called with a spec definition, return the
36
+ # definition itself.
37
+ return gem unless gem.is_a?(String)
38
+
39
+ if bundler?
40
+ lookup = Lookup.new
41
+ return lookup.spec(gem) if cache.include?(gem)
42
+
43
+ # Keep a local cache of the already processed gems in order to avoid
44
+ # double lookups.
45
+ lookup.find(Bundler.definition.dependencies, gem) do |dependency|
46
+ if potential_module?(dependency.name)
47
+ cache_miss = cache.exclude?(dependency.name)
48
+ cache << dependency.name if cache_miss
49
+ cache_miss
50
+ else
51
+ false
52
+ end
53
+ end
54
+ else
55
+ return unless potential_module?(gem)
56
+
57
+ Gem.loaded_specs[gem]
58
+ end
59
+ end
60
+
61
+ # Resolves the main load file path for module defined by the gem
62
+ # specification.
63
+ #
64
+ # @param spec [Bundler::LazySpecification, Gem::Specification, String] The
65
+ # gem specification to test or the name of the gem.
66
+ # @return [String] A string pointing the path to the module's main load
67
+ # file.
68
+ def module_path(spec)
69
+ spec = lookup(spec)
70
+ return unless spec
71
+
72
+ "#{spec.full_gem_path}/lib/#{spec.name.gsub("-", "/")}.rb"
73
+ end
74
+
75
+ # Resolves whether the module for the gem specification defines the main
76
+ # load file.
77
+ #
78
+ # @param spec [Bundler::LazySpecification, Gem::Specification, String] The
79
+ # gem specification to test or the name of the gem.
80
+ # @return [Boolean] A boolean indicating if the gem defined by the spec is
81
+ # available for loading.
82
+ def available?(spec)
83
+ path = module_path(spec)
84
+ return false unless path
85
+
86
+ File.exist?(path)
87
+ end
88
+
89
+ # Checks if the module for the gem speficiation has been loaded through
90
+ # `require "decidim/foo"`.
91
+ #
92
+ # @param spec [Bundler::LazySpecification, Gem::Specification, String] The
93
+ # gem specification to test or the name of the gem.
94
+ # @return [Boolean] A boolean indicating if the gem defined by the spec is
95
+ # loaded.
96
+ def loaded?(spec)
97
+ return false unless available?(spec)
98
+
99
+ $LOADED_FEATURES.include?(module_path(spec))
100
+ end
101
+
102
+ # Resolves whether the target gem is needed or not, i.e. does it need to be
103
+ # loaded.
104
+ #
105
+ # When bundler is available, the dependencies are resolved based on the
106
+ # modules defined in the Gemfile which means that the gem is always needed
107
+ # when it is reported as available by the resolver (i.e. defined as a
108
+ # dependency in the Gemfile itself or one of those gems depend on it).
109
+ #
110
+ # When bundler is not available, this will check whether the Decidim module
111
+ # provided by the gem has been already required/loaded or not. In this
112
+ # situation, it is impossible to know whether the implementer has intended
113
+ # the gem to be used or not, so we assume in these situations implementers
114
+ # will load all the gems they want before running any initializers. This
115
+ # means that the `require "decidim/foo"` statements have to be listed for
116
+ # all modules before the initialization process.
117
+ #
118
+ # @param spec [Bundler::LazySpecification, Gem::Specification, String] The
119
+ # gem specification to test or the name of the gem.
120
+ # @return [Boolean] A boolean indicating if the gem defined by the spec is
121
+ # needed.
122
+ def needed?(spec)
123
+ spec = lookup(spec)
124
+ return false unless spec
125
+
126
+ if bundler?
127
+ available?(spec)
128
+ else
129
+ loaded?(spec)
130
+ end
131
+ end
132
+
133
+ private
134
+
135
+ attr_accessor :cache
136
+
137
+ # Reports whether bundler is available.
138
+ #
139
+ # @return [Boolean] A boolean indicating if bundler is available or not.
140
+ def bundler?
141
+ defined?(Bundler)
142
+ end
143
+
144
+ # Only match the decidim gems. Skip the decidim-dev gem because it has
145
+ # "decidim" as a runtime dependency which would cause all the default
146
+ # gems to be always reported as available.
147
+ #
148
+ # @return [Boolean] A boolean indicating if the given gem name is a
149
+ # potential Decidim module to be processed.
150
+ def potential_module?(name)
151
+ name != "decidim-dev" && name =~ /decidim(-.*)?/
152
+ end
153
+
154
+ # The lookup class takes care of the individual recursive lookups over a
155
+ # dependency tree.
156
+ class Lookup
157
+ # @param debug [Boolean] A boolean indicating if the debug mode is enabled
158
+ # or not. False by default.
159
+ def initialize(debug: false)
160
+ @current_level = 0
161
+ return unless debug
162
+
163
+ formatter = proc do |_severity, _datetime, _progname, msg|
164
+ "#{msg}\n"
165
+ end
166
+ @logger = Logger.new($stdout, formatter: formatter)
167
+ logger.debug!
168
+ end
169
+
170
+ # Iterates recursively through the runtime dependencies array and their
171
+ # sub-dependencies to find whether the provided gem is included. This
172
+ # always iterates through the whole dependency tree even when the gem is
173
+ # already found in order not to process the same dependencies multiple
174
+ # times and to make the cache work correctly when calling this.
175
+ #
176
+ # @param dependencies [Array] An array of the dependencies to iterate
177
+ # through.
178
+ # @param gem [String] The name of the gem to find.
179
+ # @yield [dependency] Yields each dependency to be processed to the
180
+ # provided block to check if that dependency needs to be processed or
181
+ # not.
182
+ # @yieldparam [Gem::Dependency] The runtime dependency being processed.
183
+ # @yieldreturn [Boolean] A boolean indicating whether this dependency
184
+ # needs to be processed or not. True indicates it needs to be processed
185
+ # and false indicates processing is not needed.
186
+ # @return [Bundler::LazySpecification, nil] The specification for the gem
187
+ # or nil when it is not found.
188
+ def find(dependencies, gem, &block)
189
+ found = nil
190
+ dependencies.each do |dependency|
191
+ next unless process?(dependency, &block)
192
+
193
+ spec = spec(dependency.name)
194
+ next unless spec # E.g. the "bundler" gem is not in the locked gems
195
+
196
+ log(dependency)
197
+
198
+ found ||= spec if spec.name == gem
199
+
200
+ @current_level += 1
201
+ # Do not se the found value directly here because otherwise the
202
+ # recursive call would not be made if the target gem is already found.
203
+ sub_spec = find(spec.dependencies, gem, &block)
204
+ @current_level -= 1
205
+ found ||= sub_spec
206
+ end
207
+
208
+ found
209
+ end
210
+
211
+ # Finds a gem specification from the locked gems of the instance.
212
+ #
213
+ # Note that this does not resolve if the module is needed or not. This may
214
+ # also return the gem specification even when it is not listed in the
215
+ # Gemfile, e.g. when the Decidim gems are installed through git.
216
+ #
217
+ # @param name [String] The name of the gem to find.
218
+ # @return [Gem::Specification, nil] The specification for the gem
219
+ # or nil if the gem is not listed in the locked gems or nil when the
220
+ # returned spec is not installed in the current gem environment.
221
+ def spec(name)
222
+ sp = Bundler.definition.locked_gems.specs.find { |s| s.name == name }
223
+
224
+ # Fetching the gem through Gem.loaded_specs ensures we are not returning
225
+ # a lazy specification which does not respond to `#full_gem_path` which
226
+ # is needed for the resolver.
227
+ return Gem.loaded_specs[sp.name] if sp
228
+
229
+ nil
230
+ end
231
+
232
+ private
233
+
234
+ attr_reader :logger, :current_level
235
+
236
+ # Decides whether a dependency needs to be processed, i.e. compared
237
+ # whether it is the gem to be found.
238
+ #
239
+ # @param dependency [Gem::Dependency] The dependency being processed.
240
+ # @yield [dependency] Yields each dependency to be processed to the
241
+ # provided block to check if that dependency needs to be processed or
242
+ # not.
243
+ # @yieldparam [Gem::Dependency] The runtime dependency being processed.
244
+ # @yieldreturn [Boolean] A boolean indicating whether this dependency
245
+ # needs to be processed or not. True indicates it needs to be processed
246
+ # and false indicates processing is not needed.
247
+ # @return [Boolean] A boolean indicating whether the dependency needs to
248
+ # be processed, i.e. compared whether it is the gem to be found.
249
+ def process?(dependency)
250
+ return false unless dependency.type == :runtime
251
+ return true unless block_given?
252
+
253
+ yield(dependency)
254
+ end
255
+
256
+ # Writes a log message for the given dependency at the current level of
257
+ # processing. When debugging is enabled, will produce the following kind
258
+ # of log output indicating the lookup tree.
259
+ #
260
+ # @example
261
+ # decidim-admin
262
+ # --decidim-core
263
+ # ----decidim-api
264
+ # decidim-assemblies
265
+ # decidim-blogs
266
+ # --decidim-comments
267
+ #
268
+ # @param dependency [Gem::Dependency] The dependency to be logged at the
269
+ # current level of processing.
270
+ # @return [Boolean] A boolean indicating whether logging happened or not.
271
+ def log(dependency)
272
+ return false unless logger
273
+
274
+ logger.debug("#{"--" * current_level}#{dependency.name}")
275
+ end
276
+ end
277
+ end
278
+ end
@@ -21,7 +21,7 @@ module Decidim
21
21
  if user_group
22
22
  endorsements.where(user_group: user_group).any?
23
23
  else
24
- endorsements.where(author: user, user_group: nil).any?
24
+ endorsements.where(author: user, user_group: 0).any?
25
25
  end
26
26
  end
27
27
  end
@@ -9,6 +9,11 @@ module Decidim
9
9
  autoload :PDF, "decidim/exporters/pdf"
10
10
  autoload :ExportData, "decidim/exporters/export_data"
11
11
 
12
+ # Lock the export formats to one of the available exporters
13
+ EXPORT_FORMATS = [:JSON, :CSV, :Excel, :PDF, :FormPDF].freeze
14
+
15
+ class UnknownFormatError < StandardError; end
16
+
12
17
  # Necessary for the i18n normalizer to locate strings not directly invoked in views:
13
18
 
14
19
  # i18n-tasks-use t('decidim.admin.exports.formats.JSON')
@@ -19,7 +24,11 @@ module Decidim
19
24
  #
20
25
  # format - The exporter format as a string. i.e "CSV"
21
26
  def self.find_exporter(format)
22
- const_get(format)
27
+ raise UnknownFormatError unless format.respond_to?(:to_sym)
28
+ raise UnknownFormatError unless EXPORT_FORMATS.include?(format.to_sym)
29
+ raise UnknownFormatError unless const_defined?(format.to_sym)
30
+
31
+ const_get(format.to_sym)
23
32
  end
24
33
  end
25
34
  end
@@ -174,7 +174,6 @@ module Decidim
174
174
  # or 'full' (optional) (default: 'basic')
175
175
  # :lines - The Integer to indicate how many lines should editor have (optional) (default: 10)
176
176
  # :disabled - Whether the editor should be disabled
177
- # :editor_images - Allow attached images (optional) (default: false)
178
177
  #
179
178
  # Renders a container with both hidden field and editor container
180
179
  def editor(name, options = {})
@@ -192,9 +191,12 @@ module Decidim
192
191
  template += label(name, label_text + required_for_attribute(name)) if options.fetch(:label, true)
193
192
  template += hidden_field(name, hidden_options)
194
193
  template += content_tag(:div, nil, class: "editor-container #{"js-hashtags" if hashtaggable}", data: {
195
- toolbar: toolbar,
196
- disabled: options[:disabled]
197
- }.merge(editor_images_options(options)), style: "height: #{lines}rem")
194
+ toolbar: toolbar,
195
+ disabled: options[:disabled],
196
+ editor_images: true,
197
+ upload_images_path: Decidim::Core::Engine.routes.url_helpers.editor_images_path,
198
+ drag_and_drop_help_text: I18n.t("drag_and_drop_help", scope: "decidim.editor_images")
199
+ }, style: "height: #{lines}rem")
198
200
  template += error_for(name, options) if error?(name)
199
201
  template.html_safe
200
202
  end
@@ -908,14 +910,5 @@ module Decidim
908
910
  end
909
911
  end
910
912
  end
911
-
912
- def editor_images_options(options)
913
- return {} unless options[:editor_images]
914
-
915
- {
916
- upload_images_path: Decidim::Core::Engine.routes.url_helpers.editor_images_path,
917
- drag_and_drop_help_text: I18n.t("drag_and_drop_help", scope: "decidim.editor_images")
918
- }
919
- end
920
913
  end
921
914
  end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :decidim do
4
+ namespace :upgrade do
5
+ desc "Remove duplicated endorsements"
6
+ task fix_duplicate_endorsements: :environment do
7
+ logger = Logger.new($stdout)
8
+ logger.info("Removing duplicate endorsements...")
9
+ has_count = 0
10
+
11
+ columns = [:resource_type, :resource_id, :decidim_author_type, :decidim_author_id, :decidim_user_group_id]
12
+
13
+ get_duplicates(columns).each do |issue|
14
+ while row_count(issue) > 1
15
+ find_next(issue)&.destroy
16
+ has_count += 1
17
+ logger.info("Removed duplicate endorsement for #{issue.resource_type} #{issue.resource_id}")
18
+ end
19
+ end
20
+
21
+ logger.info("Patch remaining endorsements.")
22
+ Decidim::Endorsement.where(decidim_user_group_id: nil).update(decidim_user_group_id: 0)
23
+ logger.info("Process terminated, #{has_count} endorsements have been removed.")
24
+ logger.info("Done")
25
+ end
26
+
27
+ private
28
+
29
+ def get_duplicates(*columns)
30
+ Decidim::Endorsement.select("#{columns.join(",")}, COUNT(*)").group(columns).having("COUNT(*) > 1")
31
+ end
32
+
33
+ def row_count(issue)
34
+ Decidim::Endorsement.where(
35
+ resource_type: issue.resource_type,
36
+ resource_id: issue.resource_id,
37
+ decidim_author_type: issue.decidim_author_type,
38
+ decidim_author_id: issue.decidim_author_id,
39
+ decidim_user_group_id: issue.decidim_user_group_id
40
+ ).count
41
+ end
42
+
43
+ def find_next(issue)
44
+ Decidim::Endorsement.find_by(
45
+ resource_type: issue.resource_type,
46
+ resource_id: issue.resource_id,
47
+ decidim_author_type: issue.decidim_author_type,
48
+ decidim_author_id: issue.decidim_author_id,
49
+ decidim_user_group_id: issue.decidim_user_group_id
50
+ )
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :decidim do
4
+ namespace :upgrade do
5
+ namespace :moderation do
6
+ desc "Add all blocked users to global moderation panel"
7
+ task fix_blocked_user_panel: :environment do
8
+ Decidim::UserBlock.find_each do |blocked_user|
9
+ Decidim::UserModeration.where(user: blocked_user.user).first_or_create!
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.7
4
+ version: 0.26.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-05-11 00:00:00.000000000 Z
13
+ date: 2023-12-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: active_link_to
@@ -754,28 +754,28 @@ dependencies:
754
754
  requirements:
755
755
  - - '='
756
756
  - !ruby/object:Gem::Version
757
- version: 0.26.7
757
+ version: 0.26.9
758
758
  type: :runtime
759
759
  prerelease: false
760
760
  version_requirements: !ruby/object:Gem::Requirement
761
761
  requirements:
762
762
  - - '='
763
763
  - !ruby/object:Gem::Version
764
- version: 0.26.7
764
+ version: 0.26.9
765
765
  - !ruby/object:Gem::Dependency
766
766
  name: decidim-dev
767
767
  requirement: !ruby/object:Gem::Requirement
768
768
  requirements:
769
769
  - - '='
770
770
  - !ruby/object:Gem::Version
771
- version: 0.26.7
771
+ version: 0.26.9
772
772
  type: :development
773
773
  prerelease: false
774
774
  version_requirements: !ruby/object:Gem::Requirement
775
775
  requirements:
776
776
  - - '='
777
777
  - !ruby/object:Gem::Version
778
- version: 0.26.7
778
+ version: 0.26.9
779
779
  description: Adds core features so other engines can hook into the framework.
780
780
  email:
781
781
  - josepjaume@gmail.com
@@ -1940,6 +1940,7 @@ files:
1940
1940
  - app/views/layouts/decidim/widget.html.erb
1941
1941
  - config/assets.rb
1942
1942
  - config/brakeman.ignore
1943
+ - config/environment.rb
1943
1944
  - config/initializers/active_support.rb
1944
1945
  - config/initializers/browser.rb
1945
1946
  - config/initializers/carrierwave.rb
@@ -2014,9 +2015,11 @@ files:
2014
2015
  - config/locales/sk.yml
2015
2016
  - config/locales/sl.yml
2016
2017
  - config/locales/so-SO.yml
2018
+ - config/locales/sq-AL.yml
2017
2019
  - config/locales/sr-CS.yml
2018
2020
  - config/locales/sv.yml
2019
2021
  - config/locales/sw-KE.yml
2022
+ - config/locales/th-TH.yml
2020
2023
  - config/locales/ti-ER.yml
2021
2024
  - config/locales/tr-TR.yml
2022
2025
  - config/locales/uk.yml
@@ -2221,6 +2224,7 @@ files:
2221
2224
  - db/migrate/20210629172525_fix_blocked_user_names_in_action_log.rb
2222
2225
  - db/migrate/20210730112319_create_decidim_editor_images.rb
2223
2226
  - db/migrate/20211126183540_add_timestamps_to_content_blocks.rb
2227
+ - db/migrate/20231027142329_change_default_value_for_decidim_endorsements.rb
2224
2228
  - db/seeds.rb
2225
2229
  - db/seeds/homepage_image.jpg
2226
2230
  - lib/decidim/action_authorization.rb
@@ -2436,6 +2440,7 @@ files:
2436
2440
  - lib/decidim/data_portability_serializers/data_portability_user_group_serializer.rb
2437
2441
  - lib/decidim/data_portability_serializers/data_portability_user_serializer.rb
2438
2442
  - lib/decidim/db/common-passwords.txt
2443
+ - lib/decidim/dependency_resolver.rb
2439
2444
  - lib/decidim/deprecations.rb
2440
2445
  - lib/decidim/diffy_extension.rb
2441
2446
  - lib/decidim/endorsable.rb
@@ -2577,7 +2582,9 @@ files:
2577
2582
  - lib/tasks/decidim_open_data_tasks.rake
2578
2583
  - lib/tasks/decidim_tasks.rake
2579
2584
  - lib/tasks/decidim_webpacker_tasks.rake
2585
+ - lib/tasks/upgrade/decidim_deduplicate_endorsements.rake
2580
2586
  - lib/tasks/upgrade/decidim_moderation_tasks.rake
2587
+ - lib/tasks/upgrade/decidim_user_moderation.rake
2581
2588
  homepage: https://github.com/decidim/decidim
2582
2589
  licenses:
2583
2590
  - AGPL-3.0