Commit afedf8ad33fa168d2bd5bdc15c355c3c6dcb6966
1 parent
0b718210
Exists in
staging
and in
4 other branches
Fix archived validation for articles
Showing
3 changed files
with
12 additions
and
19 deletions
Show diff stats
app/models/comment.rb
@@ -213,7 +213,7 @@ class Comment < ActiveRecord::Base | @@ -213,7 +213,7 @@ class Comment < ActiveRecord::Base | ||
213 | end | 213 | end |
214 | 214 | ||
215 | def archived? | 215 | def archived? |
216 | - self.article.archived? | 216 | + self.article.archived? if self.article.present? && self.article.respond_to?(:archived?) |
217 | end | 217 | end |
218 | 218 | ||
219 | protected | 219 | protected |
lib/noosfero/vote_ext.rb
@@ -8,4 +8,15 @@ class Vote | @@ -8,4 +8,15 @@ class Vote | ||
8 | voter.present? | 8 | voter.present? |
9 | end | 9 | end |
10 | 10 | ||
11 | + validate :verify_target_archived | ||
12 | + | ||
13 | + def verify_target_archived | ||
14 | + if voteable.kind_of?(Article) || voteable.kind_of?(Comment) | ||
15 | + if voteable.archived? | ||
16 | + errors.add(:base, _("The target is achived and can't accept votes")) | ||
17 | + false | ||
18 | + end | ||
19 | + end | ||
20 | + end | ||
21 | + | ||
11 | end | 22 | end |
plugins/vote/lib/ext/vote.rb
@@ -1,18 +0,0 @@ | @@ -1,18 +0,0 @@ | ||
1 | -require_dependency 'models/vote' | ||
2 | - | ||
3 | -class Vote | ||
4 | - | ||
5 | - validate :verify_target_archived | ||
6 | - | ||
7 | - def verify_target_archived | ||
8 | - | ||
9 | - if voteable.kind_of?(Article) || voteable.kind_of?(Comment) | ||
10 | - if voteable.archived? | ||
11 | - errors.add(:base, _("The target is achived and can't accept votes")) | ||
12 | - false | ||
13 | - end | ||
14 | - end | ||
15 | - | ||
16 | - end | ||
17 | - | ||
18 | -end |