decidim-comments 0.31.0.rc2 → 0.31.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b4b97715de8ec9ced47e41a439ad51845c4ac77da00020a895c90a8f1c832a0
4
- data.tar.gz: 00cb8361b83fcc45b7ad2ea1484b9f7b4086ddc147854d92941e22155c858464
3
+ metadata.gz: f5e4186412267c1d490b61e28cb302d2ff11b7c162b2012306b36b74a87c6eb6
4
+ data.tar.gz: 6a3ae0d23d4917e2e8e6cd2fdef71d16b503f04bcc348e014194cf1381116139
5
5
  SHA512:
6
- metadata.gz: e6261221f7608369314da6bf06f4760cb63819a77e7f213548b0a9c2af33b7a586e9519d631e6e3730c9a3550a012455eb02a03bc98cffebd7a6481c00f556b1
7
- data.tar.gz: 4fb68f7d05cccddb6ad497074a3506d6b2d6c1f1572e667d27443e5e31334941f2703a9792778bd8ba5945e63afb81d8b227ad3f9956083121ef5f3c7859c866
6
+ metadata.gz: 5aedd08f5540046b8494b47cfe19c96d58a42f01a0d9ce6cf4de8f0674bf08ea9d697ebbdea836bd93e4af6c6aea731cfa1c44527b465de76861500275d730ec
7
+ data.tar.gz: 6c0fea854c82c501f661b13b78cb586b73acc8e4ec5475afdda1cc3f4e32167e51a434828e54949f9a0c9f0351479b2b4d1804ec42940eef343a4339365448e9
@@ -144,8 +144,10 @@ module Decidim
144
144
 
145
145
  if root_commentable.respond_to?(:polymorphic_resource_url)
146
146
  root_commentable.polymorphic_resource_url(url_params)
147
- else
147
+ elsif root_commentable.respond_to?(:reported_content_url)
148
148
  root_commentable.reported_content_url(url_params)
149
+ else
150
+ "/"
149
151
  end
150
152
  end
151
153
 
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UpdateUserGroupsReferences < ActiveRecord::Migration[7.2]
4
+ def up
5
+ Rails.logger.info "Starting comment body updates..."
6
+
7
+ updated_count = 0
8
+ skipped_count = 0
9
+ error_count = 0
10
+
11
+ Decidim::Comments::Comment.find_each do |comment|
12
+ next if comment.body.blank?
13
+
14
+ updated_body = process_comment_body(comment.body)
15
+ body_changed = updated_body != comment.body
16
+
17
+ if body_changed
18
+ comment.update_column(:body, updated_body) # rubocop:disable Rails/SkipsModelValidations
19
+ updated_count += 1
20
+ Rails.logger.info "✓ Updated comment ##{comment.id}"
21
+ else
22
+ skipped_count += 1
23
+ end
24
+ rescue StandardError => e
25
+ error_count += 1
26
+ Rails.logger.error "✗ Error updating comment ##{comment.id}: #{e.message}"
27
+ end
28
+
29
+ log_summary(updated_count, skipped_count, error_count)
30
+ end
31
+
32
+ def down
33
+ raise ActiveRecord::IrreversibleMigration
34
+ end
35
+
36
+ private
37
+
38
+ def process_comment_body(body)
39
+ updated_body = {}
40
+
41
+ body.each do |locale, text|
42
+ updated_body[locale] = if locale == "machine_translations" && text.is_a?(Hash)
43
+ process_machine_translations(text)
44
+ else
45
+ replace_user_group_references(text)
46
+ end
47
+ end
48
+
49
+ updated_body
50
+ end
51
+
52
+ def process_machine_translations(translations)
53
+ updated_translations = {}
54
+
55
+ translations.each do |translation_locale, translation_text|
56
+ next if translation_text.blank?
57
+
58
+ updated_translations[translation_locale] = replace_user_group_references(translation_text)
59
+ end
60
+
61
+ updated_translations
62
+ end
63
+
64
+ def replace_user_group_references(text)
65
+ return text if text.blank?
66
+
67
+ text.gsub(
68
+ %r{gid://([^/]+)/Decidim::UserGroup/(\d+)},
69
+ 'gid://\1/Decidim::User/\2'
70
+ )
71
+ end
72
+
73
+ def log_summary(updated_count, skipped_count, error_count)
74
+ Rails.logger.info "=" * 50
75
+ Rails.logger.info "Comment body update completed!"
76
+ Rails.logger.info "=" * 50
77
+ Rails.logger.info "Updated: #{updated_count}"
78
+ Rails.logger.info "Skipped: #{skipped_count}"
79
+ Rails.logger.info "Errors: #{error_count}"
80
+ Rails.logger.info "=" * 50
81
+ end
82
+ end
@@ -59,6 +59,12 @@ module Decidim
59
59
  Decidim.icons.register(name: "edit-line", icon: "edit-line", description: "Edit comment button", **common_parameters)
60
60
  end
61
61
 
62
+ initializer "decidim_comments.data_migrate", after: "decidim_core.data_migrate" do
63
+ DataMigrate.configure do |config|
64
+ config.data_migrations_path << root.join("db/data").to_s
65
+ end
66
+ end
67
+
62
68
  initializer "decidim_comments.register_resources" do
63
69
  Decidim.register_resource(:comment) do |resource|
64
70
  resource.model_class_name = "Decidim::Comments::Comment"
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-comments version.
5
5
  module Comments
6
6
  def self.version
7
- "0.31.0.rc2"
7
+ "0.31.0"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-comments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0.rc2
4
+ version: 0.31.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: 2025-10-28 00:00:00.000000000 Z
13
+ date: 2025-11-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-core
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.31.0.rc2
21
+ version: 0.31.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.31.0.rc2
28
+ version: 0.31.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: redcarpet
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -52,28 +52,28 @@ dependencies:
52
52
  requirements:
53
53
  - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 0.31.0.rc2
55
+ version: 0.31.0
56
56
  type: :development
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: 0.31.0.rc2
62
+ version: 0.31.0
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: decidim-dev
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 0.31.0.rc2
69
+ version: 0.31.0
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - '='
75
75
  - !ruby/object:Gem::Version
76
- version: 0.31.0.rc2
76
+ version: 0.31.0
77
77
  description: Pluggable comments system for some components.
78
78
  email:
79
79
  - josepjaume@gmail.com
@@ -253,6 +253,7 @@ files:
253
253
  - config/locales/vi.yml
254
254
  - config/locales/zh-CN.yml
255
255
  - config/locales/zh-TW.yml
256
+ - db/data/20251117070404_update_user_groups_references.rb
256
257
  - db/migrate/20161130143508_create_comments.rb
257
258
  - db/migrate/20161214082645_add_depth_to_comments.rb
258
259
  - db/migrate/20161216102820_add_alignment_to_comments.rb