fixes #101: comment limitations
This commit is contained in:
@@ -28,7 +28,12 @@ class Comment < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def validate_creator_is_not_limited
|
def validate_creator_is_not_limited
|
||||||
creator.is_privileged? || Comment.where("creator_id = ? AND created_at >= ?", creator_id, 1.hour.ago).count < 5
|
if creator.can_comment?
|
||||||
|
true
|
||||||
|
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")
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_last_commented_at
|
def update_last_commented_at
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ class User < ActiveRecord::Base
|
|||||||
def can_upload?
|
def can_upload?
|
||||||
if is_contributor?
|
if is_contributor?
|
||||||
true
|
true
|
||||||
elsif created_at > 1.second.ago
|
elsif false && created_at > 1.week.ago
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
upload_limit > 0
|
upload_limit > 0
|
||||||
@@ -292,7 +292,7 @@ class User < ActiveRecord::Base
|
|||||||
def can_comment?
|
def can_comment?
|
||||||
if is_privileged?
|
if is_privileged?
|
||||||
true
|
true
|
||||||
elsif created_at > 1.week.ago
|
elsif false && created_at > 1.week.ago
|
||||||
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
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class CommentTest < ActiveSupport::TestCase
|
|||||||
CurrentUser.user = user
|
CurrentUser.user = user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
|
Danbooru.config.stubs(:member_comment_limit).returns(100)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
|
|||||||
Reference in New Issue
Block a user