decidim-comments 0.27.5 → 0.27.7

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: f9358ab00be362546c8204c5b2ffc107f1d710fdf0cbabdc87b2bbd3b43d9391
4
- data.tar.gz: 651e755e4d6d217445f3ea245ccccdde990fe47d5e8f965a61716c5d2a7c9ba9
3
+ metadata.gz: 51edbf42c7b41e161bd06ffbd91e140e3e2c59eebbcb5b772bf5b9af87770ac2
4
+ data.tar.gz: 9218caa3cd9c6e3dcba830dff6fc7538c62de2d7734aaf8e84e440b080d12c0e
5
5
  SHA512:
6
- metadata.gz: a4d11d18533c35dc3b3844db27eb5dede7ee92174fae244f11ec581c5546afb61927a936976fd9c75db349662a3e11112fd730fd01dfd0e96af1a1d3828b139b
7
- data.tar.gz: 711efd02fb29aa17f83c50ad16f8913d252402907ef12355d6db63fddfbd72102f2f292b96b545e3f3b15049b5e5e71d50271ec0719538eb316989ce593f4df9
6
+ metadata.gz: 92a013f29c56999c3a7a6e61e532927e569260dce55334a67719aae7354efe8889f455bb92dee8bd8725b49d6bdce0a1c2c393df7ca93525e1891bce5ef27533
7
+ data.tar.gz: db1e81f716eb264207c2e66ae1e8f341221b2639cada634412de2e00b5279d2061b00c76f1c27c6c2c867ae6b438deed79777d6cb24c91e5d762c58bf5cca3d6
@@ -47,6 +47,8 @@ module Decidim
47
47
  hash.push(model.must_render_translation?(current_organization) ? 1 : 0)
48
48
  hash.push(model.authored_by?(current_user) ? 1 : 0)
49
49
  hash.push(model.reported_by?(current_user) ? 1 : 0)
50
+ hash.push(model.up_votes_count)
51
+ hash.push(model.down_votes_count)
50
52
  hash.push(model.cache_key_with_version)
51
53
  hash.push(model.author.cache_key_with_version)
52
54
  @hash = hash.join(Decidim.cache_key_separator)
@@ -146,11 +148,11 @@ module Decidim
146
148
  end
147
149
 
148
150
  def up_votes_count
149
- model.up_votes.count
151
+ model.up_votes_count
150
152
  end
151
153
 
152
154
  def down_votes_count
153
- model.down_votes.count
155
+ model.down_votes_count
154
156
  end
155
157
 
156
158
  def root_depth
@@ -166,11 +168,11 @@ module Decidim
166
168
  end
167
169
 
168
170
  def voted_up?
169
- model.up_voted_by?(current_user)
171
+ @up_voted ||= model.up_voted_by?(current_user)
170
172
  end
171
173
 
172
174
  def voted_down?
173
- model.down_voted_by?(current_user)
175
+ @down_voted ||= model.down_voted_by?(current_user)
174
176
  end
175
177
 
176
178
  def nested?
@@ -15,6 +15,10 @@ module Decidim
15
15
  Decidim::ContentProcessor.render(sanitize_content(render_markdown(translated_body)), "div")
16
16
  end
17
17
 
18
+ def hidden_resource?
19
+ super || (comment.respond_to?(:hidden?) && comment.hidden?)
20
+ end
21
+
18
22
  def author
19
23
  comment.normalized_author
20
24
  end
@@ -29,6 +29,7 @@ module Decidim
29
29
  translatable_fields :body
30
30
 
31
31
  parent_item_foreign_key :decidim_commentable_id
32
+ parent_item_polymorphic_type_key :decidim_commentable_type
32
33
 
33
34
  belongs_to :commentable, foreign_key: "decidim_commentable_id", foreign_type: "decidim_commentable_type", polymorphic: true
34
35
  belongs_to :root_commentable, foreign_key: "decidim_root_commentable_id", foreign_type: "decidim_root_commentable_type", polymorphic: true, touch: true
@@ -121,14 +122,14 @@ module Decidim
121
122
  #
122
123
  # Returns a bool value to indicate if the condition is truthy or not
123
124
  def up_voted_by?(user)
124
- up_votes.any? { |vote| vote.author == user }
125
+ up_votes.exists?(author: user)
125
126
  end
126
127
 
127
128
  # Public: Check if the user has downvoted the comment
128
129
  #
129
130
  # Returns a bool value to indicate if the condition is truthy or not
130
131
  def down_voted_by?(user)
131
- down_votes.any? { |vote| vote.author == user }
132
+ down_votes.exists?(author: user)
132
133
  end
133
134
 
134
135
  # Public: Overrides the `reported_content_url` Reportable concern method.
@@ -14,12 +14,22 @@ module Decidim
14
14
  validates :weight, inclusion: { in: [-1, 1] }
15
15
  validate :author_and_comment_same_organization
16
16
 
17
+ after_create :update_comment_votes_count
18
+ after_destroy :update_comment_votes_count
19
+
17
20
  def self.export_serializer
18
21
  Decidim::Comments::CommentVoteSerializer
19
22
  end
20
23
 
21
24
  private
22
25
 
26
+ def update_comment_votes_count
27
+ up_votes_count = self.class.where(decidim_comment_id: comment.id, weight: 1).count
28
+ down_votes_count = self.class.where(decidim_comment_id: comment.id, weight: -1).count
29
+
30
+ comment.update(up_votes_count: up_votes_count, down_votes_count: down_votes_count)
31
+ end
32
+
23
33
  # Private: check if the comment and the author have the same organization
24
34
  def author_and_comment_same_organization
25
35
  return unless author.present? && comment.present?
@@ -4,4 +4,170 @@ bg:
4
4
  models:
5
5
  decidim/comments/comment_by_followed_user_event: Коментар
6
6
  decidim/comments/comment_created_event: Коментар
7
+ decidim/comments/comment_upvoted_event: Коментарът е одобрен
7
8
  decidim/comments/reply_created_event: Отговор на коментар
9
+ decidim/comments/user_group_mentioned_event: Споменаване
10
+ decidim/comments/user_mentioned_event: Споменаване
11
+ activerecord:
12
+ models:
13
+ decidim/comments/comment:
14
+ one: Коментар
15
+ other: Коментари
16
+ decidim/comments/comment_vote:
17
+ one: Глас
18
+ other: Гласове
19
+ decidim:
20
+ comments:
21
+ admin:
22
+ shared:
23
+ availability_fields:
24
+ enabled: Коментарите са активирани
25
+ end_time: Коментарите са активирани до
26
+ start_time: Коментарите са активирани от
27
+ comments:
28
+ create:
29
+ error: Възникна проблем при създаването на коментара.
30
+ delete:
31
+ error: Коментарът не можа да бъде изтрит.
32
+ update:
33
+ error: Възникна проблем при актуализирането на коментара.
34
+ comments_count: Брой коментари
35
+ comments_title: Коментари
36
+ last_activity:
37
+ new_comment_at_html: "<span>Нов коментар на %{link}</span>"
38
+ view: Преглед
39
+ votes:
40
+ create:
41
+ error: Възникна проблем с гласуването за коментара.
42
+ components:
43
+ add_comment_form:
44
+ account_message: <a href="%{sign_in_url}">Влезте с Вашия профил</a> или <a href="%{sign_up_url}">се регистрирайте</a>, за да добавите коментара си.
45
+ form:
46
+ body:
47
+ label: Коментар
48
+ placeholder: Какво мислите за това?
49
+ form_error: Текстът е задължителен и не може да е по-дълъг от %{length} символа.
50
+ submit: Изпрати
51
+ user_group_id:
52
+ label: Коментирайте като
53
+ opinion:
54
+ label: Вашето мнение по тази тема
55
+ negative: Негативно
56
+ negative_selected: Вашето мнение по тази тема е негативно
57
+ neutral: Неутрално
58
+ neutral_selected: Вашето мнение по тази тема е неутрално
59
+ positive: Позитивно
60
+ positive_selected: Вашето мнение по тази тема е позитивно
61
+ remaining_characters: "Оставащи символи: %{count}"
62
+ remaining_characters_1: "%{count} оставащ символ"
63
+ title: Добавете Вашия коментар
64
+ comment:
65
+ alignment:
66
+ against: Против
67
+ in_favor: Подкрепям
68
+ confirm_destroy: Сигурни ли сте, че искате да изтриете този коментар?
69
+ delete: Изтрий
70
+ deleted_at: Коментарът е изтрит на %{date}
71
+ deleted_user: Изтрит участник
72
+ edit: Редактирай
73
+ edited: Редактирано
74
+ hide_replies: Скриване на отговорите
75
+ moderated_at: Коментарът е модериран на %{date}
76
+ reply: Отговори
77
+ report:
78
+ action: Доклад
79
+ already_reported: Това съдържание вече е докладвано и ще бъде прегледано от администратор.
80
+ close: Затвори
81
+ description: Това съдържание неподходящо ли е?
82
+ details: Допълнителни коментари
83
+ reasons:
84
+ does_not_belong: Съдържа незаконни дейности, заплахи за самоубийство, лична информация или нещо друго, което считате, че е неподходящо за %{organization_name}.
85
+ offensive: Съдържа расизъм, сексизъм, злословия, лични атаки, заплахи за смърт, заявки за самоубийство или всякаква форма на омраза.
86
+ spam: Съдържа примамка за кликване, реклама, измами или скриптове.
87
+ title: Докладване за неподходящо съдържание
88
+ show_replies:
89
+ one: Показване на отговора
90
+ other: Показване на %{count} отговора
91
+ single_comment_link_title: Вземете линка
92
+ comment_order_selector:
93
+ order:
94
+ best_rated: С най-висока оценка
95
+ most_discussed: Най-обсъждани
96
+ older: По-старо
97
+ recent: Скорошни
98
+ title: 'Подреди по:'
99
+ comment_thread:
100
+ title: Разговор с %{authorName}
101
+ comments:
102
+ blocked_comments_for_unauthorized_user_warning: Трябва да сте верифицирани, за да коментирате в този момент, но можете да прочетете предишните.
103
+ blocked_comments_for_user_warning: Понастоящем не можете да коментирате, но можете да прочетете предходните коментари.
104
+ blocked_comments_warning: Коментарите в момента са деактивирани, но можете да прочетете предишните.
105
+ comment_details_title: Детайли за коментара
106
+ loading: Коментарите се зареждат...
107
+ single_comment_warning: <a href="%{url}">Вижте всички коментари</a>
108
+ single_comment_warning_title: Виждате единичен коментар
109
+ title:
110
+ one: "%{count} коментар"
111
+ other: "%{count} коментари"
112
+ down_vote_button:
113
+ text: Не съм съгласен с този коментар
114
+ edit_comment_modal_form:
115
+ close: Затвори
116
+ form:
117
+ body:
118
+ label: Коментар
119
+ placeholder: Какво мислите за това?
120
+ submit: Изпрати
121
+ title: Редактирайте Вашия коментар
122
+ up_vote_button:
123
+ text: Съгласен съм с този коментар
124
+ events:
125
+ comments:
126
+ comment_by_followed_user:
127
+ email_intro: "%{author_name} остави коментар в %{resource_title}. Можете да го прочетете на тази страница:"
128
+ email_outro: Получихте това известие, защото следвате %{author_name}. Можете да спрете да следвате този потребител от страницата на неговия профил.
129
+ email_subject: Има нов коментар от %{author_name} в(ъв) %{resource_title}
130
+ notification_title: Има нов коментар от <a href="%{author_path}">%{author_name} %{author_nickname}</a> в(ъв) <a href="%{resource_path}">%{resource_title}</a>.
131
+ comment_by_followed_user_group:
132
+ email_intro: 'Групата %{author_name} остави коментар в(ъв) %{resource_title}. Можете да го прочетете на следната страница:'
133
+ email_outro: Получавате това известие, защото следвате %{author_name}. Можете да спрете да следвате тази група от страницата на профила ѝ.
134
+ email_subject: Има нов коментар от %{author_name} в(ъв) %{resource_title}
135
+ notification_title: Има нов коментар от <a href="%{author_path}">%{author_name} %{author_nickname}</a> в(ъв) <a href="%{resource_path}">%{resource_title}</a>.
136
+ comment_created:
137
+ email_intro: "%{resource_title} получи коментар. Можете да прочетете коментара на тази страница:"
138
+ email_outro: Получавате това известие, защото следвате „%{resource_title}“ или неговия автор. Можете да прекратите следването от предходната връзка.
139
+ email_subject: Има нов коментар от %{author_name} по %{resource_title}
140
+ notification_title: Има нов коментар от <a href="%{author_path}">%{author_name} %{author_nickname}</a> по <a href="%{resource_path}">%{resource_title}</a>
141
+ comment_downvoted:
142
+ email_intro: Вашият коментар в „%{resource_title}“ беше гласуван против. Вече има общо %{upvotes} гласа за и %{downvotes} гласа против.
143
+ email_outro: Получихте това известие, защото вие сте авторът на този коментар.
144
+ email_subject: Вашият коментар в „%{resource_title}“ беше гласуван против.
145
+ notification_title: Вашият <a href="%{resource_path}">коментар</a> в „%{resource_title}“ беше гласуван против. Вече има общо %{upvotes} гласа за и %{downvotes} гласа против.
146
+ comment_upvoted:
147
+ email_intro: Коментарът ви в „%{resource_title}“ беше гласуван в подкрепа. Вече има общо %{upvotes} гласа за и %{downvotes} гласа против.
148
+ email_outro: Получихте това известие, защото вие сте авторът на този коментар.
149
+ email_subject: Коментарът ви в „%{resource_title}“ беше гласуван в подкрепа.
150
+ notification_title: Вашият <a href="%{resource_path}">коментар</a> в „%{resource_title}“ получи положителен глас. Вече има общо %{upvotes} гласа за и %{downvotes} гласа против.
151
+ reply_created:
152
+ email_intro: "%{author_name} отговори на вашия коментар в %{resource_title}. Можете да го прочетете на тази страница:"
153
+ email_outro: Получавате това известие, защото някой отговори на коментара Ви.
154
+ email_subject: "%{author_name} отговори на коментара Ви по %{resource_title}"
155
+ notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> отговори на коментара Ви по <a href="%{resource_path}">%{resource_title}</a>
156
+ user_group_mentioned:
157
+ email_intro: Група, към която принадлежите, беше спомената
158
+ email_outro: Получавате това известие, защото сте член на групата %{group_name}, която беше спомената в(ъв) %{resource_title}.
159
+ email_subject: Бяхте споменати в(ъв) %{resource_title} като член на %{group_name}
160
+ notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> Ви спомена в(ъв) <a href="%{resource_path}">%{resource_title}</a> като член на <a href="%{group_path}">%{group_name} %{group_nickname}</a>
161
+ user_mentioned:
162
+ email_intro: Бяхте споменати
163
+ email_outro: Получавате това известие, защото бяхте споменати в(ъв) %{resource_title}.
164
+ email_subject: Бяхте споменати в(ъв) %{resource_title}
165
+ notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> Ви спомена в(ъв) <a href="%{resource_path}">%{resource_title}</a>
166
+ metrics:
167
+ comments:
168
+ description: Брой коментари генерирани от участници
169
+ object: коментари
170
+ title: Коментари
171
+ errors:
172
+ messages:
173
+ cannot_have_comments: не може да има коментари
@@ -125,27 +125,27 @@ ca:
125
125
  comments:
126
126
  comment_by_followed_user:
127
127
  email_intro: "%{author_name} ha deixat un comentari a %{resource_title}. Podeu llegir-lo en aquesta pàgina:"
128
- email_outro: Has rebut aquesta notificació perquè estàs seguint %{author_name}. Pots deixar de seguir a aquesta participant des de la seva pàgina de perfil.
128
+ email_outro: Has rebut aquesta notificació perquè estàs seguint el comentari "%{author_name}". Pots deixar de seguir a aquesta participant des de la seva pàgina de perfil.
129
129
  email_subject: Hi ha un nou comentari de %{author_name} en %{resource_title}
130
130
  notification_title: Hi ha un nou comentari per <a href="%{author_path}">%{author_name} %{author_nickname}</a> a <a href="%{resource_path}">%{resource_title}</a>.
131
131
  comment_by_followed_user_group:
132
132
  email_intro: '%{author_name} ha deixat un comentari a%{resource_title}. Pots llegir-lo en aquesta pàgina:'
133
- email_outro: Reps aquesta notificació perquè segueixes a %{author_name}. Pots deixar de seguir aquest grup des de la seva pàgina de perfil.
133
+ email_outro: Reps aquesta notificació perquè segueixes a "%{author_name}". Pots deixar de seguir aquest grup des de la seva pàgina de perfil.
134
134
  email_subject: Hi ha un nou comentari de %{author_name} en %{resource_title}
135
135
  notification_title: Hi ha un nou comentari per <a href="%{author_path}">%{author_name} %{author_nickname}</a> a <a href="%{resource_path}">%{resource_title}</a>.
136
136
  comment_created:
137
137
  email_intro: "S'ha comentat %{resource_title}. Pots llegir el comentari d'aquesta pàgina:"
138
- email_outro: Has rebut aquesta notificació perquè estàs seguint "%{resource_title}" o la seva autora. Pots deixar de seguir-la des de l'enllaç anterior.
138
+ email_outro: Has rebut aquesta notificació perquè estàs seguint el comentari "%{resource_title}" o la seva autora. Pots deixar de seguir-la des de l'enllaç anterior.
139
139
  email_subject: Hi ha un nou comentari de %{author_name} a %{resource_title}
140
140
  notification_title: Hi ha un nou comentari de <a href="%{author_path}">%{author_name} %{author_nickname}</a> en <a href="%{resource_path}">%{resource_title}</a>
141
141
  comment_downvoted:
142
142
  email_intro: El teu comentari a "%{resource_title}" ha rebut un vot negatiu. Ara té un total de %{upvotes} vots positius i %{downvotes} vots negatius.
143
- email_outro: Has rebut aquesta notificació perquè ets autora d'aquest comentari.
143
+ email_outro: Has rebut aquesta notificació perquè vas fer aquest comentari.
144
144
  email_subject: El teu comentari a "%{resource_title}" ha rebut un vot negatiu.
145
145
  notification_title: El teu <a href="%{resource_path}">comentari</a> a "%{resource_title}" ha rebut un vot negatiu. Ara té un total de %{upvotes} vots positius i %{downvotes} vots negatius.
146
146
  comment_upvoted:
147
147
  email_intro: El teu comentari a "%{resource_title}" ha rebut un vot positiu. Ara té un total de %{upvotes} vots positius i %{downvotes} vots negatius.
148
- email_outro: Has rebut aquesta notificació perquè ets autora d'aquest comentari.
148
+ email_outro: Has rebut aquesta notificació perquè vas fer aquest comentari.
149
149
  email_subject: El teu comentari a "%{resource_title}" ha rebut un vot positiu.
150
150
  notification_title: El teu <a href="%{resource_path}">comentari</a> a "%{resource_title}" ha rebut un vot positiu. Ara té un total de %{upvotes} vots positius i %{downvotes} vots negatius.
151
151
  reply_created:
@@ -155,12 +155,12 @@ ca:
155
155
  notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> ha respost el teu comentari a <a href="%{resource_path}">%{resource_title}</a>
156
156
  user_group_mentioned:
157
157
  email_intro: Un grup al qual pertanys ha estat esmentat
158
- email_outro: Has rebut aquesta notificació perquè formes part del grup %{group_name} que ha estat esmentat a %{resource_title}.
158
+ email_outro: Has rebut aquesta notificació perquè formes part del grup "%{group_name}" que ha estat esmentat a %{resource_title}.
159
159
  email_subject: T'han esmentat a %{resource_title} com a membre de %{group_name}
160
160
  notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> t'ha esmentat com a membre de <a href="%{group_path}">%{group_name} %{group_nickname}</a> a <a href="%{resource_path}">%{resource_title}</a>
161
161
  user_mentioned:
162
162
  email_intro: Has estat esmentada
163
- email_outro: Has rebut aquesta notificació perquè has estat esmentada a %{resource_title}.
163
+ email_outro: Has rebut aquesta notificació perquè t'han esmentat al comentari "%{resource_title}".
164
164
  email_subject: Has estat esmentada a %{resource_title}
165
165
  notification_title: Has estat esmentada a <a href="%{resource_path}">%{resource_title}</a> per <a href="%{author_path}">%{author_name} %{author_nickname}</a>
166
166
  metrics:
@@ -125,7 +125,7 @@ es:
125
125
  comments:
126
126
  comment_by_followed_user:
127
127
  email_intro: "%{author_name} ha dejado un comentario en %{resource_title}. Puedes leerlo en esta página:"
128
- email_outro: Has recibido esta notificación porque sigues "%{author_name}". Puedes dejar de seguir a esta participante desde su página de perfil.
128
+ email_outro: Has recibido esta notificación porque sigues a "%{author_name}". Puedes dejar de seguir a esta participante desde su página de perfil.
129
129
  email_subject: Hay un nuevo comentario de %{author_name} en %{resource_title}
130
130
  notification_title: Hay un nuevo comentario de <a href="%{author_path}">%{author_name} %{author_nickname}</a> en <a href="%{resource_path}">%{resource_title}</a>.
131
131
  comment_by_followed_user_group:
@@ -135,32 +135,32 @@ es:
135
135
  notification_title: Hay un nuevo comentario de <a href="%{author_path}">%{author_name} %{author_nickname}</a> en <a href="%{resource_path}">%{resource_title}</a>.
136
136
  comment_created:
137
137
  email_intro: "%{resource_title} ha sido comentado. Puedes leer el comentario en esta página:"
138
- email_outro: Has recibido esta notificación porque está siguiendo "%{resource_title}" o su autora. Puedes dejar de seguirla desde el enlace anterior.
138
+ email_outro: Has recibido esta notificación porque estás siguiendo el comentario "%{resource_title}" o a su autora. Puedes dejar de seguirla desde el enlace anterior.
139
139
  email_subject: Hay un nuevo comentario de %{author_name} en %{resource_title}
140
140
  notification_title: Hay un nuevo comentario de <a href="%{author_path}">%{author_name} %{author_nickname}</a> en <a href="%{resource_path}">%{resource_title}</a>
141
141
  comment_downvoted:
142
142
  email_intro: Tu comentario en "%{resource_title}" ha sido votado negativamente. Ahora tiene un total de %{upvotes} votos positivos y %{downvotes} votos negativos.
143
- email_outro: Has recibido esta notificación porque eres la autora de este comentario.
143
+ email_outro: Has recibido esta notificación porque hiciste este comentario.
144
144
  email_subject: Su comentario en "%{resource_title}" ha sido votado negativamente.
145
145
  notification_title: Tu <a href="%{resource_path}">comentario</a> en "%{resource_title}" ha sido votado negativamente. Ahora tiene un total de %{upvotes} votos positivos y %{downvotes} votos negativos.
146
146
  comment_upvoted:
147
147
  email_intro: Tu comentario en "%{resource_title}" ha sido votado postivamente. Ahora tiene un total de %{upvotes} votos positivos y %{downvotes} votos negativos.
148
- email_outro: Has recibido esta notificación porque eres la autora de este comentario.
148
+ email_outro: Has recibido esta notificación porque hiciste este comentario.
149
149
  email_subject: Tu comentario en "%{resource_title}" ha sido votado positivamente.
150
150
  notification_title: Tu <a href="%{resource_path}">comentario</a> en "%{resource_title}" ha sido votado positivamente. Ahora tiene un total de %{upvotes} votos positivos y %{downvotes} votos negativos.
151
151
  reply_created:
152
152
  email_intro: "%{author_name} ha respondido a tu comentario en %{resource_title}. Puedes leerlo en esta página:"
153
- email_outro: Has recibido esta notificación porque tu comentario fue respondido.
153
+ email_outro: Has recibido esta notificación porque han respondido a tu comentario.
154
154
  email_subject: "%{author_name} ha respondido a tu comentario en %{resource_title}"
155
155
  notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> ha respondido a tu comentario en <a href="%{resource_path}">%{resource_title}</a>
156
156
  user_group_mentioned:
157
157
  email_intro: Se ha mencionado un grupo al que perteneces
158
- email_outro: Has recibido esta notificación porque formas parte del grupo %{group_name} que ha sido mencionado en %{resource_title}.
158
+ email_outro: Has recibido esta notificación porque formas parte del grupo "%{group_name}" que ha sido mencionado en "%{resource_title}".
159
159
  email_subject: Te han mencionado en %{resource_title} como miembro de %{group_name}
160
160
  notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> te ha mencionado en <a href="%{resource_path}">%{resource_title}</a> como miembro de <a href="%{group_path}">%{group_name} %{group_nickname}</a>
161
161
  user_mentioned:
162
162
  email_intro: Has sido mencionada
163
- email_outro: Has recibido esta notificación porque has sido mencionada en %{resource_title}.
163
+ email_outro: Has recibido esta notificación porque te han mencionado en el comentario "%{resource_title}".
164
164
  email_subject: Has sido mencionada en %{resource_title}
165
165
  notification_title: Has sido mencionada en <a href="%{resource_path}">%{resource_title}</a> por <a href="%{author_path}">%{author_name} %{author_nickname}</a>
166
166
  metrics:
@@ -0,0 +1 @@
1
+ he:
@@ -27,6 +27,8 @@ hu:
27
27
  comments:
28
28
  create:
29
29
  error: Hiba történt a hozzászólás létrehozása során.
30
+ delete:
31
+ error: A hozzászólás nem törölhető.
30
32
  update:
31
33
  error: Hiba történt a hozzászólás frissítése során.
32
34
  comments_count: Hozzászólások száma
@@ -45,7 +47,7 @@ hu:
45
47
  label: Megjegyzés
46
48
  placeholder: Mit gondolsz erről?
47
49
  form_error: Kötelező kitölteni, és nem lehet hosszabb, mint %{length} karakter.
48
- submit: Elküld
50
+ submit: Küldés
49
51
  user_group_id:
50
52
  label: 'Megjegyzés mint:'
51
53
  opinion:
@@ -76,6 +76,7 @@ pl:
76
76
  edit: Edytuj
77
77
  edited: Edytowany
78
78
  hide_replies: Ukryj odpowiedzi
79
+ moderated_at: Komentarz moderowany dnia %{date}
79
80
  reply: Odpowiedz
80
81
  report:
81
82
  action: Zgłoś
@@ -71,9 +71,9 @@ ro:
71
71
  delete: Șterge
72
72
  deleted_at: Comentariu șters la %{date}
73
73
  deleted_user: Participant șters
74
- edit: Editează
75
- edited: Editat
76
- hide_replies: Ascunde răspunsurile
74
+ edit: Actualizare
75
+ edited: Actualizat
76
+ hide_replies: Ascundeți răspunsurile
77
77
  moderated_at: Comentariu moderat pe %{date}
78
78
  reply: Răspunde
79
79
  report:
@@ -139,7 +139,7 @@ ro:
139
139
  notification_title: Există un comentariu nou de la <a href="%{author_path}">%{author_name} %{author_nickname}</a> pentru <a href="%{resource_path}">%{resource_title}</a>.
140
140
  comment_created:
141
141
  email_intro: "%{resource_title} a primit un comentariu. Poți citi comentariul pe această pagină:"
142
- email_outro: Ai primit această notificare deoarece urmărești „%{resource_title}” sau pe autorii săi. Poți anula abonarea de la link-ul anterior.
142
+ email_outro: Ați primit această notificare deoarece urmăriți „%{resource_title}” sau pe autorii săi. Puteți anula abonarea de la link-ul anterior.
143
143
  email_subject: Există un nou comentariu de la %{author_name} pentru %{resource_title}
144
144
  notification_title: Există un nou comentariu de la <a href="%{author_path}">%{author_name} %{author_nickname}</a> pentru <a href="%{resource_path}">%{resource_title}</a>
145
145
  comment_downvoted:
@@ -1 +1,39 @@
1
+ ---
1
2
  sq:
3
+ decidim:
4
+ components:
5
+ add_comment_form:
6
+ form:
7
+ user_group_id:
8
+ label: Komento si
9
+ opinion:
10
+ label: Mendimi jot mbi këtë temë
11
+ negative: Negativ
12
+ negative_selected: Mendimi jot mbi këtë temë është negativ
13
+ neutral: Neutral
14
+ neutral_selected: Mendimi jot mbi këtë temë është neutral
15
+ positive: Pozitiv
16
+ positive_selected: Mendimi jot mbi këtë temë është pozitiv
17
+ remaining_characters: "%{count} karaktere të mbetura"
18
+ remaining_characters_1: "%{count} karakter i mbetur"
19
+ title: Shto komentin tënd
20
+ comment:
21
+ alignment:
22
+ against: Kundër
23
+ in_favor: Pro
24
+ confirm_destroy: A je i sigurt që do ta fshish këtë koment?
25
+ delete: Fshi
26
+ deleted_at: Komenti u fshi në datën %{date}
27
+ edit: Përpuno
28
+ edited: Ndryshuar
29
+ hide_replies: Fshih përgjigjet
30
+ moderated_at: Komenti u moderua në datën %{date}
31
+ reply: Përgjigju
32
+ report:
33
+ action: Raporto
34
+ already_reported: Kjo përmbajtje është raportuar nga të tjerë dhe do rishikohet nga administratorët.
35
+ close: Mbyll
36
+ description: Përmbajtje e papërshtatshme?
37
+ details: Komente të tjera
38
+ reasons:
39
+ offensive: Përmban racizëm, seksizëm, ofendime, sulme personale, kërcënime me vdekje, shtyrje për vetëvrasje apo forma të tjera të gjuhës së urrejtjes.
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddCommentVoteCounterCacheToComments < ActiveRecord::Migration[6.1]
4
+ def change
5
+ add_column :decidim_comments_comments, :up_votes_count, :integer, null: false, default: 0, index: true
6
+ add_column :decidim_comments_comments, :down_votes_count, :integer, null: false, default: 0, index: true
7
+
8
+ # We cannot use the reset_counters as up_votes and down_votes are scoped associationws
9
+ reversible do |dir|
10
+ dir.up do
11
+ Decidim::Comments::Comment.reset_column_information
12
+ Decidim::Comments::Comment.find_each do |record|
13
+ # rubocop:disable Rails/SkipsModelValidations
14
+ record.class.update_counters(record.id, up_votes_count: record.up_votes.length)
15
+ record.class.update_counters(record.id, down_votes_count: record.down_votes.length)
16
+ # rubocop:enable Rails/SkipsModelValidations
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path("lib", __dir__)
4
+
5
+ # Maintain your gem's version:
6
+ require "decidim/comments/version"
7
+
8
+ # Describe your gem and declare its dependencies:
9
+ Gem::Specification.new do |s|
10
+ s.version = Decidim::Comments.version
11
+ s.authors = ["Josep Jaume Rey Peroy", "Marc Riera Casals", "Oriol Gual Oliva"]
12
+ s.email = ["josepjaume@gmail.com", "mrc2407@gmail.com", "oriolgual@gmail.com"]
13
+ s.license = "AGPL-3.0"
14
+ s.homepage = "https://github.com/decidim/decidim"
15
+ s.required_ruby_version = "~> 3.0.0"
16
+
17
+ s.name = "decidim-comments"
18
+ s.summary = "Decidim comments module"
19
+ s.description = "Pluggable comments system for some components."
20
+
21
+ s.files = Dir.chdir(__dir__) do
22
+ `git ls-files -z`.split("\x0").select do |f|
23
+ (File.expand_path(f) == __FILE__) ||
24
+ f.start_with?(*%w(app/ config/ db/ lib/ Rakefile README.md))
25
+ end
26
+ end
27
+
28
+ s.add_dependency "decidim-core", Decidim::Comments.version
29
+ s.add_dependency "redcarpet", "~> 3.5", ">= 3.5.1"
30
+
31
+ s.add_development_dependency "decidim-admin", Decidim::Comments.version
32
+ s.add_development_dependency "decidim-dev", Decidim::Comments.version
33
+ end
@@ -58,7 +58,7 @@ module Decidim
58
58
  end
59
59
 
60
60
  def up_votes
61
- object.up_votes.size
61
+ object.up_votes_count
62
62
  end
63
63
 
64
64
  def up_voted
@@ -66,7 +66,7 @@ module Decidim
66
66
  end
67
67
 
68
68
  def down_votes
69
- object.down_votes.size
69
+ object.down_votes_count
70
70
  end
71
71
 
72
72
  def down_voted
@@ -4,8 +4,11 @@ require "decidim/core/test/factories"
4
4
 
5
5
  FactoryBot.define do
6
6
  factory :comment, class: "Decidim::Comments::Comment" do
7
- author { build(:user, organization: commentable.organization) }
8
- commentable { build(:dummy_resource) }
7
+ transient do
8
+ skip_injection { false }
9
+ end
10
+ author { build(:user, organization: commentable.organization, skip_injection: skip_injection) }
11
+ commentable { build(:dummy_resource, skip_injection: skip_injection) }
9
12
  root_commentable { commentable }
10
13
  body { Decidim::Faker::Localized.paragraph }
11
14
  participatory_space { commentable.try(:participatory_space) }
@@ -25,22 +28,32 @@ FactoryBot.define do
25
28
  end
26
29
 
27
30
  trait :comment_on_comment do
28
- author { build(:user, organization: root_commentable.organization) }
31
+ author { build(:user, organization: root_commentable.organization, skip_injection: skip_injection) }
29
32
  commentable do
30
33
  build(
31
34
  :comment,
32
35
  author: author,
33
36
  root_commentable: root_commentable,
34
- commentable: root_commentable
37
+ commentable: root_commentable,
38
+ skip_injection: skip_injection
35
39
  )
36
40
  end
37
- root_commentable { build(:dummy_resource) }
41
+ root_commentable { build(:dummy_resource, skip_injection: skip_injection) }
42
+ end
43
+
44
+ trait :moderated do
45
+ after(:create) do |comment, evaluator|
46
+ create(:moderation, reportable: comment, hidden_at: 2.days.ago, skip_injection: evaluator.skip_injection)
47
+ end
38
48
  end
39
49
  end
40
50
 
41
51
  factory :comment_vote, class: "Decidim::Comments::CommentVote" do
42
- comment { build(:comment) }
43
- author { build(:user, organization: comment.organization) }
52
+ transient do
53
+ skip_injection { false }
54
+ end
55
+ comment { build(:comment, skip_injection: skip_injection) }
56
+ author { build(:user, organization: comment.organization, skip_injection: skip_injection) }
44
57
  weight { [-1, 1].sample }
45
58
 
46
59
  trait :up_vote do
@@ -16,7 +16,7 @@ shared_context "when it's a comment event" do
16
16
  let(:comment_author_name) { decidim_html_escape comment.author.name }
17
17
 
18
18
  let(:extra) { { comment_id: comment.id } }
19
- let(:resource_title) { decidim_html_escape(translated(resource.title)) }
19
+ let(:resource_title) { decidim_sanitize_translated(resource.title) }
20
20
  let(:user_group) do
21
21
  user_group = create(:user_group, :verified, organization: organization, users: [comment_author])
22
22
  comment.update!(user_group: user_group)
@@ -42,4 +42,37 @@ shared_examples_for "a comment event" do
42
42
  expect(subject.resource_text).to eq comment.formatted_body
43
43
  end
44
44
  end
45
+
46
+ describe "hidden_resource?" do
47
+ context "when comment is not moderated" do
48
+ it "returns false" do
49
+ expect(subject.hidden_resource?).to be false
50
+ end
51
+ end
52
+
53
+ context "when comment is moderated" do
54
+ let(:comment) { create(:comment, :moderated) }
55
+
56
+ it "returns true" do
57
+ expect(subject.hidden_resource?).to be true
58
+ end
59
+ end
60
+
61
+ context "when resource is not moderated" do
62
+ it "returns false" do
63
+ expect(subject.hidden_resource?).to be false
64
+ end
65
+ end
66
+
67
+ context "when resource is moderated" do
68
+ before do
69
+ create(:moderation, reportable: resource, hidden_at: 2.days.ago)
70
+ resource.reload
71
+ end
72
+
73
+ it "returns true" do
74
+ expect(subject.hidden_resource?).to be true
75
+ end
76
+ end
77
+ end
45
78
  end
@@ -12,7 +12,7 @@ shared_examples_for "a comment voted event" do
12
12
  let(:comment_vote_author) { comment_vote.author }
13
13
 
14
14
  let(:extra) { { comment_id: comment.id, author_id: comment_vote_author.id, weight: weight, downvotes: 100, upvotes: 999 } }
15
- let(:resource_title) { decidim_html_escape(translated(resource.title)) }
15
+ let(:resource_title) { decidim_sanitize_translated(resource.title) }
16
16
  let(:resource_text) { subject.resource_text }
17
17
 
18
18
  let(:verb) { weight.positive? ? "upvoted" : "downvoted" }
@@ -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.27.5"
7
+ "0.27.7"
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.27.5
4
+ version: 0.27.7
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-12-20 00:00:00.000000000 Z
13
+ date: 2024-07-16 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.27.5
21
+ version: 0.27.7
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.27.5
28
+ version: 0.27.7
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.27.5
55
+ version: 0.27.7
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.27.5
62
+ version: 0.27.7
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.27.5
69
+ version: 0.27.7
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.27.5
76
+ version: 0.27.7
77
77
  description: Pluggable comments system for some components.
78
78
  email:
79
79
  - josepjaume@gmail.com
@@ -167,7 +167,6 @@ files:
167
167
  - app/views/decidim/comments/votes/create.js.erb
168
168
  - app/views/decidim/comments/votes/error.js.erb
169
169
  - config/assets.rb
170
- - config/environment.rb
171
170
  - config/locales/am-ET.yml
172
171
  - config/locales/ar-SA.yml
173
172
  - config/locales/ar.yml
@@ -200,6 +199,7 @@ files:
200
199
  - config/locales/ga-IE.yml
201
200
  - config/locales/gl.yml
202
201
  - config/locales/gn-PY.yml
202
+ - config/locales/he-IL.yml
203
203
  - config/locales/hr-HR.yml
204
204
  - config/locales/hr.yml
205
205
  - config/locales/hu.yml
@@ -263,7 +263,9 @@ files:
263
263
  - db/migrate/20200828101910_add_commentable_counter_cache_to_comments.rb
264
264
  - db/migrate/20210402124534_add_participatory_process_to_comments.rb
265
265
  - db/migrate/20210529095942_add_deleted_at_column_to_comments.rb
266
+ - db/migrate/20240304092558_add_comment_vote_counter_cache_to_comments.rb
266
267
  - db/seeds.rb
268
+ - decidim-comments.gemspec
267
269
  - lib/decidim/api/add_comment_type.rb
268
270
  - lib/decidim/api/comment_mutation_type.rb
269
271
  - lib/decidim/api/comment_type.rb
@@ -304,16 +306,16 @@ require_paths:
304
306
  - lib
305
307
  required_ruby_version: !ruby/object:Gem::Requirement
306
308
  requirements:
307
- - - ">="
309
+ - - "~>"
308
310
  - !ruby/object:Gem::Version
309
- version: '3.0'
311
+ version: 3.0.0
310
312
  required_rubygems_version: !ruby/object:Gem::Requirement
311
313
  requirements:
312
314
  - - ">="
313
315
  - !ruby/object:Gem::Version
314
316
  version: '0'
315
317
  requirements: []
316
- rubygems_version: 3.4.22
318
+ rubygems_version: 3.5.14
317
319
  signing_key:
318
320
  specification_version: 4
319
321
  summary: Decidim comments module
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Empty line for playing nice with tpope/vim-rails