ask module: fix some

This commit is contained in:
iCross 2013-05-29 20:21:19 +08:00 committed by chris
parent 841fa10c55
commit b0640f925b
5 changed files with 12 additions and 8 deletions

View File

@ -21,11 +21,14 @@ class Panel::Ask::BackEnd::AskQuestionsController < OrbitBackendController
def edit def edit
@ask_question = AskQuestion.find(params[:id]) @ask_question = AskQuestion.find(params[:id])
if @ask_question.ask_reply @ask_reply = @ask_question.ask_reply
if @ask_reply
@url = panel_ask_back_end_ask_question_ask_reply_path(@ask_question, @ask_question.ask_reply) @url = panel_ask_back_end_ask_question_ask_reply_path(@ask_question, @ask_question.ask_reply)
@method = 'put'
else else
@ask_question.ask_reply = AskReply.new @ask_reply = AskReply.new
@url = panel_ask_back_end_ask_question_ask_replies_path(@ask_question) @url = panel_ask_back_end_ask_question_ask_replies_path(@ask_question)
@method = 'post'
end end
end end

View File

@ -10,7 +10,8 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController
def create def create
@ask_question = AskQuestion.find(params[:ask_question_id]) @ask_question = AskQuestion.find(params[:ask_question_id])
@ask_question.ask_reply.create(params[:ask_reply]) @ask_question.ask_reply = AskReply.new(params[:ask_reply])
@ask_question.save
if @ask_question.ask_reply.send_email? if @ask_question.ask_reply.send_email?
::AskMailer.reply(@ask_question).deliver ::AskMailer.reply(@ask_question).deliver
end end

View File

@ -14,7 +14,7 @@ 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 verify_recaptcha model: @ask_question, private_key: '6Lfl7OESAAAAAD4rl5S16-zjt5yiKNYJ6jsqdwmL'
@ask_acknowledgement = AskAcknowledgement.first @ask_acknowledgement = AskAcknowledgement.first_or_create
@ask_question.save @ask_question.save
AskAdmin.all.each do |ask_admin| AskAdmin.all.each do |ask_admin|
Resque.enqueue(SendAskNoticeMail, ask_admin.id, @ask_question.id) Resque.enqueue(SendAskNoticeMail, ask_admin.id, @ask_question.id)

View File

@ -1,5 +1,5 @@
<div id="ask_question_reply"> <div id="ask_question_reply">
<%= form_for @ask_question.ask_reply, url: @url do |f| %> <%= form_for @ask_reply, url: @url, method: @method do |f| %>
<table class="table"> <table class="table">
<tr> <tr>
<td><%= AskQuestion.human_attribute_name(:name) %><%= @ask_question.name %></td> <td><%= AskQuestion.human_attribute_name(:name) %><%= @ask_question.name %></td>
@ -34,12 +34,12 @@
</tr> </tr>
<tr> <tr>
<td colspan="5"> <td colspan="5">
<%= f.label :send_email %><%= f.radio_button :send_email, 1, checked: @ask_question.ask_reply.send_email? %><%= t('ask.yes') %> <%= f.label :send_email %><%= f.radio_button :send_email, 1, checked: @ask_reply.send_email? %><%= t('ask.yes') %>
&nbsp; &nbsp;
&nbsp; &nbsp;
&nbsp; &nbsp;
&nbsp; &nbsp;
<%= f.radio_button :send_email, 0, checked: !@ask_question.ask_reply.send_email? %><%= t('ask.no') %> <%= f.radio_button :send_email, 0, checked: !@ask_reply.send_email? %><%= t('ask.no') %>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@ -1,5 +1,5 @@
<% if @ask_question.errors.empty? %> <% if @ask_question.errors.empty? %>
$('#acknowledgement').html('<p><%= t('ask.save_success') %>!</p><p><%= @ask_acknowledgement.content rescue '' %></p>'); $('#acknowledgement').html('<%= j simple_format(@ask_acknowledgement.content) %>');
$('html,body').scrollTop(0); $('html,body').scrollTop(0);
<% else %> <% else %>
alert('<%= @ask_question.errors.full_messages.join('\n') %>'); alert('<%= @ask_question.errors.full_messages.join('\n') %>');