aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2011-02-21 13:16:42 +1300
committerPhilip Arndt <parndt@gmail.com>2011-02-21 13:21:56 +1300
commitf221da62cde073059424eddaa1f7a52ed67de848 (patch)
tree563d1dcb3abd2230a453609665965ef33348a06f /app/models
parent4228fa4146360751edb1241e187f67d03128cdaf (diff)
downloadrefinerycms-blog-f221da62cde073059424eddaa1f7a52ed67de848.tar.gz
refinerycms-blog-f221da62cde073059424eddaa1f7a52ed67de848.tar.bz2
refinerycms-blog-f221da62cde073059424eddaa1f7a52ed67de848.zip
Added settings click-button functionality for toggling comments being enabled, with translations.
Diffstat (limited to 'app/models')
-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'