decidim-comments 0.32.2 → 0.32.3

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: b40d0d4aa990d69cab616ffb20bad1edb97444b272c50eafde6e089138c84e24
4
- data.tar.gz: 946410858a7a66fef57f4bd8b37d7c7e218f4aef0664720ce3287d13d6ef7cfc
3
+ metadata.gz: 5f7047fc91db47a33c578eb418293109690463145e6489bfb4905f41675328d5
4
+ data.tar.gz: 47a7f23562c90b50ffd7a58b908ed92a3a837f03ce66bec55e1a0388fad7df77
5
5
  SHA512:
6
- metadata.gz: 9382b8a728a8af2319248331a512cb34b38a040a5a32224f700df44bc53ce1daba67024d41582c6df73a218118d2ab5c268f177cb2364aa6c1be488f79f57db4
7
- data.tar.gz: 9c658b3a40f3531db3aab30887639b6199e2a339202fa2e469f18199178101b7aeba1b523f4d23711cd0e923e7f0d0e7073781d115bd8f7dd38205d0a031cfc9
6
+ metadata.gz: b8f2a232c09dd855515be00b9244e94b488693df1290132d012a0cf99ee2ee9c9e884e24723c43e736bbc4b7f97c6a620bc47386a6c1056531cbf2d29eba3101
7
+ data.tar.gz: 171c16f53238eafa5f1b3ccc73e0eff270ce4d2bdd06ed2ac32178f79a7f17de5339527ea73a8837a72fd569a903458d5f528c82ca8254864a886dbb94cbba77
@@ -144,14 +144,18 @@ module Decidim
144
144
 
145
145
  def set_commentable
146
146
  @commentable ||= if commentable_gid
147
- GlobalID::Locator.locate_signed(commentable_gid)
147
+ resource = GlobalID::Locator.locate_signed(commentable_gid)
148
+ ensure_in_organization!(resource)
149
+ resource
148
150
  elsif comment
149
151
  comment.root_commentable
150
152
  end
151
153
  end
152
154
 
153
155
  def set_comment
154
- @comment = Decidim::Comments::Comment.find_by(id: params[:id])
156
+ @comment = Decidim::Comments::Comment
157
+ .for_organization(organization: current_organization)
158
+ .find(params.expect(:id))
155
159
  end
156
160
 
157
161
  def ensure_commentable!
@@ -34,7 +34,9 @@ module Decidim
34
34
  attr_reader :comment
35
35
 
36
36
  def set_comment
37
- @comment = Decidim::Comments::Comment.find_by(id: params[:comment_id])
37
+ @comment = Decidim::Comments::Comment
38
+ .for_organization(organization: current_organization)
39
+ .find(params.expect(:comment_id))
38
40
  end
39
41
  end
40
42
  end
@@ -59,6 +59,14 @@ module Decidim
59
59
 
60
60
  scope :not_deleted, -> { where(deleted_at: nil) }
61
61
 
62
+ # Scopes comments to the participatory spaces owned by the organization.
63
+ # Comments on resources store their participatory space, while comments
64
+ # on participatory spaces use the space itself as the root commentable.
65
+ def self.for_organization(organization:)
66
+ spaces = organization.participatory_spaces
67
+ where(participatory_space: spaces).or(where(root_commentable: spaces))
68
+ end
69
+
62
70
  translatable_fields :body
63
71
  searchable_fields({
64
72
  participatory_space: :itself,
@@ -194,7 +194,7 @@ ca:
194
194
  email_intro: Has estat esmentada
195
195
  email_outro: Has rebut aquesta notificació perquè t'han esmentat al comentari "%{resource_title}".
196
196
  email_subject: Has estat esmentada a %{resource_title}
197
- notification_title: T'han esmentat per <a href="%{author_path}">%{author_name}</a> a <a href="%{resource_path}">%{resource_title}</a>
197
+ notification_title: <a href="%{author_path}">%{author_name}</a> t'ha esmentat a <a href="%{resource_path}">%{resource_title}</a>
198
198
  errors:
199
199
  messages:
200
200
  cannot_have_comments: no es poden fer comentaris
@@ -61,8 +61,8 @@ eu:
61
61
  neutral_selected: Zure iritzia gai honi buruz neutroa da
62
62
  positive: Positiboa
63
63
  positive_selected: Zure iritzia gai honi buruz positiboa da
64
- remaining_characters: "%{count} kakaktere geratzen dira"
65
- remaining_characters_1: "%{count} kakaktere geratzen dira"
64
+ remaining_characters: "Karaktere %{count} geratzen da"
65
+ remaining_characters_1: "%{count} karaktere geratzen dira"
66
66
  title: Gehitu zure iruzkina
67
67
  comment:
68
68
  alignment:
@@ -97,11 +97,11 @@ eu:
97
97
  does_not_belong: Bertan badago legez kontrako jardunik, suizidio-mehatxurik, informazio pertsonalik edo beste zernahi, zure ustez %{organization_name}-ri ez dagokionik.
98
98
  offensive: Arrazakeria, sexismoa, laidoak, eraso pertsonalak, heriotza-mehatxuak, suizidio eskaerak edo gorrotozko edozein diskurtso.
99
99
  spam: Bertan badago clickbait-ik, publizitaterik edo iruzurrik.
100
- title: Jakinarazi eduki desegokia
100
+ title: Eduki desegokia salatu
101
101
  show_replies:
102
- one: Erakutsi %{count} erantzun
102
+ one: Erakutsi erantzun %{count}
103
103
  other: Erakutsi %{count} erantzun
104
- single_comment_link_title: Lortu esteka
104
+ single_comment_link_title: Esteka lortu
105
105
  sort_by: 'Nork sortua:'
106
106
  comment_order_selector:
107
107
  order:
@@ -123,7 +123,7 @@ eu:
123
123
  single_comment_warning: <a href="%{url}"> iruzkin guztiak ikusgai </a>
124
124
  single_comment_warning_title: Iruzkin bakar bat ikusten ari zara
125
125
  title:
126
- one: "Iruzkin bat"
126
+ one: "Iruzkin %{count}"
127
127
  other: "%{count} iruzkin"
128
128
  top_comment_label: Babes gehien galdu dituztenak
129
129
  down_vote_button:
@@ -148,9 +148,9 @@ eu:
148
148
  help:
149
149
  comment_votes:
150
150
  comment: Bozkatutako iruzkinaren identifikazioa
151
- created_at: Zein datatan sortu zen bozketa hau
151
+ created_at: Zein datatan sortu den bozketa hau
152
152
  id: Babesaren identifikazioa
153
- updated_at: Zein datatan eguneratu zen azken aldiz bozketa hau
153
+ updated_at: Zein datatan eguneratu den azken aldiz bozketa hau
154
154
  weight: Babesaren balioa (1 boto gehiago, -1 boto gutxiago)
155
155
  comments:
156
156
  alignment: Iruzkin hau aldekoa bazen, kontrakoa edo neutrala
@@ -158,7 +158,7 @@ eu:
158
158
  body: Iruzkina bera
159
159
  commentable_id: Iruzkingarriaren identifikazio bakarra
160
160
  commentable_type: Iruzkingarri mota (emaitza, proposamena... bazen)
161
- created_at: Zein datatan sortu zen iruzkin hau
161
+ created_at: Zein datatan sortu den iruzkin hau
162
162
  depth: Zein lekutan dago iruzkin hau hiru iruzkinetan (iruzkinaren erantzuna bada edo erantzunaren erantzuna bada)
163
163
  id: Identifikazioa iruzkin honetarako
164
164
  locale: Parte-hartzaileak iruzkin hau uztean erabili du tokiko hizkuntza
@@ -146,6 +146,7 @@ fr-CA:
146
146
  comment_votes:
147
147
  id: L'id du vote
148
148
  comments:
149
+ author: Le nom du participant qui a laissé ce commentaire
149
150
  body: Le commentaire lui-même
150
151
  commentable_id: L'identifiant unique de l"élément commenté
151
152
  commentable_type: Le type de l'élément commenté (si c'était un résultat, une proposition, etc.)
@@ -185,10 +185,12 @@ sk:
185
185
  email_intro: "%{author_name} komentoval na %{resource_title}. Môžete si to prečítať na stránke:"
186
186
  email_outro: Túto notifikáciu ste dostali, pretože sledujete autora "%{author_name}". Notifikácie môžete zrušiť po kliknutí na predchádzajúci odkaz.
187
187
  email_subject: Je nový komentár od %{author_name} na %{resource_title}
188
+ notification_title: V <a href="%{resource_path}">%{resource_title}</a> je nový komentár od <a href="%{author_path}">%{author_name}</a>.
188
189
  comment_created:
189
190
  email_intro: "%{resource_title} bol okomentovaný. Komentár si môžete prečítať na stránke:"
190
191
  email_outro: Túto notifikáciu ste dostali, pretože sledujete "%{resource_title}" alebo autora. Notifikácie môžete zrušiť po kliknutí na predchádzajúci odkaz.
191
192
  email_subject: Je nový komentár od %{author_name} na %{resource_title}
193
+ notification_title: V <a href="%{resource_path}">%{resource_title}</a> je nový komentár od <a href="%{author_path}">%{author_name}</a>
192
194
  comment_downvoted:
193
195
  email_intro: Váš komentár v „%{resource_title}“ získal negatívny hlas. Teraz má celkovo %{upvotes} pozitívnych hlasov a %{downvotes} negatívnych hlasov.
194
196
  email_outro: Toto upozornenie ste dostali, pretože ste autorom tohto komentára.
@@ -203,10 +205,12 @@ sk:
203
205
  email_intro: "%{author_name} odpovedal na váš komentár na %{resource_title}. Môžete si to prečítať na stránke:"
204
206
  email_outro: Túto notifikáciu ste dostali, pretože niekto odpovedal na Váš komentár.
205
207
  email_subject: "%{author_name} odpovedal na Váš komentár na %{resource_title}"
208
+ notification_title: <a href="%{author_path}">%{author_name}</a> odpovedal/a na váš komentár v <a href="%{resource_path}">%{resource_title}</a>
206
209
  user_mentioned:
207
210
  email_intro: Niekto vás spomenul
208
211
  email_outro: Túto notifikáciu ste dostali, pretože ste boli spomenutí na %{resource_title}.
209
212
  email_subject: Boli ste spomenutí na %{resource_title}
213
+ notification_title: <a href="%{author_path}">%{author_name}</a> vás spomenul/a v <a href="%{resource_path}">%{resource_title}</a>
210
214
  errors:
211
215
  messages:
212
216
  cannot_have_comments: nemôže mať komentáre
@@ -3,7 +3,7 @@
3
3
  $LOAD_PATH.push File.expand_path("lib", __dir__)
4
4
 
5
5
  Gem::Specification.new do |s|
6
- version = "0.32.2"
6
+ version = "0.32.3"
7
7
  s.version = version
8
8
  s.authors = ["Josep Jaume Rey Peroy", "Marc Riera Casals", "Oriol Gual Oliva"]
9
9
  s.email = ["josepjaume@gmail.com", "mrc2407@gmail.com", "oriolgual@gmail.com"]
@@ -22,7 +22,7 @@ module Decidim
22
22
 
23
23
  @organization = resource.organization
24
24
 
25
- rand(0..config_value(:comments_count)).times do
25
+ config_value(:comments_count).times do
26
26
  comment1 = create_comment(resource)
27
27
  NewCommentNotificationCreator.new(comment1, []).create
28
28
 
@@ -43,7 +43,10 @@ module Decidim
43
43
  attr_reader :organization
44
44
 
45
45
  def config_value(key)
46
- slow_seeds? ? Decidim::Seeds::SEEDS_CONFIG[key][:slow] : Decidim::Seeds::SEEDS_CONFIG[key][:fast]
46
+ value = slow_seeds? ? Decidim::Seeds::SEEDS_CONFIG[key][:slow] : Decidim::Seeds::SEEDS_CONFIG[key][:fast]
47
+ return rand(value) if value.is_a?(Range)
48
+
49
+ value
47
50
  end
48
51
 
49
52
  def slow_seeds?
@@ -60,10 +63,13 @@ module Decidim
60
63
  # @return [Decidim::Comments::Comment]
61
64
  def create_comment(resource, root_commentable = nil)
62
65
  author = random_user
66
+ root = root_commentable || resource
67
+ space = root.respond_to?(:participatory_space) ? root.participatory_space : root
63
68
 
64
69
  params = {
65
70
  commentable: resource,
66
- root_commentable: root_commentable || resource,
71
+ root_commentable: root,
72
+ participatory_space: space,
67
73
  body: { en: ::Faker::Lorem.sentence(word_count: 50) },
68
74
  author:
69
75
  }
@@ -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.32.2"
7
+ "0.32.3"
8
8
  end
9
9
  end
10
10
  end
@@ -18,6 +18,7 @@ module Decidim
18
18
  autoload :CommentVoteSerializer, "decidim/comments/comment_vote_serializer"
19
19
  autoload :Export, "decidim/comments/export"
20
20
  autoload :Markdown, "decidim/comments/markdown"
21
+ autoload :Seed, "decidim/comments/seed"
21
22
 
22
23
  def self.data_portable_entities
23
24
  ["Decidim::Comments::Comment", "Decidim::Comments::CommentVote"]
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.32.2
4
+ version: 0.32.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.32.2
20
+ version: 0.32.3
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 0.32.2
27
+ version: 0.32.3
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: redcarpet
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -51,28 +51,28 @@ dependencies:
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.32.2
54
+ version: 0.32.3
55
55
  type: :development
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.32.2
61
+ version: 0.32.3
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: decidim-dev
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.32.2
68
+ version: 0.32.3
69
69
  type: :development
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 0.32.2
75
+ version: 0.32.3
76
76
  description: Pluggable comments system for some components.
77
77
  email:
78
78
  - josepjaume@gmail.com
@@ -138,7 +138,6 @@ files:
138
138
  - app/models/decidim/comments/application_record.rb
139
139
  - app/models/decidim/comments/comment.rb
140
140
  - app/models/decidim/comments/comment_vote.rb
141
- - app/models/decidim/comments/seed.rb
142
141
  - app/packs/entrypoints/decidim_comments.js
143
142
  - app/packs/src/decidim/comments/comments.component.js
144
143
  - app/packs/src/decidim/comments/comments.component.test.js
@@ -298,6 +297,7 @@ files:
298
297
  - lib/decidim/comments/markdown.rb
299
298
  - lib/decidim/comments/mutation_extensions.rb
300
299
  - lib/decidim/comments/query_extensions.rb
300
+ - lib/decidim/comments/seed.rb
301
301
  - lib/decidim/comments/test.rb
302
302
  - lib/decidim/comments/test/factories.rb
303
303
  - lib/decidim/comments/test/shared_examples/comment_event.rb