Commit afedf8ad33fa168d2bd5bdc15c355c3c6dcb6966
1 parent
0b718210
Exists in
theme-brasil-digital-from-staging
and in
6 other branches
Fix archived validation for articles
Showing
3 changed files
with
12 additions
and
19 deletions
Show diff stats
app/models/comment.rb
lib/noosfero/vote_ext.rb
... | ... | @@ -8,4 +8,15 @@ class Vote |
8 | 8 | voter.present? |
9 | 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 | 22 | end | ... | ... |
plugins/vote/lib/ext/vote.rb
... | ... | @@ -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 |