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
data/lib/decidim/core.rb CHANGED
@@ -113,6 +113,7 @@ module Decidim
113
113
  autoload :EventRecorder, "decidim/event_recorder"
114
114
  autoload :ControllerHelpers, "decidim/controller_helpers"
115
115
  autoload :ProcessesFileLocally, "decidim/processes_file_locally"
116
+ autoload :DependencyResolver, "decidim/dependency_resolver"
116
117
 
117
118
  include ActiveSupport::Configurable
118
119
  # Loads seeds from all engines.
@@ -396,23 +397,24 @@ module Decidim
396
397
  1_000
397
398
  end
398
399
 
399
- # Defines the name of the cookie used to check if the user allows Decidim to
400
- # set cookies.
400
+ # Defines the name of the cookie used to check if the user has given consent
401
+ # to store local data in their browser.
401
402
  config_accessor :consent_cookie_name do
402
403
  "decidim-consent"
403
404
  end
404
405
 
405
- # Defines cookie categories. Note that when adding a cookie you need to
406
- # add following i18n entries also (change 'foo' with the name of the cookie).
406
+ # Defines data consent categories. Note that when adding an item you need to
407
+ # add following i18n entries also (change 'foo' with the name of the data
408
+ # which can be a cookie for instance).
407
409
  #
408
- # layouts.decidim.cookie_consent.cookie_details.cookies.foo.service
409
- # layouts.decidim.cookie_consent.cookie_details.cookies.foo.description
410
+ # layouts.decidim.data_consent.details.items.foo.service
411
+ # layouts.decidim.data_consent.details.items.foo.description
410
412
  config_accessor :consent_categories do
411
413
  [
412
414
  {
413
415
  slug: "essential",
414
416
  mandatory: true,
415
- cookies: [
417
+ items: [
416
418
  {
417
419
  type: "cookie",
418
420
  name: "_session_id"
@@ -420,6 +422,10 @@ module Decidim
420
422
  {
421
423
  type: "cookie",
422
424
  name: Decidim.consent_cookie_name
425
+ },
426
+ {
427
+ type: "local_storage",
428
+ name: "pwaInstallPromptSeen"
423
429
  }
424
430
  ]
425
431
  },
@@ -711,12 +717,45 @@ module Decidim
711
717
  Rails.autoloaders.main.ignore(path) if Rails.configuration.autoloader == :zeitwerk
712
718
  end
713
719
 
714
- # Checks if a particular decidim gem is installed
715
- # Note that defined(Decidim::Something) does not work all the times, specially when the
716
- # Gemfile uses the "path" parameter to find the module.
717
- # This is because the module can be defined by some files searched by Rails automatically
718
- # (ie: decidim-initiatives/lib/decidim/initiatives/version.rb automatically defines Decidim::Intiatives even if not required)
720
+ # Checks if a particular decidim gem is installed and needed by this
721
+ # particular instance. Preferrably this happens through bundler by inspecting
722
+ # the Gemfile of the instance but when Decidim is used without bundler, this
723
+ # will check:
724
+ # 1. If the gem is globally available or not in the loaded specs, i.e. the
725
+ # gems available in the gem install directory/directories.
726
+ # 2. If the gem has been required through `require "decidim/foo"`.
727
+ #
728
+ # Using bundler is suggested as it will provide more accurate results
729
+ # regarding what is actually needed. It will resolve all the gems listed in
730
+ # the Gemfile and also their dependencies which provides us accurate
731
+ # information whether a gem is needed by the instance or not.
732
+ #
733
+ # Note that using something like defined?(Decidim::Foo) will not work because
734
+ # the way the Decidim handles version definitions for each gem. After the gems
735
+ # are loaded, this would always return true because the version definition
736
+ # files of each module define that module which means it is available at
737
+ # runtime if the gem is installed in the gem load path. In some situations it
738
+ # can be installed there through other projects or through the command line
739
+ # even if the instance does not require that module or even through
740
+ # installing gems from git sources or from file paths.
741
+ #
742
+ # When a gem is reported as "needed" by the dependency resolver, this will
743
+ # also require that module ensuring its availability for the initialization
744
+ # code.
745
+ #
746
+ # @param mod [Symbol, String] The module name to check, e.g. `:proposals`.
747
+ # @return [Boolean] A boolean indicating whether the module is installed.
719
748
  def self.module_installed?(mod)
720
- Gem.loaded_specs.has_key?("decidim-#{mod}")
749
+ return false unless Decidim::DependencyResolver.instance.needed?("decidim-#{mod}")
750
+
751
+ # The dependency may not be automatically loaded through the Gemfile if the
752
+ # user lists e.g. "decidim-core" and "decidim-budgets" in it. In this
753
+ # situation, "decidim-comments" is also needed because it is a dependency
754
+ # for "decidim-budgets".
755
+ require "decidim/#{mod}"
756
+
757
+ true
758
+ rescue LoadError
759
+ false
721
760
  end
722
761
  end
@@ -0,0 +1,272 @@
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 [Bundler::LazySpecification, Gem::Specification, nil] When bundler
32
+ # is available, returns `Bundler::LazySpecification`. When bundler is not
33
+ # available, returns `Gem::Specification`. Both of these implement the
34
+ # necessary methods for the other checks. In both cases returns nil if
35
+ # the gem is not found.
36
+ def lookup(gem)
37
+ # In case the lookup method is called with a spec definition, return the
38
+ # definition itself.
39
+ return gem unless gem.is_a?(String)
40
+
41
+ if bundler?
42
+ lookup = Lookup.new
43
+ return lookup.spec(gem) if cache.include?(gem)
44
+
45
+ # Keep a local cache of the already processed gems in order to avoid
46
+ # double lookups.
47
+ lookup.find(Bundler.definition.dependencies, gem) do |dependency|
48
+ if potential_module?(dependency.name)
49
+ cache_miss = cache.exclude?(dependency.name)
50
+ cache << dependency.name if cache_miss
51
+ cache_miss
52
+ else
53
+ false
54
+ end
55
+ end
56
+ else
57
+ return unless potential_module?(gem)
58
+
59
+ Gem.loaded_specs[gem]
60
+ end
61
+ end
62
+
63
+ # Resolves the main load file path for module defined by the gem
64
+ # specification.
65
+ #
66
+ # @param spec [Bundler::LazySpecification, Gem::Specification, String] The
67
+ # gem specification to test or the name of the gem.
68
+ # @return [String] A string pointing the path to the module's main load
69
+ # file.
70
+ def module_path(spec)
71
+ spec = lookup(spec)
72
+ return unless spec
73
+
74
+ "#{spec.full_gem_path}/lib/#{spec.name.gsub("-", "/")}.rb"
75
+ end
76
+
77
+ # Resolves whether the module for the gem specification defines the main
78
+ # load file.
79
+ #
80
+ # @param spec [Bundler::LazySpecification, Gem::Specification, String] The
81
+ # gem specification to test or the name of the gem.
82
+ # @return [Boolean] A boolean indicating if the gem defined by the spec is
83
+ # available for loading.
84
+ def available?(spec)
85
+ path = module_path(spec)
86
+ return false unless path
87
+
88
+ File.exist?(path)
89
+ end
90
+
91
+ # Checks if the module for the gem speficiation has been loaded through
92
+ # `require "decidim/foo"`.
93
+ #
94
+ # @param spec [Bundler::LazySpecification, Gem::Specification, String] The
95
+ # gem specification to test or the name of the gem.
96
+ # @return [Boolean] A boolean indicating if the gem defined by the spec is
97
+ # loaded.
98
+ def loaded?(spec)
99
+ return false unless available?(spec)
100
+
101
+ $LOADED_FEATURES.include?(module_path(spec))
102
+ end
103
+
104
+ # Resolves whether the target gem is needed or not, i.e. does it need to be
105
+ # loaded.
106
+ #
107
+ # When bundler is available, the dependencies are resolved based on the
108
+ # modules defined in the Gemfile which means that the gem is always needed
109
+ # when it is reported as available by the resolver (i.e. defined as a
110
+ # dependency in the Gemfile itself or one of those gems depend on it).
111
+ #
112
+ # When bundler is not available, this will check whether the Decidim module
113
+ # provided by the gem has been already required/loaded or not. In this
114
+ # situation, it is impossible to know whether the implementer has intended
115
+ # the gem to be used or not, so we assume in these situations implementers
116
+ # will load all the gems they want before running any initializers. This
117
+ # means that the `require "decidim/foo"` statements have to be listed for
118
+ # all modules before the initialization process.
119
+ #
120
+ # @param spec [Bundler::LazySpecification, Gem::Specification, String] The
121
+ # gem specification to test or the name of the gem.
122
+ # @return [Boolean] A boolean indicating if the gem defined by the spec is
123
+ # needed.
124
+ def needed?(spec)
125
+ spec = lookup(spec)
126
+ return false unless spec
127
+
128
+ if bundler?
129
+ available?(spec)
130
+ else
131
+ loaded?(spec)
132
+ end
133
+ end
134
+
135
+ private
136
+
137
+ attr_accessor :cache
138
+
139
+ # Reports whether bundler is available.
140
+ #
141
+ # @return [Boolean] A boolean indicating if bundler is available or not.
142
+ def bundler?
143
+ defined?(Bundler)
144
+ end
145
+
146
+ # Only match the decidim gems. Skip the decidim-dev gem because it has
147
+ # "decidim" as a runtime dependency which would cause all the default
148
+ # gems to be always reported as available.
149
+ #
150
+ # @return [Boolean] A boolean indicating if the given gem name is a
151
+ # potential Decidim module to be processed.
152
+ def potential_module?(name)
153
+ name != "decidim-dev" && name =~ /decidim(-.*)?/
154
+ end
155
+
156
+ # The lookup class takes care of the individual recursive lookups over a
157
+ # dependency tree.
158
+ class Lookup
159
+ # @param debug [Boolean] A boolean indicating if the debug mode is enabled
160
+ # or not. False by default.
161
+ def initialize(debug: false)
162
+ @current_level = 0
163
+ return unless debug
164
+
165
+ formatter = proc do |_severity, _datetime, _progname, msg|
166
+ "#{msg}\n"
167
+ end
168
+ @logger = Logger.new($stdout, formatter: formatter)
169
+ logger.debug!
170
+ end
171
+
172
+ # Iterates recursively through the runtime dependencies array and their
173
+ # sub-dependencies to find whether the provided gem is included. This
174
+ # always iterates through the whole dependency tree even when the gem is
175
+ # already found in order not to process the same dependencies multiple
176
+ # times and to make the cache work correctly when calling this.
177
+ #
178
+ # @param dependencies [Array] An array of the dependencies to iterate
179
+ # through.
180
+ # @param gem [String] The name of the gem to find.
181
+ # @yield [dependency] Yields each dependency to be processed to the
182
+ # provided block to check if that dependency needs to be processed or
183
+ # not.
184
+ # @yieldparam [Gem::Dependency] The runtime dependency being processed.
185
+ # @yieldreturn [Boolean] A boolean indicating whether this dependency
186
+ # needs to be processed or not. True indicates it needs to be processed
187
+ # and false indicates processing is not needed.
188
+ # @return [Bundler::LazySpecification, nil] The specification for the gem
189
+ # or nil when it is not found.
190
+ def find(dependencies, gem, &block)
191
+ found = nil
192
+ dependencies.each do |dependency|
193
+ next unless process?(dependency, &block)
194
+
195
+ spec = spec(dependency.name)
196
+ next unless spec # E.g. the "bundler" gem is not in the locked gems
197
+
198
+ log(dependency)
199
+
200
+ found ||= spec if spec.name == gem
201
+
202
+ @current_level += 1
203
+ # Do not se the found value directly here because otherwise the
204
+ # recursive call would not be made if the target gem is already found.
205
+ sub_spec = find(spec.dependencies, gem, &block)
206
+ @current_level -= 1
207
+ found ||= sub_spec
208
+ end
209
+
210
+ found
211
+ end
212
+
213
+ # Finds a gem specification from the locked gems of the instance.
214
+ #
215
+ # Note that this does not resolve if the module is needed or not. This may
216
+ # also return the gem specification even when it is not listed in the
217
+ # Gemfile, e.g. when the Decidim gems are installed through git.
218
+ #
219
+ # @param name [String] The name of the gem to find.
220
+ # @return [Bundler::LazySpecification, nil] The specification for the gem
221
+ # or nil if the gem is not listed in the locked gems.
222
+ def spec(name)
223
+ Bundler.definition.locked_gems.specs.find { |s| s.name == name }
224
+ end
225
+
226
+ private
227
+
228
+ attr_reader :logger, :current_level
229
+
230
+ # Decides whether a dependency needs to be processed, i.e. compared
231
+ # whether it is the gem to be found.
232
+ #
233
+ # @param dependency [Gem::Dependency] The dependency being processed.
234
+ # @yield [dependency] Yields each dependency to be processed to the
235
+ # provided block to check if that dependency needs to be processed or
236
+ # not.
237
+ # @yieldparam [Gem::Dependency] The runtime dependency being processed.
238
+ # @yieldreturn [Boolean] A boolean indicating whether this dependency
239
+ # needs to be processed or not. True indicates it needs to be processed
240
+ # and false indicates processing is not needed.
241
+ # @return [Boolean] A boolean indicating whether the dependency needs to
242
+ # be processed, i.e. compared whether it is the gem to be found.
243
+ def process?(dependency)
244
+ return false unless dependency.type == :runtime
245
+ return true unless block_given?
246
+
247
+ yield(dependency)
248
+ end
249
+
250
+ # Writes a log message for the given dependency at the current level of
251
+ # processing. When debugging is enabled, will produce the following kind
252
+ # of log output indicating the lookup tree.
253
+ #
254
+ # @example
255
+ # decidim-admin
256
+ # --decidim-core
257
+ # ----decidim-api
258
+ # decidim-assemblies
259
+ # decidim-blogs
260
+ # --decidim-comments
261
+ #
262
+ # @param dependency [Gem::Dependency] The dependency to be logged at the
263
+ # current level of processing.
264
+ # @return [Boolean] A boolean indicating whether logging happened or not.
265
+ def log(dependency)
266
+ return false unless logger
267
+
268
+ logger.debug("#{"--" * current_level}#{dependency.name}")
269
+ end
270
+ end
271
+ end
272
+ end
@@ -40,6 +40,7 @@ module Decidim
40
40
  def email_subject_i18n_options
41
41
  sanitized_values = { resource_title: decidim_sanitize(resource_title) }
42
42
  sanitized_values[:mentioned_proposal_title] = decidim_sanitize(mentioned_proposal_title) if i18n_options.has_key?(:mentioned_proposal_title)
43
+ sanitized_values[:participatory_space_title] = decidim_sanitize(participatory_space_title) if i18n_options.has_key?(:participatory_space_title)
43
44
  i18n_options.merge(sanitized_values)
44
45
  end
45
46
 
@@ -14,8 +14,6 @@ module Decidim
14
14
 
15
15
  delegate :resource_manifest, :resource_key, to: :class
16
16
 
17
- alias_method :manifest, :resource_manifest
18
-
19
17
  # Public: Whether the permissions for this object actions can be set at resource level.
20
18
  def allow_resource_permissions?
21
19
  false
@@ -33,7 +33,7 @@ module Decidim
33
33
  )
34
34
  end
35
35
 
36
- base_config.merge(api_key: api_key)
36
+ base_config.merge(api_key: api_key, language: language_code)
37
37
  end
38
38
 
39
39
  # A builder for the HERE maps which needs to be configured differently
@@ -44,6 +44,51 @@ module Decidim
44
44
  template.javascript_pack_tag("decidim_map_provider_here", defer: false)
45
45
  end
46
46
  end
47
+
48
+ private
49
+
50
+ def language_code
51
+ primary = I18n.locale.to_s
52
+ secondary = primary.split("-")[0]
53
+ available_language_codes[primary] || available_language_codes[secondary] || ""
54
+ end
55
+
56
+ def available_language_codes
57
+ @available_language_codes ||= {
58
+ "ar" => "ara", # Arabic
59
+ "eu" => "baq", # Basque
60
+ "ca" => "cat", # Catalan
61
+ "zh" => "chi", # Chinese (simplified)
62
+ # "" => "cht", # Chinese (traditional)
63
+ "cs" => "cze", # Czech
64
+ "da" => "dan", # Danish
65
+ "nl" => "dut", # Dutch
66
+ "en" => "eng", # English
67
+ "fi" => "fin", # Finnish
68
+ "fr" => "fre", # French
69
+ "de" => "ger", # German
70
+ "ga" => "gle", # Gaelic
71
+ "el" => "gre", # Greek
72
+ "he" => "heb", # Hebrew
73
+ "hi" => "hin", # Hindi
74
+ "id" => "ind", # Indonesian
75
+ "it" => "ita", # Italian
76
+ "no" => "nor", # Norwegian
77
+ "fa" => "per", # Persian
78
+ "pl" => "pol", # Polish
79
+ "pt" => "por", # Portuguese
80
+ "ru" => "rus", # Russian
81
+ "si" => "sin", # Sinhalese
82
+ "es" => "spa", # Spanish
83
+ "sv" => "swe", # Swedish
84
+ "th" => "tha", # Thai
85
+ "tr" => "tur", # Turkish
86
+ "uk" => "ukr", # Ukrainian
87
+ "ur" => "urd", # Urdu
88
+ "vi" => "vie", # Vietnamese
89
+ "cy" => "wel" # Welsh
90
+ }
91
+ end
47
92
  end
48
93
  end
49
94
  end
@@ -52,7 +52,7 @@ module Decidim
52
52
  candidate = name
53
53
 
54
54
  2.step do |n|
55
- return candidate if Decidim::User.where("nickname ILIKE ?", candidate.downcase).where(scope).empty?
55
+ return candidate if Decidim::UserBaseEntity.where("nickname ILIKE ?", candidate.downcase).where(scope).empty?
56
56
 
57
57
  candidate = numbered_variation_of(name, n)
58
58
  end
@@ -43,7 +43,14 @@ module Decidim
43
43
 
44
44
  define_method attribute_name do
45
45
  field = public_send(name) || {}
46
- value = field[locale.to_s] || field[locale.to_sym]
46
+ value =
47
+ if field.is_a?(Hash)
48
+ field[locale.to_s] || field[locale.to_sym]
49
+ else
50
+ # The value may not be a hash in case the attribute type was
51
+ # changed and the old value is still stored against the record.
52
+ field
53
+ end
47
54
  value_type = self.class.attribute_types[attribute_name.to_s]
48
55
  value_type ? value_type.cast(value) : value
49
56
  end
@@ -39,7 +39,7 @@ module Decidim
39
39
  80
40
40
  end
41
41
 
42
- ENV.fetch("PORT", default_port).to_i
42
+ ENV.fetch("HTTP_PORT", default_port).to_i
43
43
  end
44
44
  end
45
45
 
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.27.0.rc1
4
+ version: 0.27.0
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: 2022-06-27 00:00:00.000000000 Z
13
+ date: 2022-09-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: active_link_to
@@ -740,28 +740,28 @@ dependencies:
740
740
  requirements:
741
741
  - - '='
742
742
  - !ruby/object:Gem::Version
743
- version: 0.27.0.rc1
743
+ version: 0.27.0
744
744
  type: :runtime
745
745
  prerelease: false
746
746
  version_requirements: !ruby/object:Gem::Requirement
747
747
  requirements:
748
748
  - - '='
749
749
  - !ruby/object:Gem::Version
750
- version: 0.27.0.rc1
750
+ version: 0.27.0
751
751
  - !ruby/object:Gem::Dependency
752
752
  name: decidim-dev
753
753
  requirement: !ruby/object:Gem::Requirement
754
754
  requirements:
755
755
  - - '='
756
756
  - !ruby/object:Gem::Version
757
- version: 0.27.0.rc1
757
+ version: 0.27.0
758
758
  type: :development
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.27.0.rc1
764
+ version: 0.27.0
765
765
  description: Adds core features so other engines can hook into the framework.
766
766
  email:
767
767
  - josepjaume@gmail.com
@@ -1410,8 +1410,9 @@ files:
1410
1410
  - app/packs/src/decidim/configuration.js
1411
1411
  - app/packs/src/decidim/confirm.js
1412
1412
  - app/packs/src/decidim/conversations.js
1413
- - app/packs/src/decidim/cookie_consent/consent_manager.js
1414
- - app/packs/src/decidim/cookie_consent/cookie_consent.js
1413
+ - app/packs/src/decidim/data_consent/consent_manager.js
1414
+ - app/packs/src/decidim/data_consent/consent_manager.test.js
1415
+ - app/packs/src/decidim/data_consent/index.js
1415
1416
  - app/packs/src/decidim/data_picker.js
1416
1417
  - app/packs/src/decidim/datalist_select.js
1417
1418
  - app/packs/src/decidim/decidim_application.js
@@ -1556,7 +1557,7 @@ files:
1556
1557
  - app/packs/stylesheets/decidim/modules/_conference-speaker.scss
1557
1558
  - app/packs/stylesheets/decidim/modules/_confirm.scss
1558
1559
  - app/packs/stylesheets/decidim/modules/_conversation.scss
1559
- - app/packs/stylesheets/decidim/modules/_cookie-consent.scss
1560
+ - app/packs/stylesheets/decidim/modules/_data-consent.scss
1560
1561
  - app/packs/stylesheets/decidim/modules/_data-picker.scss
1561
1562
  - app/packs/stylesheets/decidim/modules/_datepicker.scss
1562
1563
  - app/packs/stylesheets/decidim/modules/_definition-data.scss
@@ -1723,6 +1724,7 @@ files:
1723
1724
  - app/queries/decidim/user_groups/member_memberships.rb
1724
1725
  - app/resolvers/decidim/core/metric_resolver.rb
1725
1726
  - app/resolvers/decidim/hashtags_resolver.rb
1727
+ - app/scrubbers/decidim/admin_input_scrubber.rb
1726
1728
  - app/scrubbers/decidim/newsletter_scrubber.rb
1727
1729
  - app/scrubbers/decidim/user_input_scrubber.rb
1728
1730
  - app/serializers/decidim/exporters/participatory_space_components_serializer.rb
@@ -1820,7 +1822,6 @@ files:
1820
1822
  - app/views/decidim/devise/omniauth_registrations/new.html.erb
1821
1823
  - app/views/decidim/devise/passwords/edit.html.erb
1822
1824
  - app/views/decidim/devise/passwords/new.html.erb
1823
- - app/views/decidim/devise/registrations/edit.html.erb
1824
1825
  - app/views/decidim/devise/registrations/new.html.erb
1825
1826
  - app/views/decidim/devise/sessions/new.html.erb
1826
1827
  - app/views/decidim/devise/shared/_links.html.erb
@@ -1963,8 +1964,8 @@ files:
1963
1964
  - app/views/kaminari/decidim/_prev_page.html.erb
1964
1965
  - app/views/layouts/decidim/_admin_links.html.erb
1965
1966
  - app/views/layouts/decidim/_application.html.erb
1966
- - app/views/layouts/decidim/_cookie_warning.html.erb
1967
1967
  - app/views/layouts/decidim/_cors.html.erb
1968
+ - app/views/layouts/decidim/_data_consent_warning.html.erb
1968
1969
  - app/views/layouts/decidim/_decidim_javascript.html.erb
1969
1970
  - app/views/layouts/decidim/_edit_link.html.erb
1970
1971
  - app/views/layouts/decidim/_head.html.erb
@@ -2049,6 +2050,7 @@ files:
2049
2050
  - config/locales/mt.yml
2050
2051
  - config/locales/nl.yml
2051
2052
  - config/locales/no.yml
2053
+ - config/locales/oc-FR.yml
2052
2054
  - config/locales/om-ET.yml
2053
2055
  - config/locales/pl.yml
2054
2056
  - config/locales/pt-BR.yml
@@ -2477,6 +2479,7 @@ files:
2477
2479
  - lib/decidim/core/test/shared_examples/railtie_examples.rb
2478
2480
  - lib/decidim/core/test/shared_examples/reportable.rb
2479
2481
  - lib/decidim/core/test/shared_examples/reports_examples.rb
2482
+ - lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
2480
2483
  - lib/decidim/core/test/shared_examples/resource_search_examples.rb
2481
2484
  - lib/decidim/core/test/shared_examples/resourceable.rb
2482
2485
  - lib/decidim/core/test/shared_examples/rich_text_editor_examples.rb
@@ -2495,9 +2498,11 @@ files:
2495
2498
  - lib/decidim/core/test/shared_examples/traceable_interface_examples.rb
2496
2499
  - lib/decidim/core/test/shared_examples/translated_event_examples.rb
2497
2500
  - lib/decidim/core/test/shared_examples/uncommentable_component_examples.rb
2501
+ - lib/decidim/core/test/shared_examples/versions_controller_examples.rb
2498
2502
  - lib/decidim/core/test/shared_examples/with_endorsable_permissions_examples.rb
2499
2503
  - lib/decidim/core/version.rb
2500
2504
  - lib/decidim/db/common-passwords.txt
2505
+ - lib/decidim/dependency_resolver.rb
2501
2506
  - lib/decidim/deprecations.rb
2502
2507
  - lib/decidim/diffy_extension.rb
2503
2508
  - lib/decidim/download_your_data.rb
@@ -2681,9 +2686,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
2681
2686
  version: '3.0'
2682
2687
  required_rubygems_version: !ruby/object:Gem::Requirement
2683
2688
  requirements:
2684
- - - ">"
2689
+ - - ">="
2685
2690
  - !ruby/object:Gem::Version
2686
- version: 1.3.1
2691
+ version: '0'
2687
2692
  requirements: []
2688
2693
  rubygems_version: 3.2.22
2689
2694
  signing_key:
@@ -1,41 +0,0 @@
1
- <h2><%= t("devise.registrations.edit.title", resource: resource_class.model_name.human) %></h2>
2
-
3
- <%= decidim_form_for(resource, namespace: "registration", as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
4
- <%= render "devise/shared/error_messages", resource: resource %>
5
- <%= form_required_explanation %>
6
- <%= invisible_captcha %>
7
-
8
- <div class="field">
9
- <%= f.email_field :email, autocomplete: "email" %>
10
- </div>
11
-
12
- <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
13
- <p>
14
- <%= t("devise.registrations.edit.currently_waiting_confirmation_for_email", email: resource.unconfirmed_email) %>
15
- </p>
16
- <% end %>
17
-
18
- <div class="field">
19
- <%= f.password_field :password, password_field_options_for(current_user) %>
20
- </div>
21
-
22
- <div class="field">
23
- <%= f.password_field :password_confirmation, password_field_options_for(current_user).except(:help_text) %>
24
- </div>
25
-
26
- <div class="field">
27
- <%= f.password_field :current_password, autocomplete: "current-password" %>
28
- </div>
29
-
30
- <div class="field">
31
- <%= f.text_field :name, autocomplete: "name" %>
32
- </div>
33
-
34
- <div><%= f.submit t("devise.registrations.edit.update") %></div>
35
- <% end %>
36
-
37
- <h3><%= t("devise.registrations.edit.cancel_my_account") %></h3>
38
-
39
- <p><%= t("devise.registrations.edit.unhappy") %> <%= link_to t("devise.registrations.edit.cancel_my_account"), registration_path(resource_name), data: { confirm: t("devise.registrations.edit.are_you_sure") }, method: :delete %>.</p>
40
-
41
- <%= link_to t("devise.shared.links.back"), :back %>
@@ -1,8 +0,0 @@
1
- <div class="cookie-warning flex-center padding-1 hide">
2
- <p>
3
- <%= t("layouts.decidim.cookie_consent.warning.need_cookies", cookies: t("layouts.decidim.cookie_consent.warning.all_cookies")) %>
4
- </p>
5
- <a href="#" class="button margin-vertical-2" data-open="cc-modal">
6
- <%= t("change_cookie_settings", scope: "layouts.decidim.cookie_consent.warning") %>
7
- </a>
8
- </div>