From d98d0088068ac8b2a73bf22be60b761f111381a1 Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Thu, 5 Sep 2013 17:53:22 +0800 Subject: [PATCH 01/45] add sending post request function --- .../ask/back_end/ask_replies_controller.rb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index 86219b7ad..ee8bcfede 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -17,6 +17,11 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController if @ask_question.ask_reply.send_email? Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id) end + ## + ##if status == "..." + ##send_request + ##------------------- + # redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') end @@ -26,6 +31,32 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController if @ask_reply.send_email? Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id) end + ## + send_request + ## redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') end + + def send_request + require 'net/http' + require 'uri' + require 'json' + uri = URI.parse("http://localhost:3000") + @body = { + "a" => "123", + "b" => "456" + }.to_json + + request = Net::HTTP::Post.new(initheader = {'Content-Type' =>'application/json'}) + request.body = @body + + response = Net::HTTP.start(uri.host, uri.port) do |http| + http.request(request) + end + + puts "Response #{response.code} #{response.message}: #{response.body}" + # flash[:notice]=response.message + # flash[:notice] = "Response #{response.code} #{response.message}: #{response.body}" + end + end From 8cd27e26e2552c37b75ec388e48f36bbc6db11b2 Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Mon, 9 Sep 2013 15:26:13 +0800 Subject: [PATCH 02/45] Fixed untracked files Conflicts: config/mongoid.yml --- .../app/views/panel/ask/back_end/ask_questions/edit.html.erb | 1 + .../ask_new/test/dummy/app/mailers/.gitkeep~HEAD | 0 .../ask_new/test/dummy/app/mailers/.gitkeep~HEAD_0 | 0 .../mailers/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 | 0 .../mailers/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 | 0 .../ask_new/test/dummy/app/models/.gitkeep~HEAD | 0 .../ask_new/test/dummy/app/models/.gitkeep~HEAD_0 | 0 .../models/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 | 0 .../models/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 | 0 .../ask_new/test/dummy/lib/assets/.gitkeep~HEAD | 0 .../ask_new/test/dummy/lib/assets/.gitkeep~HEAD_0 | 0 .../assets/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 | 0 .../assets/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 | 0 vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~HEAD | 0 vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~HEAD_0 | 0 .../dummy/log/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 | 0 .../log/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 | 0 .../built_in_modules/ask_new/test/dummy/public/favicon.ico~HEAD | 0 .../public/favicon.ico~b1b82cb9af6c2dadffc1a4a7608ea08660907529 | 0 .../faq/app/views/panel/faq/back_end/qas/index.html.erb | 2 +- 20 files changed, 2 insertions(+), 1 deletion(-) rename log/.gitignore => vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~HEAD (100%) create mode 100644 vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~HEAD_0 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~HEAD create mode 100644 vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~HEAD_0 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~HEAD create mode 100644 vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~HEAD_0 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~HEAD create mode 100644 vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~HEAD_0 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 create mode 100644 vendor/built_in_modules/ask_new/test/dummy/public/favicon.ico~HEAD create mode 100644 vendor/built_in_modules/ask_new/test/dummy/public/favicon.ico~b1b82cb9af6c2dadffc1a4a7608ea08660907529 diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb index 7225f69a1..4d30b6b94 100644 --- a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb +++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb @@ -31,6 +31,7 @@ ['已處理', '已處理'], ['轉介其他單位', '轉介其他單位'] ] %> + diff --git a/log/.gitignore b/vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~HEAD similarity index 100% rename from log/.gitignore rename to vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~HEAD diff --git a/vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~HEAD_0 b/vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~HEAD_0 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 b/vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 b/vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~HEAD b/vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~HEAD_0 b/vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~HEAD_0 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 b/vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 b/vendor/built_in_modules/ask_new/test/dummy/app/models/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~HEAD b/vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~HEAD_0 b/vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~HEAD_0 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 b/vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 b/vendor/built_in_modules/ask_new/test/dummy/lib/assets/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~HEAD b/vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~HEAD_0 b/vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~HEAD_0 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 b/vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 b/vendor/built_in_modules/ask_new/test/dummy/log/.gitkeep~b1b82cb9af6c2dadffc1a4a7608ea08660907529_0 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/public/favicon.ico~HEAD b/vendor/built_in_modules/ask_new/test/dummy/public/favicon.ico~HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/test/dummy/public/favicon.ico~b1b82cb9af6c2dadffc1a4a7608ea08660907529 b/vendor/built_in_modules/ask_new/test/dummy/public/favicon.ico~b1b82cb9af6c2dadffc1a4a7608ea08660907529 new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/index.html.erb b/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/index.html.erb index 30714cdc0..334d5973d 100644 --- a/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/index.html.erb +++ b/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/index.html.erb @@ -17,6 +17,6 @@
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:add), new_panel_faq_back_end_qa_path, :class => 'btn btn-primary pull-right' if (is_manager? rescue nil) %>
- <%= paginate @qas, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %> + <%= paginate @qas, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} rescue nil %>
From bf5416095e456b16256034631479532f77c83186 Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Tue, 10 Sep 2013 10:48:28 +0800 Subject: [PATCH 03/45] add auth_request route and controller --- .../panel/ask/back_end/ask_replies_controller.rb | 2 +- .../panel/ask/back_end/ask_requests_controller.rb | 10 ++++++++++ vendor/built_in_modules/ask_new/config/routes.rb | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index ee8bcfede..a4fb92bf9 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -41,7 +41,7 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController require 'net/http' require 'uri' require 'json' - uri = URI.parse("http://localhost:3000") + uri = URI.parse("http://localhost/ask/back_end/ask_requests/auth_request:3000") @body = { "a" => "123", "b" => "456" diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb new file mode 100644 index 000000000..5676ee028 --- /dev/null +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb @@ -0,0 +1,10 @@ +class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController + + include AdminHelper + include OrbitControllerLib::DivisionForDisable + + def auth_request + + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/ask_new/config/routes.rb b/vendor/built_in_modules/ask_new/config/routes.rb index 0c4894874..3b6f5a8b6 100644 --- a/vendor/built_in_modules/ask_new/config/routes.rb +++ b/vendor/built_in_modules/ask_new/config/routes.rb @@ -11,10 +11,12 @@ Rails.application.routes.draw do end resources :ask_replies end - + resources :ask_categories resources :ask_acknowledgements resources :ask_admins + + match "ask_requests/auth_request" => "ask_requests#auth_request", :as => 'auth_request' end namespace :front_end do From da40c2b66990a42af55f12ea2869da55a27fec1a Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Tue, 10 Sep 2013 16:31:35 +0800 Subject: [PATCH 04/45] Allow sending request and getting response --- .../ask/back_end/ask_replies_controller.rb | 23 ++++++++++--------- .../ask/back_end/ask_requests_controller.rb | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index a4fb92bf9..54366a359 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -34,28 +34,29 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController ## send_request ## - redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') + redirect_to panel_ask_back_end_ask_questions_path # , notice: t('ask.reply_success') end - + def send_request require 'net/http' require 'uri' require 'json' - uri = URI.parse("http://localhost/ask/back_end/ask_requests/auth_request:3000") - @body = { + + uri = URI.parse("http://localhost:4000/panel/ask/back_end/ask_requests/auth_request") + + body = { "a" => "123", "b" => "456" - }.to_json + } - request = Net::HTTP::Post.new(initheader = {'Content-Type' =>'application/json'}) - request.body = @body + http = Net::HTTP.new(uri.host, uri.port) + request = Net::HTTP::Post.new(uri.request_uri) + request.set_form_data(body) - response = Net::HTTP.start(uri.host, uri.port) do |http| - http.request(request) - end + response = http.request(request) puts "Response #{response.code} #{response.message}: #{response.body}" - # flash[:notice]=response.message + flash[:notice] = response.body # flash[:notice] = "Response #{response.code} #{response.message}: #{response.body}" end diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb index 5676ee028..eb5584fa2 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb @@ -4,7 +4,7 @@ class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController include OrbitControllerLib::DivisionForDisable def auth_request - + params.merge!({'c' => '789'}) + render :json => "#{params}" end - end \ No newline at end of file From cc7a4ffb6ddf8083da020f69cf428ca15dbdb8cf Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Tue, 10 Sep 2013 17:54:18 +0800 Subject: [PATCH 05/45] add response(temp) --- .../ask/back_end/ask_replies_controller.rb | 22 ++++++++++++++----- .../ask/back_end/ask_requests_controller.rb | 12 +++++++++- .../ask_requests/auth_request.html.erb | 0 .../built_in_modules/ask_new/config/routes.rb | 3 ++- 4 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_requests/auth_request.html.erb diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index 54366a359..02dd6190a 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -26,18 +26,19 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController end def update + @ask_question = AskQuestion.find(params[:ask_question_id]) @ask_reply = AskReply.find(params[:id]) @ask_reply.update_attributes(params[:ask_reply]) if @ask_reply.send_email? Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id) end ## - send_request + send_request(@ask_question) ## redirect_to panel_ask_back_end_ask_questions_path # , notice: t('ask.reply_success') end - def send_request + def send_request(current_question) require 'net/http' require 'uri' require 'json' @@ -52,11 +53,20 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(body) - response = http.request(request) - - puts "Response #{response.code} #{response.message}: #{response.body}" - flash[:notice] = response.body + # puts "Response #{response.code} #{response.message}: #{response.body}" + if response.code == "200" + uri = URI.parse("http://localhost:4000/panel/ask/back_end/ask_requests/transfer_request") + http = Net::HTTP.new(uri.host, uri.port) + request = Net::HTTP::Post.new(uri.request_uri) + body = { + 'title' => current_question.title + } + request.set_form_data(body) + response = http.request(request) + flash[:notice] = response.body + end + # flash[:notice] = response.body # flash[:notice] = "Response #{response.code} #{response.message}: #{response.body}" end diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb index eb5584fa2..e25b9636a 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb @@ -4,7 +4,17 @@ class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController include OrbitControllerLib::DivisionForDisable def auth_request - params.merge!({'c' => '789'}) + params={'c' => '456' } render :json => "#{params}" end + + def transfer_request + # @ask_question = AskQuestion.all + # x = @ask_question.count + # params={'d' => x } + @transfered_question=AskQuestion.new(:title=>params[:title]) + @transfered_question.save + render :json => "#{params}" + end + end \ No newline at end of file diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_requests/auth_request.html.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_requests/auth_request.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/built_in_modules/ask_new/config/routes.rb b/vendor/built_in_modules/ask_new/config/routes.rb index 3b6f5a8b6..cf7d5fe31 100644 --- a/vendor/built_in_modules/ask_new/config/routes.rb +++ b/vendor/built_in_modules/ask_new/config/routes.rb @@ -15,8 +15,9 @@ Rails.application.routes.draw do resources :ask_categories resources :ask_acknowledgements resources :ask_admins - + match "ask_requests/auth_request" => "ask_requests#auth_request", :as => 'auth_request' + match "ask_requests/transfer_request" => "ask_requests#transfer_request", :as => 'transfer_request' end namespace :front_end do From 64e14d42e277acf696268b32a3f8908885f06b2e Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Wed, 11 Sep 2013 07:09:25 +0800 Subject: [PATCH 06/45] Allow ask_question transter --- .../ask/back_end/ask_replies_controller.rb | 22 ++++++++++++++----- .../ask/back_end/ask_requests_controller.rb | 21 ++++++++++++++++-- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index 02dd6190a..514e49b74 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -1,5 +1,5 @@ +# encoding: utf-8 class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController - include AdminHelper include OrbitControllerLib::DivisionForDisable @@ -33,9 +33,9 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id) end ## - send_request(@ask_question) + send_request(@ask_question) if params[:ask_reply][:status] == '轉介其他單位' ## - redirect_to panel_ask_back_end_ask_questions_path # , notice: t('ask.reply_success') + redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') end def send_request(current_question) @@ -46,8 +46,7 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController uri = URI.parse("http://localhost:4000/panel/ask/back_end/ask_requests/auth_request") body = { - "a" => "123", - "b" => "456" + 'auth_token' => '3kjlfksjDFJ' } http = Net::HTTP.new(uri.host, uri.port) @@ -55,17 +54,28 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController request.set_form_data(body) response = http.request(request) # puts "Response #{response.code} #{response.message}: #{response.body}" + if response.code == "200" uri = URI.parse("http://localhost:4000/panel/ask/back_end/ask_requests/transfer_request") http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri) body = { - 'title' => current_question.title + 'name' => current_question.name, + 'title' => current_question.title, + 'identity' => current_question.identity, + 'email' => current_question.email, + 'phone' => current_question.phone, + 'tax' => current_question.tax, + 'content' => current_question.content, + 'category' => current_question.ask_category.name, + 'category_key' => current_question.ask_category.key } request.set_form_data(body) response = http.request(request) flash[:notice] = response.body end + + puts "Response #{response.code} #{response.message}: #{response.body}" # flash[:notice] = response.body # flash[:notice] = "Response #{response.code} #{response.message}: #{response.body}" end diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb index e25b9636a..dca8d3739 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb @@ -1,10 +1,10 @@ +# encoding: utf-8 class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController include AdminHelper include OrbitControllerLib::DivisionForDisable def auth_request - params={'c' => '456' } render :json => "#{params}" end @@ -12,8 +12,25 @@ class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController # @ask_question = AskQuestion.all # x = @ask_question.count # params={'d' => x } - @transfered_question=AskQuestion.new(:title=>params[:title]) + + if !AskCategory.where(name: params['category']).any? + @ask_category = AskCategory.new(name: params['category'], key: params['category_key']) + @ask_category.save! + end + + category = AskCategory.where(name: params['category']) + + @transfered_question = AskQuestion.new( + name: params['name'], + identity: params['identity'], + email: params['email'], + phone: params['phone'], + tax: params['tax'], + title: params['title'], + content: params['content'], + ask_category_id: category.first.id) @transfered_question.save + render :json => "#{params}" end From 1237a111cabec11683211495cc754bf619d4ce7f Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Wed, 11 Sep 2013 12:19:44 +0800 Subject: [PATCH 07/45] =?UTF-8?q?add=20transfered=5Fcategory=20if=20not=20?= =?UTF-8?q?exist.=20change=20transfered=20reply's=20status=20to=20?= =?UTF-8?q?=E5=BE=85=E8=99=95=E7=90=86(=E8=BD=89).=20=20showing=20request?= =?UTF-8?q?=20code=20if=20error.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ask/back_end/ask_replies_controller.rb | 22 +++++++++---------- .../ask/back_end/ask_requests_controller.rb | 12 +++++----- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index 514e49b74..8b1b66db8 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -17,11 +17,6 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController if @ask_question.ask_reply.send_email? Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id) end - ## - ##if status == "..." - ##send_request - ##------------------- - # redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') end @@ -33,12 +28,12 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id) end ## - send_request(@ask_question) if params[:ask_reply][:status] == '轉介其他單位' + send_request(@ask_question, @ask_reply) if params[:ask_reply][:status] == '轉介其他單位' ## redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') end - def send_request(current_question) + def send_request(current_question, current_reply) require 'net/http' require 'uri' require 'json' @@ -53,7 +48,7 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(body) response = http.request(request) - # puts "Response #{response.code} #{response.message}: #{response.body}" + puts "Response #{response.code} #{response.message}: #{response.body}" if response.code == "200" uri = URI.parse("http://localhost:4000/panel/ask/back_end/ask_requests/transfer_request") @@ -67,12 +62,17 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController 'phone' => current_question.phone, 'tax' => current_question.tax, 'content' => current_question.content, - 'category' => current_question.ask_category.name, - 'category_key' => current_question.ask_category.key } request.set_form_data(body) response = http.request(request) - flash[:notice] = response.body + + if response.code != "200" + new_status = "轉介其他單位" + "(" + response.code + ")" + current_reply.update_attributes(status: new_status) + else + new_status = "轉介其他單位" + "(" + "succes!" + ")" + current_reply.update_attributes(status: new_status) + end end puts "Response #{response.code} #{response.message}: #{response.body}" diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb index dca8d3739..eff47c5ff 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb @@ -9,16 +9,12 @@ class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController end def transfer_request - # @ask_question = AskQuestion.all - # x = @ask_question.count - # params={'d' => x } - if !AskCategory.where(name: params['category']).any? - @ask_category = AskCategory.new(name: params['category'], key: params['category_key']) + if !AskCategory.where(key: "transfered_question").any? + @ask_category = AskCategory.new(name: "transfered_question", key: "transfered_question") @ask_category.save! end - - category = AskCategory.where(name: params['category']) + category = AskCategory.where(key: "transfered_question") @transfered_question = AskQuestion.new( name: params['name'], @@ -29,6 +25,8 @@ class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController title: params['title'], content: params['content'], ask_category_id: category.first.id) + @transfered_question.ask_reply = AskReply.new + @transfered_question.ask_reply.update_attributes(status: "待處理(轉)") @transfered_question.save render :json => "#{params}" From 24b9f4015bfebe8e17f8d6bf49fa885ee9691289 Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Wed, 11 Sep 2013 12:36:32 +0800 Subject: [PATCH 08/45] add checkboxes for 11 dep in edit view --- .../ask/back_end/ask_questions/edit.html.erb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb index 4d30b6b94..9fff7f2c3 100644 --- a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb +++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb @@ -33,6 +33,21 @@ ] %> + + + <%= check_box_tag(:dep1) %><%= label_tag(:dep1, "總務長室暨總務處秘書室") %> + <%= check_box_tag(:dep2) %><%= label_tag(:dep2, "文書組") %> + <%= check_box_tag(:dep3) %><%= label_tag(:dep3, "事務組") %> + <%= check_box_tag(:dep4) %><%= label_tag(:dep4, "保管組") %> + <%= check_box_tag(:dep5) %><%= label_tag(:dep5, "營繕組") %> + <%= check_box_tag(:dep6) %><%= label_tag(:dep6, "出納組") %> + <%= check_box_tag(:dep7) %><%= label_tag(:dep7, "採購組") %> + <%= check_box_tag(:dep8) %><%= label_tag(:dep8, "經營管理組") %> + <%= check_box_tag(:dep9) %><%= label_tag(:dep9, "駐警隊") %> + <%= check_box_tag(:dep10) %><%= label_tag(:dep10, "社科院總務分處") %> + <%= check_box_tag(:dep11) %><%= label_tag(:dep11, "醫學院總務分處") %> + + <%= f.label :send_email %><%= f.radio_button :send_email, 1, checked: @ask_reply.send_email? %><%= t('ask.yes') %> From 3f9cdec426e46305a160ec59a161e33e1c3b44cc Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Wed, 11 Sep 2013 13:55:13 +0800 Subject: [PATCH 09/45] add option for dep_dns --- .../panel/ask/back_end/ask_replies_controller.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index 8b1b66db8..41d2900a9 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -28,17 +28,18 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id) end ## - send_request(@ask_question, @ask_reply) if params[:ask_reply][:status] == '轉介其他單位' + send_request("http://localhost:4000", @ask_question, @ask_reply) if params[:ask_reply][:status] == '轉介其他單位' ## redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') end - def send_request(current_question, current_reply) + def send_request(dep_dns, current_question, current_reply) require 'net/http' require 'uri' require 'json' - - uri = URI.parse("http://localhost:4000/panel/ask/back_end/ask_requests/auth_request") + + uri_path = "/panel/ask/back_end/ask_requests/auth_request" + uri = URI.parse(dep_dns + uri_path) body = { 'auth_token' => '3kjlfksjDFJ' @@ -51,7 +52,8 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController puts "Response #{response.code} #{response.message}: #{response.body}" if response.code == "200" - uri = URI.parse("http://localhost:4000/panel/ask/back_end/ask_requests/transfer_request") + uri_path = "/panel/ask/back_end/ask_requests/transfer_request" + uri = URI.parse(dep_dns + uri_path) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri) body = { From 0a1ebf18e3b0e057d441a5e01415bf19e9fc7a1f Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Wed, 11 Sep 2013 14:17:11 +0800 Subject: [PATCH 10/45] Add check box array --- .../ask/back_end/ask_questions/edit.html.erb | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb index 9fff7f2c3..949751489 100644 --- a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb +++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb @@ -1,3 +1,7 @@ + +
<%= form_for @ask_reply, url: @url, method: @method do |f| %> @@ -34,18 +38,18 @@ - From 883496ede17833cade1df0f4bef5c7dd6cb5503a Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Wed, 11 Sep 2013 15:44:38 +0800 Subject: [PATCH 11/45] add multi deliver request --- .../ask/back_end/ask_replies_controller.rb | 10 ++++++--- .../ask/back_end/ask_questions/edit.html.erb | 22 +++++++++---------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index 41d2900a9..55aee182d 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -28,8 +28,12 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id) end ## - send_request("http://localhost:4000", @ask_question, @ask_reply) if params[:ask_reply][:status] == '轉介其他單位' + binding.pry + params[:school][:depts].each do |dns| + send_request(dns, @ask_question, @ask_reply) + end unless params[:school].nil? ## + redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') end @@ -39,7 +43,7 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController require 'json' uri_path = "/panel/ask/back_end/ask_requests/auth_request" - uri = URI.parse(dep_dns + uri_path) + uri = URI.parse("http://" + dep_dns + uri_path) body = { 'auth_token' => '3kjlfksjDFJ' @@ -53,7 +57,7 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController if response.code == "200" uri_path = "/panel/ask/back_end/ask_requests/transfer_request" - uri = URI.parse(dep_dns + uri_path) + uri = URI.parse("http://" + dep_dns + uri_path) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri) body = { diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb index 949751489..570eb0e2d 100644 --- a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb +++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb @@ -39,17 +39,17 @@ From 71dad22b04d5f110f96193ba04b6c2baccf5e91e Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Wed, 11 Sep 2013 15:50:14 +0800 Subject: [PATCH 12/45] Add dynamic checkboxes Conflicts: vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb --- .../ask/back_end/ask_questions/edit.html.erb | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb index 570eb0e2d..90825c6d9 100644 --- a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb +++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb @@ -1,7 +1,23 @@ - + +
<%= form_for @ask_reply, url: @url, method: @method do |f| %>
- <%= check_box_tag(:dep1) %><%= label_tag(:dep1, "總務長室暨總務處秘書室") %> - <%= check_box_tag(:dep2) %><%= label_tag(:dep2, "文書組") %> - <%= check_box_tag(:dep3) %><%= label_tag(:dep3, "事務組") %> - <%= check_box_tag(:dep4) %><%= label_tag(:dep4, "保管組") %> - <%= check_box_tag(:dep5) %><%= label_tag(:dep5, "營繕組") %> - <%= check_box_tag(:dep6) %><%= label_tag(:dep6, "出納組") %> - <%= check_box_tag(:dep7) %><%= label_tag(:dep7, "採購組") %> - <%= check_box_tag(:dep8) %><%= label_tag(:dep8, "經營管理組") %> - <%= check_box_tag(:dep9) %><%= label_tag(:dep9, "駐警隊") %> - <%= check_box_tag(:dep10) %><%= label_tag(:dep10, "社科院總務分處") %> - <%= check_box_tag(:dep11) %><%= label_tag(:dep11, "醫學院總務分處") %> + + <%= check_box("schoool", "depts", {:multiple => true}, "總務長室暨總務處秘書室", nil) %><%= label_tag(:dep1, "總務長室暨總務處秘書室") %> + <%= check_box("schoool", "depts", {:multiple => true}, "文書組", nil) %><%= label_tag(:dep2, "文書組") %> + <%= check_box("schoool", "depts", {:multiple => true}, "事務組", nil) %><%= label_tag(:dep3, "事務組") %> + <%= check_box("schoool", "depts", {:multiple => true}, "保管組", nil) %><%= label_tag(:dep4, "保管組") %> + <%= check_box("schoool", "depts", {:multiple => true}, "營繕組", nil) %><%= label_tag(:dep5, "營繕組") %> + <%= check_box("schoool", "depts", {:multiple => true}, "出納組", nil) %><%= label_tag(:dep6, "出納組") %> + <%= check_box("schoool", "depts", {:multiple => true}, "採購組", nil) %><%= label_tag(:dep7, "採購組") %> + <%= check_box("schoool", "depts", {:multiple => true}, "經營管理組", nil) %><%= label_tag(:dep8, "經營管理組") %> + <%= check_box("schoool", "depts", {:multiple => true}, "駐警隊", nil) %><%= label_tag(:dep9, "駐警隊") %> + <%= check_box("schoool", "depts", {:multiple => true}, "社科院總務分處", nil) %><%= label_tag(:dep10, "社科院總務分處") %> + <%= check_box("schoool", "depts", {:multiple => true}, "醫學院總務分處", nil) %><%= label_tag(:dep11, "醫學院總務分處") %>
- <%= check_box("schoool", "depts", {:multiple => true}, "總務長室暨總務處秘書室", nil) %><%= label_tag(:dep1, "總務長室暨總務處秘書室") %> - <%= check_box("schoool", "depts", {:multiple => true}, "文書組", nil) %><%= label_tag(:dep2, "文書組") %> - <%= check_box("schoool", "depts", {:multiple => true}, "事務組", nil) %><%= label_tag(:dep3, "事務組") %> - <%= check_box("schoool", "depts", {:multiple => true}, "保管組", nil) %><%= label_tag(:dep4, "保管組") %> - <%= check_box("schoool", "depts", {:multiple => true}, "營繕組", nil) %><%= label_tag(:dep5, "營繕組") %> - <%= check_box("schoool", "depts", {:multiple => true}, "出納組", nil) %><%= label_tag(:dep6, "出納組") %> - <%= check_box("schoool", "depts", {:multiple => true}, "採購組", nil) %><%= label_tag(:dep7, "採購組") %> - <%= check_box("schoool", "depts", {:multiple => true}, "經營管理組", nil) %><%= label_tag(:dep8, "經營管理組") %> - <%= check_box("schoool", "depts", {:multiple => true}, "駐警隊", nil) %><%= label_tag(:dep9, "駐警隊") %> - <%= check_box("schoool", "depts", {:multiple => true}, "社科院總務分處", nil) %><%= label_tag(:dep10, "社科院總務分處") %> - <%= check_box("schoool", "depts", {:multiple => true}, "醫學院總務分處", nil) %><%= label_tag(:dep11, "醫學院總務分處") %> + <%= check_box("school", "depts", {:multiple => true}, "localhost:3000", nil) %><%= label_tag(:dep1, "總務長室暨總務處秘書室") %> + <%= check_box("school", "depts", {:multiple => true}, "localhost:4000", nil) %><%= label_tag(:dep2, "文書組") %> + <%= check_box("school", "depts", {:multiple => true}, "事務組", nil) %><%= label_tag(:dep3, "事務組") %> + <%= check_box("school", "depts", {:multiple => true}, "保管組", nil) %><%= label_tag(:dep4, "保管組") %> + <%= check_box("school", "depts", {:multiple => true}, "營繕組", nil) %><%= label_tag(:dep5, "營繕組") %> + <%= check_box("school", "depts", {:multiple => true}, "出納組", nil) %><%= label_tag(:dep6, "出納組") %> + <%= check_box("school", "depts", {:multiple => true}, "採購組", nil) %><%= label_tag(:dep7, "採購組") %> + <%= check_box("school", "depts", {:multiple => true}, "經營管理組", nil) %><%= label_tag(:dep8, "經營管理組") %> + <%= check_box("school", "depts", {:multiple => true}, "駐警隊", nil) %><%= label_tag(:dep9, "駐警隊") %> + <%= check_box("school", "depts", {:multiple => true}, "社科院總務分處", nil) %><%= label_tag(:dep10, "社科院總務分處") %> + <%= check_box("school", "depts", {:multiple => true}, "醫學院總務分處", nil) %><%= label_tag(:dep11, "醫學院總務分處") %>
@@ -39,6 +55,7 @@ From b7bf180df2b99fd0e7a6493f8666bb0212b8fc19 Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Wed, 11 Sep 2013 16:46:56 +0800 Subject: [PATCH 13/45] fix frontend ask_category error --- .../panel/ask/back_end/ask_replies_controller.rb | 11 +++++------ .../panel/ask/front_end/ask_questions/index.html.erb | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index 55aee182d..ce233ea72 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -27,12 +27,11 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController if @ask_reply.send_email? Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id) end - ## - binding.pry - params[:school][:depts].each do |dns| - send_request(dns, @ask_question, @ask_reply) - end unless params[:school].nil? - ## + + params[:school][:depts].each do |dns| + send_request(dns, @ask_question, @ask_reply) + end unless params[:school].nil? + redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') end diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/index.html.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/index.html.erb index e38c86be6..b0a8da59e 100644 --- a/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/index.html.erb +++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/index.html.erb @@ -35,7 +35,7 @@ $(document).ready(function(){
<%= f.label :ask_category_id, class: 'control-label required' %>
- <%= f.collection_select :ask_category_id, AskCategory.all, :id, :name %> + <%= f.collection_select :ask_category_id, AskCategory.all.select { |c| c.key != 'transfered_question' }, :id, :name %>
From c361a7a20137c4f45e7d630ddb9e73e7ac09d6f8 Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Wed, 11 Sep 2013 17:02:36 +0800 Subject: [PATCH 14/45] Fix check box selections appearance Conflicts: vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb --- .../ask/back_end/ask_replies_controller.rb | 3 +-- .../ask/back_end/ask_questions/edit.html.erb | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index ce233ea72..9ed18e048 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -32,7 +32,6 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController send_request(dns, @ask_question, @ask_reply) end unless params[:school].nil? - redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') end @@ -75,7 +74,7 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController new_status = "轉介其他單位" + "(" + response.code + ")" current_reply.update_attributes(status: new_status) else - new_status = "轉介其他單位" + "(" + "succes!" + ")" + new_status = "轉介其他單位" + "(" + "success!" + ")" current_reply.update_attributes(status: new_status) end end diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb index 90825c6d9..f22ed63ce 100644 --- a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb +++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb @@ -2,7 +2,18 @@ $(document).ready(function() { if ($("#ask_reply_status").val() == '轉介其他單位') { $('.dept_options').show(); } + $("#ask_reply_status").change(function() { + + var local_host = "<%= request.host %>:<%= request.port %>"; + + $('input[type=checkbox]').each(function() { + if ($(this).val() == local_host) { + $(this).addClass("hide"); + $(this).next().addClass("hide"); + } + }); + $('.dept_options').slideUp(); if ($(this).find('option:selected').attr('value') == '轉介其他單位') { $('.dept_options').slideDown(); @@ -16,6 +27,9 @@ $(document).ready(function() { .dept_options { display: none; } +.hide { + display: none; +}
@@ -56,8 +70,8 @@ $(document).ready(function() {
+
<%= check_box("school", "depts", {:multiple => true}, "localhost:3000", nil) %><%= label_tag(:dep1, "總務長室暨總務處秘書室") %> <%= check_box("school", "depts", {:multiple => true}, "localhost:4000", nil) %><%= label_tag(:dep2, "文書組") %> <%= check_box("school", "depts", {:multiple => true}, "事務組", nil) %><%= label_tag(:dep3, "事務組") %> @@ -50,6 +67,7 @@ <%= check_box("school", "depts", {:multiple => true}, "駐警隊", nil) %><%= label_tag(:dep9, "駐警隊") %> <%= check_box("school", "depts", {:multiple => true}, "社科院總務分處", nil) %><%= label_tag(:dep10, "社科院總務分處") %> <%= check_box("school", "depts", {:multiple => true}, "醫學院總務分處", nil) %><%= label_tag(:dep11, "醫學院總務分處") %> +
- <%= check_box("school", "depts", {:multiple => true}, "localhost:3000", nil) %><%= label_tag(:dep1, "總務長室暨總務處秘書室") %> - <%= check_box("school", "depts", {:multiple => true}, "localhost:4000", nil) %><%= label_tag(:dep2, "文書組") %> + <%= check_box("school", "depts", {:multiple => true}, "localhost:3000", nil) %><%= label_tag("localhost:3000", "總務長室暨總務處秘書室") %> + <%= check_box("school", "depts", {:multiple => true}, "localhost:4000", nil) %><%= label_tag("localhost:4000", "文書組") %> <%= check_box("school", "depts", {:multiple => true}, "事務組", nil) %><%= label_tag(:dep3, "事務組") %> <%= check_box("school", "depts", {:multiple => true}, "保管組", nil) %><%= label_tag(:dep4, "保管組") %> <%= check_box("school", "depts", {:multiple => true}, "營繕組", nil) %><%= label_tag(:dep5, "營繕組") %> From 580be0b34b4c59fabe8b087999054663215cf6ce Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Wed, 11 Sep 2013 16:46:56 +0800 Subject: [PATCH 15/45] fix frontend ask_category error --- .../app/controllers/panel/ask/back_end/ask_replies_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index 9ed18e048..9f1374bcd 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -31,7 +31,6 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController params[:school][:depts].each do |dns| send_request(dns, @ask_question, @ask_reply) end unless params[:school].nil? - redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') end From 0c29701f9b522808c19cebe9558a81977be6936a Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Mon, 16 Sep 2013 14:03:26 +0800 Subject: [PATCH 16/45] test --- .../ask/back_end/ask_replies_controller.rb | 55 +++++++------------ .../ask/back_end/ask_requests_controller.rb | 50 ++++++++--------- 2 files changed, 45 insertions(+), 60 deletions(-) diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index 9f1374bcd..743520dba 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -38,45 +38,32 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController require 'net/http' require 'uri' require 'json' - - uri_path = "/panel/ask/back_end/ask_requests/auth_request" + + uri_path = "/panel/ask/back_end/ask_requests/transfer_request" uri = URI.parse("http://" + dep_dns + uri_path) - - body = { - 'auth_token' => '3kjlfksjDFJ' - } - http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri) + body = { + # 'auth_token' => '3kjlfksjDFJ', + 'name' => current_question.name, + 'title' => current_question.title, + 'identity' => current_question.identity, + 'email' => current_question.email, + 'phone' => current_question.phone, + 'tax' => current_question.tax, + 'content' => current_question.content, + } request.set_form_data(body) + request.add_field 'X-Auth-Token', '3kjlfksjDFJ' response = http.request(request) - puts "Response #{response.code} #{response.message}: #{response.body}" - - if response.code == "200" - uri_path = "/panel/ask/back_end/ask_requests/transfer_request" - uri = URI.parse("http://" + dep_dns + uri_path) - http = Net::HTTP.new(uri.host, uri.port) - request = Net::HTTP::Post.new(uri.request_uri) - body = { - 'name' => current_question.name, - 'title' => current_question.title, - 'identity' => current_question.identity, - 'email' => current_question.email, - 'phone' => current_question.phone, - 'tax' => current_question.tax, - 'content' => current_question.content, - } - request.set_form_data(body) - response = http.request(request) - - if response.code != "200" - new_status = "轉介其他單位" + "(" + response.code + ")" - current_reply.update_attributes(status: new_status) - else - new_status = "轉介其他單位" + "(" + "success!" + ")" - current_reply.update_attributes(status: new_status) - end - end + # binding.pry + if response.code != "200" + new_status = "轉介其他單位" + "(" + response.code + ")" + current_reply.update_attributes(status: new_status) + else + new_status = "轉介其他單位" + "(" + "success!" + ")" + current_reply.update_attributes(status: new_status) + end puts "Response #{response.code} #{response.message}: #{response.body}" # flash[:notice] = response.body diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb index eff47c5ff..ce98c0a98 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb @@ -1,35 +1,33 @@ # encoding: utf-8 class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController - include AdminHelper include OrbitControllerLib::DivisionForDisable - - def auth_request - render :json => "#{params}" - end - + # skip_before_filter :verify_authenticity_token + def transfer_request - - if !AskCategory.where(key: "transfered_question").any? - @ask_category = AskCategory.new(name: "transfered_question", key: "transfered_question") - @ask_category.save! + + if request.headers["HTTP_X_AUTH_TOKEN"] == '3kjlfksjDFJ' + if !AskCategory.where(key: "transfered_question").any? + @ask_category = AskCategory.new(name: "transfered_question", key: "transfered_question") + @ask_category.save! + end + category = AskCategory.where(key: "transfered_question") + @transfered_question = AskQuestion.new( + name: params['name'], + identity: params['identity'], + email: params['email'], + phone: params['phone'], + tax: params['tax'], + title: params['title'], + content: params['content'], + ask_category_id: category.first.id) + @transfered_question.ask_reply = AskReply.new + @transfered_question.ask_reply.update_attributes(status: "待處理(轉)") + @transfered_question.save + render :nothing => true + else + render :status => 500 end - category = AskCategory.where(key: "transfered_question") - - @transfered_question = AskQuestion.new( - name: params['name'], - identity: params['identity'], - email: params['email'], - phone: params['phone'], - tax: params['tax'], - title: params['title'], - content: params['content'], - ask_category_id: category.first.id) - @transfered_question.ask_reply = AskReply.new - @transfered_question.ask_reply.update_attributes(status: "待處理(轉)") - @transfered_question.save - - render :json => "#{params}" end end \ No newline at end of file From e89615a6f39dc5ee084a9f84e63087ae9d8db373 Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Tue, 17 Sep 2013 12:02:35 +0800 Subject: [PATCH 17/45] Fix naming error --- config/mongoid.yml | 24 ------------------ .../ask/back_end/ask_replies_controller.rb | 5 ++-- .../ask/back_end/ask_requests_controller.rb | 25 +++++++++++-------- .../ask/back_end/ask_questions/edit.html.erb | 2 +- 4 files changed, 19 insertions(+), 37 deletions(-) delete mode 100644 config/mongoid.yml diff --git a/config/mongoid.yml b/config/mongoid.yml deleted file mode 100644 index 7e8d9e5cf..000000000 --- a/config/mongoid.yml +++ /dev/null @@ -1,24 +0,0 @@ -defaults: &defaults - host: localhost - # slaves: - # - host: slave1.local - port: 27017 - # - host: slave2.local - # port: 27019 - -development: - <<: *defaults - database: test_site -test: - <<: *defaults - database: test_site - -# set these environment variables on your prod server -production: - # host: <%= ENV['MONGOID_HOST'] %> - # port: <%= ENV['MONGOID_PORT'] %> - # username: <%= ENV['MONGOID_USERNAME'] %> - # password: <%= ENV['MONGOID_PASSWORD'] %> - # database: <%= ENV['MONGOID_DATABASE'] %> - <<: *defaults - database: test_site diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb index 743520dba..d77f582e7 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_replies_controller.rb @@ -44,7 +44,7 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri) body = { - # 'auth_token' => '3kjlfksjDFJ', + # 'auth_token' => '3kjlfksjDFJ', 'name' => current_question.name, 'title' => current_question.title, 'identity' => current_question.identity, @@ -53,6 +53,7 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController 'tax' => current_question.tax, 'content' => current_question.content, } + request.set_form_data(body) request.add_field 'X-Auth-Token', '3kjlfksjDFJ' response = http.request(request) @@ -61,7 +62,7 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController new_status = "轉介其他單位" + "(" + response.code + ")" current_reply.update_attributes(status: new_status) else - new_status = "轉介其他單位" + "(" + "success!" + ")" + new_status = "轉介其他單位" + "(" + " Success!" + ")" current_reply.update_attributes(status: new_status) end diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb index ce98c0a98..3580fc283 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb @@ -7,23 +7,28 @@ class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController def transfer_request if request.headers["HTTP_X_AUTH_TOKEN"] == '3kjlfksjDFJ' - if !AskCategory.where(key: "transfered_question").any? - @ask_category = AskCategory.new(name: "transfered_question", key: "transfered_question") + if !AskCategory.where(key: "transferred_question").any? + @ask_category = AskCategory.new(key: "transferred_question") + @ask_category.name_translations = { "zh_tw" => "轉介的問題", "en" => "Transferred Question" } @ask_category.save! end - category = AskCategory.where(key: "transfered_question") + + category = AskCategory.where(key: "transferred_question") + @transfered_question = AskQuestion.new( - name: params['name'], + name: params['name'], identity: params['identity'], - email: params['email'], - phone: params['phone'], - tax: params['tax'], - title: params['title'], - content: params['content'], + email: params['email'], + phone: params['phone'], + tax: params['tax'], + title: params['title'], + content: params['content'], ask_category_id: category.first.id) + @transfered_question.ask_reply = AskReply.new - @transfered_question.ask_reply.update_attributes(status: "待處理(轉)") + @transfered_question.ask_reply.update_attributes(status: "待處理 (轉)") @transfered_question.save + render :nothing => true else render :status => 500 diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb index f22ed63ce..e96e4710a 100644 --- a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb +++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb @@ -1,7 +1,7 @@
- <%= check_box("school", "depts", {:multiple => true}, (request.host + ":14180"), nil) %><%= label_tag((request.host + ":14180"), "測試站14180") %> - <%= check_box("school", "depts", {:multiple => true}, (request.host + ":14280"), nil) %><%= label_tag((request.host + ":14280"), "測試站14280") %> + + <%= check_box("school", "depts", {:multiple => true}, (request.host + ":3000"), nil) %><%= label_tag((request.host + ":3000"), "測試站3000") %> + <%= check_box("school", "depts", {:multiple => true}, (request.host + ":4000"), nil) %><%= label_tag((request.host + ":4000"), "測試站4000") %> <%= check_box("school", "depts", {:multiple => true}, "", nil) %><%= label_tag(:dep1, "總務長室暨總務處秘書室") %> <%= check_box("school", "depts", {:multiple => true}, "文書組", nil) %><%= label_tag(:dep2, "文書組") %> <%= check_box("school", "depts", {:multiple => true}, "事務組", nil) %><%= label_tag(:dep3, "事務組") %> From 75f5404b7aad77137d1491a8d71534a99e5c2cc9 Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Tue, 8 Oct 2013 17:36:03 +0800 Subject: [PATCH 43/45] Modify value to test servers --- .../panel/ask/back_end/ask_questions/edit.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb index 1556a073f..fab97631a 100644 --- a/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb +++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_questions/edit.html.erb @@ -1,6 +1,6 @@