Index: app/models/comment.rb
===================================================================
--- app/models/comment.rb (revision 189)
+++ app/models/comment.rb (working copy)
@@ -36,7 +36,6 @@
class Comment < Content
validates_presence_of :author, :author_ip, :article_id, :body
validates_format_of :author_email, :with => Format::EMAIL
- validates_length_of :body_html, :minimum => 15
before_validation :clean_up_author_email
before_validation :clean_up_author_url
@@ -48,6 +47,13 @@
has_one :event, :dependent => :destroy
attr_protected :approved
+ after_create :delete_short_comments
+ def delete_short_comments
+ if self.body_html.size < 12
+ self.destroy
+ end
+ end
+
def self.find_all_by_section(section, options = {})
find :all, options.update(:conditions => ['contents.approved = ? and assigned_sections.section_id = ?', true, section.id],
:select => 'contents.*', :joins => 'INNER JOIN assigned_sections ON assigned_sections.article_id = contents.article_id',
Index: app/controllers/mephisto_controller.rb
===================================================================
--- app/controllers/mephisto_controller.rb (revision 188)
+++ app/controllers/mephisto_controller.rb (working copy)
@@ -49,7 +49,7 @@
@comment = @article.comments.build(params[:comment].merge(:user_id => session[:user], :author_ip => request.remote_ip, :user_agent => request.user_agent, :referrer => request.referer))
@comment.check_approval site, request if @comment.valid?
- @comment.save!
+ @comment.save! if params[:human] == "on"
redirect_to dispatch_path(:path => (site.permalink_for(@article)[1..-1].split('/') << 'comments' << @comment.id.to_s), :anchor => @comment.dom_id)
rescue ActiveRecord::RecordInvalid
show_article_with 'errors' => @comment.errors.full_messages, 'submitted' => params[:comment]
Index: themes/site-1/simpla/templates/_comments.liquid
===================================================================
--- themes/site-1/simpla/templates/_comments.liquid (revision 183)
+++ themes/site-1/simpla/templates/_comments.liquid (working copy)
@@ -21,6 +21,7 @@
<p>{{ form.email }}<label for="email"><small>Mail (will not be published)</small></label></p>
<p>{{ form.url }}<label for="url"><small>Website</small></label></p>
<p><textarea name="comment[body]" id="comment" cols="100%" rows="10">{{ submitted.body }}</textarea></p>
+ <p><input type="checkbox" name="human" /> I am a human (check this)</p>
<p><input name="submit" type="submit" id="submit" value="Submit Comment" /></p>
{% endcommentform %}