aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/blog_comment.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/blog_comment.rb')
-rw-r--r--app/models/blog_comment.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index 015b96d..13aceb1 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -13,7 +13,7 @@ class BlogComment < ActiveRecord::Base
alias_attribute :message, :body
validates :name, :message, :presence => true
- validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
+ validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
scope :unmoderated, :conditions => {:state => nil}
scope :approved, :conditions => {:state => 'approved'}
@@ -39,6 +39,13 @@ class BlogComment < ActiveRecord::Base
self.state.nil?
end
+ def self.toggle!
+ currently = RefinerySetting.find_or_set(:comments_allowed, true, {
+ :scoping => 'blog'
+ })
+ RefinerySetting.set(:comments_allowed, {:value => !currently, :scoping => 'blog'})
+ end
+
before_create do |comment|
unless BlogComment::Moderation.enabled?
comment.state = comment.ham? ? 'approved' : 'rejected'