fixes #744
This commit is contained in:
@@ -5,7 +5,7 @@ class CommentVote < ActiveRecord::Base
|
|||||||
belongs_to :user
|
belongs_to :user
|
||||||
before_validation :initialize_user, :on => :create
|
before_validation :initialize_user, :on => :create
|
||||||
validates_presence_of :user_id, :comment_id, :score
|
validates_presence_of :user_id, :comment_id, :score
|
||||||
validates_uniqueness_of :user_id, :scope => :comment_id, :message => "has already voted for this comment"
|
validates_uniqueness_of :user_id, :scope => :comment_id, :message => "have already voted for this comment"
|
||||||
validate :validate_user_can_vote
|
validate :validate_user_can_vote
|
||||||
validate :validate_comment_can_be_down_voted
|
validate :validate_comment_can_be_down_voted
|
||||||
validates_inclusion_of :score, :in => [-1, 1], :message => "must be 1 or -1"
|
validates_inclusion_of :score, :in => [-1, 1], :message => "must be 1 or -1"
|
||||||
@@ -27,7 +27,7 @@ class CommentVote < ActiveRecord::Base
|
|||||||
|
|
||||||
def validate_user_can_vote
|
def validate_user_can_vote
|
||||||
if !user.can_comment_vote?
|
if !user.can_comment_vote?
|
||||||
errors.add :user, "can not comment vote"
|
errors.add :base, "You cannot vote on comments"
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
@@ -36,7 +36,7 @@ class CommentVote < ActiveRecord::Base
|
|||||||
|
|
||||||
def validate_comment_can_be_down_voted
|
def validate_comment_can_be_down_voted
|
||||||
if is_negative? && comment.creator.is_janitor?
|
if is_negative? && comment.creator.is_janitor?
|
||||||
errors.add :user, "can not downvote a janitor comment"
|
errors.add :base, "You cannot downvote a janitor comment"
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
|
|||||||
@@ -20,3 +20,9 @@ en:
|
|||||||
post_disapproval:
|
post_disapproval:
|
||||||
post: "You"
|
post: "You"
|
||||||
post_id: "You"
|
post_id: "You"
|
||||||
|
comment:
|
||||||
|
post: "You"
|
||||||
|
post_id: "You"
|
||||||
|
comment_vote:
|
||||||
|
comment: "You"
|
||||||
|
user_id: "You"
|
||||||
Reference in New Issue
Block a user