From b0640f925ba6bb0d89e10a82dc91e6cd86737a4d Mon Sep 17 00:00:00 2001 From: iCross Date: Wed, 29 May 2013 20:21:19 +0800 Subject: [PATCH] ask module: fix some --- .../panel/ask/back_end/ask_questions_controller.rb | 7 +++++-- .../panel/ask/back_end/ask_replies_controller.rb | 3 ++- .../panel/ask/front_end/ask_questions_controller.rb | 2 +- .../views/panel/ask/back_end/ask_questions/edit.html.erb | 6 +++--- .../views/panel/ask/front_end/ask_questions/create.js.erb | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/vendor/built_in_modules/ask/app/controllers/panel/ask/back_end/ask_questions_controller.rb b/vendor/built_in_modules/ask/app/controllers/panel/ask/back_end/ask_questions_controller.rb index bb6b273f..9d31ab73 100644 --- a/vendor/built_in_modules/ask/app/controllers/panel/ask/back_end/ask_questions_controller.rb +++ b/vendor/built_in_modules/ask/app/controllers/panel/ask/back_end/ask_questions_controller.rb @@ -21,11 +21,14 @@ class Panel::Ask::BackEnd::AskQuestionsController < OrbitBackendController def edit @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) + @method = 'put' else - @ask_question.ask_reply = AskReply.new + @ask_reply = AskReply.new @url = panel_ask_back_end_ask_question_ask_replies_path(@ask_question) + @method = 'post' end end diff --git a/vendor/built_in_modules/ask/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask/app/controllers/panel/ask/back_end/ask_replies_controller.rb index 2498669c..7804bbb6 100644 --- a/vendor/built_in_modules/ask/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -10,7 +10,8 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController def create @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? ::AskMailer.reply(@ask_question).deliver end diff --git a/vendor/built_in_modules/ask/app/controllers/panel/ask/front_end/ask_questions_controller.rb b/vendor/built_in_modules/ask/app/controllers/panel/ask/front_end/ask_questions_controller.rb index 5b985a8d..8687522c 100644 --- a/vendor/built_in_modules/ask/app/controllers/panel/ask/front_end/ask_questions_controller.rb +++ b/vendor/built_in_modules/ask/app/controllers/panel/ask/front_end/ask_questions_controller.rb @@ -14,7 +14,7 @@ class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController def create @ask_question = AskQuestion.new(params[:ask_question]) if verify_recaptcha model: @ask_question, private_key: '6Lfl7OESAAAAAD4rl5S16-zjt5yiKNYJ6jsqdwmL' - @ask_acknowledgement = AskAcknowledgement.first + @ask_acknowledgement = AskAcknowledgement.first_or_create @ask_question.save AskAdmin.all.each do |ask_admin| Resque.enqueue(SendAskNoticeMail, ask_admin.id, @ask_question.id) diff --git a/vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_questions/edit.html.erb b/vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_questions/edit.html.erb index cf4fa408..7225f69a 100644 --- a/vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_questions/edit.html.erb +++ b/vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_questions/edit.html.erb @@ -1,5 +1,5 @@
- <%= form_for @ask_question.ask_reply, url: @url do |f| %> + <%= form_for @ask_reply, url: @url, method: @method do |f| %> @@ -34,12 +34,12 @@ diff --git a/vendor/built_in_modules/ask/app/views/panel/ask/front_end/ask_questions/create.js.erb b/vendor/built_in_modules/ask/app/views/panel/ask/front_end/ask_questions/create.js.erb index 57a326f2..9570bf0a 100644 --- a/vendor/built_in_modules/ask/app/views/panel/ask/front_end/ask_questions/create.js.erb +++ b/vendor/built_in_modules/ask/app/views/panel/ask/front_end/ask_questions/create.js.erb @@ -1,5 +1,5 @@ <% if @ask_question.errors.empty? %> - $('#acknowledgement').html('

<%= t('ask.save_success') %>!

<%= @ask_acknowledgement.content rescue '' %>

'); + $('#acknowledgement').html('<%= j simple_format(@ask_acknowledgement.content) %>'); $('html,body').scrollTop(0); <% else %> alert('<%= @ask_question.errors.full_messages.join('\n') %>');
<%= AskQuestion.human_attribute_name(:name) %>:<%= @ask_question.name %>
- <%= 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') %>         - <%= 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') %>