Updated captcha, mailing function working

This commit is contained in:
saurabhbhatia 2013-08-15 11:25:05 +08:00
parent a1eae7543e
commit d977b83d06
4 changed files with 17 additions and 11 deletions

View File

@ -17,7 +17,7 @@ gem "select2-rails", '3.3.1'
gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git' gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git'
gem "acts_as_unvlogable" gem "acts_as_unvlogable"
gem 'youtube_it' gem 'youtube_it'
gem 'negative_captcha' gem 'gotcha'
# gem "memcached", "~> 1.4.3" # gem "memcached", "~> 1.4.3"
# gem "memcache-client" # gem "memcache-client"

View File

@ -1,5 +1,4 @@
class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController
before_filter :setup_negative_captcha, :only => [:index, :create]
layout false layout false
@ -14,15 +13,20 @@ class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController
def create def create
@ask_question = AskQuestion.new(params[:ask_question]) @ask_question = AskQuestion.new(params[:ask_question])
if verify_recaptcha model: @ask_question, private_key: '6Lfl7OESAAAAAD4rl5S16-zjt5yiKNYJ6jsqdwmL' if gotcha_valid? && @ask_question.save
@ask_acknowledgement = AskAcknowledgement.first || AskAcknowlegement.new @ask_acknowledgement = AskAcknowledgement.first || AskAcknowlegement.new
AskMailer.reply(@ask_question).deliver #@ask_question.save
@ask_question.save
redirect_to root_path redirect_to root_path
AskAdmin.all.each do |ask_admin| AskAdmin.all.each do |ask_admin|
AskMailer.notice(ask_admin, @ask_question).deliver
Resque.enqueue(SendAskNoticeMail, ask_admin.id, @ask_question.id) Resque.enqueue(SendAskNoticeMail, ask_admin.id, @ask_question.id)
end end
else
# @captcha.error will explain what went wrong
flash[:notice] = "Please refill human verification"
render :action => 'index'
end end
#respond_to do |format| #respond_to do |format|
# format.js # format.js
#end #end
@ -35,7 +39,7 @@ class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController
secret: "8a056b337dcc34741626c0b2a14dc3a05794abc11a83407f1d8ed1a1c48afec01dcae1ec2f90348981564ee1d05a537253881cf86bf9644ec4695ab797317738", secret: "8a056b337dcc34741626c0b2a14dc3a05794abc11a83407f1d8ed1a1c48afec01dcae1ec2f90348981564ee1d05a537253881cf86bf9644ec4695ab797317738",
spinner: request.remote_ip, spinner: request.remote_ip,
# Whatever fields are in your form # Whatever fields are in your form
fields: [:name, :email, :contect], fields: [:name, :email, :content],
params: params params: params
) )
end end

View File

@ -57,9 +57,11 @@
</div> </div>
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
<%= recaptcha_tags ajax: true, public_key: '6Lfl7OESAAAAAKdxTSSmWSOWlL__04A9AqQzD7_z' %> <%= gotcha_error %>
<%= gotcha%>
</div> </div>
</div> </div>
<div class="form-actions"> <div class="form-actions">
<%= f.submit t('submit'), class: 'btn btn-primary' %> <%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= f.button t('cancel'), type: 'reset', class: 'btn' %> <%= f.button t('cancel'), type: 'reset', class: 'btn' %>