eBooru/app/models/post_vote.rb

23 lines
483 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class PostVote < UserVote
validate :validate_user_can_vote
2022-10-08 17:59:33 -04:00
def self.model_creator_column
:uploader
end
2019-09-04 00:56:41 -04:00
def validate_user_can_vote
if user.younger_than(3.days) && score == -1
errors.add(:user, "must be 3 days old to downvote posts")
2019-09-04 00:56:41 -04:00
return false
end
allowed = user.can_post_vote_with_reason
2019-09-04 00:56:41 -04:00
if allowed != true
errors.add(:user, User.throttle_reason(allowed))
2019-09-04 00:56:41 -04:00
return false
end
true
end
2010-02-15 17:45:09 -05:00
end