From 103c265b417f00a591578bef5f0877d6d8ce48c7 Mon Sep 17 00:00:00 2001 From: ghostrigger Date: Wed, 3 Apr 2013 00:30:19 +0800 Subject: [PATCH 1/3] Update maintenance.html.bak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updated twitter link courtesy of @mseymour for https://github.com/r888888888/danbooru/issues/776 --- public/maintenance.html.bak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/maintenance.html.bak b/public/maintenance.html.bak index 879a6251c..5e1810fe5 100644 --- a/public/maintenance.html.bak +++ b/public/maintenance.html.bak @@ -16,6 +16,6 @@

The site is down for maintenance.

-

Check Twitter for updates.

+

Check Twitter for updates.

From a5f1a6bad1ce058861c703fbfcf5add856c34229 Mon Sep 17 00:00:00 2001 From: Toks Date: Tue, 2 Apr 2013 13:31:57 -0400 Subject: [PATCH 2/3] better comment creation errors --- app/logical/anonymous_user.rb | 4 ++++ app/models/comment.rb | 7 +++++-- app/models/user.rb | 10 ++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/logical/anonymous_user.rb b/app/logical/anonymous_user.rb index eafd3f2fe..057337633 100644 --- a/app/logical/anonymous_user.rb +++ b/app/logical/anonymous_user.rb @@ -96,6 +96,10 @@ class AnonymousUser false end + def is_comment_limited? + true + end + def can_remove_from_pools? false end diff --git a/app/models/comment.rb b/app/models/comment.rb index 6c4fd6faa..295104869 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -86,10 +86,13 @@ class Comment < ActiveRecord::Base end 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 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 end end diff --git a/app/models/user.rb b/app/models/user.rb index 239c93004..3cbb9c694 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -424,10 +424,16 @@ class User < ActiveRecord::Base def can_comment? if is_privileged? 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 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 From dc6f345e25057f39745a6cabd0e735f9f9adf349 Mon Sep 17 00:00:00 2001 From: Toks Date: Tue, 2 Apr 2013 13:33:43 -0400 Subject: [PATCH 3/3] allow unlimited non-bumping comments --- app/models/comment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 295104869..defc95abf 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -86,7 +86,7 @@ class Comment < ActiveRecord::Base end def validate_creator_is_not_limited - if creator.is_comment_limited? + if creator.is_comment_limited? && !do_not_bump_post? errors.add(:base, "You can only post #{Danbooru.config.member_comment_limit} comments per hour") false elsif creator.can_comment?