better comment creation errors
This commit is contained in:
@@ -96,6 +96,10 @@ class AnonymousUser
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_comment_limited?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def can_remove_from_pools?
|
def can_remove_from_pools?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -86,10 +86,13 @@ class Comment < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def validate_creator_is_not_limited
|
def validate_creator_is_not_limited
|
||||||
if creator.can_comment?
|
if creator.is_comment_limited?
|
||||||
|
errors.add(:base, "You can only post #{Danbooru.config.member_comment_limit} comments per hour")
|
||||||
|
false
|
||||||
|
elsif creator.can_comment?
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
errors.add(:creator, "can not post comments within 1 week of sign up, and can only post #{Danbooru.config.member_comment_limit} comments per hour after that")
|
errors.add(:base, "You can not post comments within 1 week of sign up")
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -424,10 +424,16 @@ class User < ActiveRecord::Base
|
|||||||
def can_comment?
|
def can_comment?
|
||||||
if is_privileged?
|
if is_privileged?
|
||||||
true
|
true
|
||||||
elsif created_at > Danbooru.config.member_comment_time_threshold
|
else
|
||||||
|
created_at <= Danbooru.config.member_comment_time_threshold
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_comment_limited?
|
||||||
|
if is_privileged?
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
Comment.where("creator_id = ? and created_at > ?", id, 1.hour.ago).count < Danbooru.config.member_comment_limit
|
Comment.where("creator_id = ? and created_at > ?", id, 1.hour.ago).count >= Danbooru.config.member_comment_limit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user