diff --git a/config/mongoid.yml b/config/mongoid.yml index 7e8d9e5cf..b42849e50 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -12,7 +12,6 @@ development: test: <<: *defaults database: test_site - # set these environment variables on your prod server production: # host: <%= ENV['MONGOID_HOST'] %> @@ -21,4 +20,4 @@ production: # password: <%= ENV['MONGOID_PASSWORD'] %> # database: <%= ENV['MONGOID_DATABASE'] %> <<: *defaults - database: test_site + database: production_8 diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_coordinations_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_coordinations_controller.rb new file mode 100644 index 000000000..241289b3a --- /dev/null +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_coordinations_controller.rb @@ -0,0 +1,15 @@ +class Panel::Ask::BackEnd::AskCoordinationsController < OrbitWidgetController + + include AdminHelper + include OrbitControllerLib::DivisionForDisable + + before_filter :for_app_manager + + def initialize + super + @app_title = 'ask_coordinations' + end + + def index + end +end \ No newline at end of file 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..abefaf985 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 @@ -13,19 +13,122 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController def create @ask_question = AskQuestion.find(params[:ask_question_id]) @ask_question.ask_reply = AskReply.new(params[:ask_reply]) + @ask_reply = @ask_question.ask_reply @ask_question.save if @ask_question.ask_reply.send_email? Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id) end + + status_stack = [] + new_status = "" + params[:school][:depts].each do |dns| + begin + status_stack << send_request(dns, @ask_question, @ask_reply) + rescue + status_stack << "fail" + end + end unless params[:school].nil? + + success_count = status_stack.count("success") + failed_count = status_stack.count("fail") + + if failed_count == 0 && success_count > 0 + new_status = "轉介其他單位" + elsif failed_count > 0 && success_count > 0 + new_status = "部份轉介失敗" + elsif failed_count > 0 && success_count == 0 + new_status = "轉介失敗" + elsif failed_count == 0 && success_count == 0 && @ask_reply.status == "待處理" + new_status = "待處理" + elsif failed_count == 0 && success_count == 0 && @ask_reply.status == "已處理" + new_status = "已處理" + elsif failed_count == 0 && success_count == 0 && @ask_reply.status == "轉介其他單位" + new_status = "轉介失敗" + end + + @ask_reply.update_attributes(status: new_status) + redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') 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 + + status_stack = [] + new_status = "" + params[:school][:depts].each do |dns| + begin + status_stack << send_request(dns, @ask_question, @ask_reply) + rescue + status_stack << "fail" + end + end unless params[:school].nil? + + success_count = status_stack.count("success") + failed_count = status_stack.count("fail") + + if failed_count == 0 && success_count > 0 + new_status = "轉介其他單位" + elsif failed_count > 0 && success_count > 0 + new_status = "部份轉介失敗" + elsif failed_count > 0 && success_count == 0 + new_status = "轉介失敗" + elsif failed_count == 0 && success_count == 0 && @ask_reply.status == "待處理" + new_status = "待處理" + elsif failed_count == 0 && success_count == 0 && @ask_reply.status == "已處理" + new_status = "已處理" + elsif failed_count == 0 && success_count == 0 && @ask_reply.status == "轉介其他單位" + new_status = "轉介失敗" + end + + @ask_reply.update_attributes(status: new_status) redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success') end + + def send_request(dep_dns, current_question, current_reply) + require 'net/http' + require 'uri' + require 'json' + + 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 = { + # '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, + } + #binding.pry + status = "" + 3.times do + request.set_form_data(body) + request.add_field 'X-Auth-Token', '3kjlfksjDFJ' + response = http.request(request) + + if response.code == "200" + status = "success" + break + else + status = "fail" + end + end + + return status + # puts "Response #{response.code} #{response.message}: #{response.body}" + # flash[:notice] = response.body + # flash[:notice] = "Response #{response.code} #{response.message}: #{response.body}" + end + 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 new file mode 100644 index 000000000..28c499fb2 --- /dev/null +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/back_end/ask_requests_controller.rb @@ -0,0 +1,38 @@ +# encoding: utf-8 +class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController + include AdminHelper + include OrbitControllerLib::DivisionForDisable + skip_before_filter :verify_authenticity_token + + def transfer_request + + if request.headers["HTTP_X_AUTH_TOKEN"] == '3kjlfksjDFJ' + 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: "transferred_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 + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/front_end/ask_questions_controller.rb b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/front_end/ask_questions_controller.rb index 5de179f37..e94ffe0bf 100644 --- a/vendor/built_in_modules/ask_new/app/controllers/panel/ask/front_end/ask_questions_controller.rb +++ b/vendor/built_in_modules/ask_new/app/controllers/panel/ask/front_end/ask_questions_controller.rb @@ -14,18 +14,22 @@ class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController def create @ask_question = AskQuestion.new(params[:ask_question]) if gotcha_valid? && @ask_question.save - @acknowledgement = AskAcknowledgement.last + @acknowledgement = AskAcknowledgement.last @ask_acknowledgement = AskAcknowledgement.first || AskAcknowlegement.new - #@ask_question.save - redirect_to root_path + AskAdmin.all.each do |ask_admin| AskMailer.notice(ask_admin, @ask_question).deliver Resque.enqueue(SendAskNoticeMail, ask_admin.id, @ask_question.id) end - # redirect_to panel_ask_front_end_thank_you_path + + # Render to create.js.erb respond_to do |format| format.js - # format.js { render :thank_you, notice: 'Your question has been successfully sent.' } + end + else + # Render to index.js.erb + respond_to do |format| + format.js { render :index } end end end @@ -43,4 +47,7 @@ class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController end @item = Page.find(params[:page_id]) rescue nil end + + def sorry + 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 7225f69a1..c87672622 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,47 @@ + + + +
+ | ||||
+ | + +||||
<%= f.label :send_email %><%= f.radio_button :send_email, 1, checked: @ask_reply.send_email? %><%= t('ask.yes') %>
diff --git a/log/.gitignore b/vendor/built_in_modules/ask_new/app/views/panel/ask/back_end/ask_requests/auth_request.html.erb
similarity index 100%
rename from log/.gitignore
rename to 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/views/panel/ask/front_end/ask_questions/create.js.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/create.js.erb
index b9e03a590..a1951909d 100644
--- a/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/create.js.erb
+++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/create.js.erb
@@ -1 +1 @@
-window.location.href= "<%= panel_ask_front_end_thank_you_path %>"
+window.location.href = "<%= panel_ask_front_end_thank_you_path %>";
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..9a6721a2a 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
@@ -21,9 +21,9 @@ $(document).ready(function(){
$(this).hide();
}).bind("ajaxError", function() {
$(this).hide();
+ // window.location.href = "<%= panel_ask_front_end_thank_you_path %>";
});
-
- });
+});
- <%= form_for @ask_question, url: panel_ask_front_end_ask_questions_path(standalone: true), html: {class: 'form-horizontal'} do |f| %>
+ <%= form_for @ask_question, url: panel_ask_front_end_ask_questions_path(standalone: true), html: {class: 'form-horizontal'}, method: :post do |f| %>
<%= 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 != 'transferred_question' }, :id, :name %>
diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/index.js.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/index.js.erb
new file mode 100644
index 000000000..bc272ab14
--- /dev/null
+++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/index.js.erb
@@ -0,0 +1 @@
+window.location.href = "<%= panel_ask_front_end_sorry_path %>";
\ No newline at end of file
diff --git a/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/sorry.html.erb b/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/sorry.html.erb
new file mode 100644
index 000000000..674de72f8
--- /dev/null
+++ b/vendor/built_in_modules/ask_new/app/views/panel/ask/front_end/ask_questions/sorry.html.erb
@@ -0,0 +1 @@
+ <%= t(:ask_fail, :scope => :ask) %> !\ No newline at end of file diff --git a/vendor/built_in_modules/ask_new/config/locales/en.yml b/vendor/built_in_modules/ask_new/config/locales/en.yml index a4aeacae6..dcde262a0 100644 --- a/vendor/built_in_modules/ask_new/config/locales/en.yml +++ b/vendor/built_in_modules/ask_new/config/locales/en.yml @@ -1,5 +1,6 @@ en: ask: + ask_fail: Something went wrong ask: Ask export: Export reply: Reply diff --git a/vendor/built_in_modules/ask_new/config/locales/zh_tw.yml b/vendor/built_in_modules/ask_new/config/locales/zh_tw.yml index 0b8109b11..452dbc407 100644 --- a/vendor/built_in_modules/ask_new/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/ask_new/config/locales/zh_tw.yml @@ -3,6 +3,7 @@ zh_tw: errors: verification_failed: 驗證碼錯誤 ask: + ask_fail: 寄送失敗 ask: 發問 export: 匯出 reply: 回覆 diff --git a/vendor/built_in_modules/ask_new/config/routes.rb b/vendor/built_in_modules/ask_new/config/routes.rb index 0c4894874..0e44b4693 100644 --- a/vendor/built_in_modules/ask_new/config/routes.rb +++ b/vendor/built_in_modules/ask_new/config/routes.rb @@ -11,14 +11,18 @@ 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' + match "ask_requests/transfer_request" => "ask_requests#transfer_request", :as => 'transfer_request' end namespace :front_end do match "ask_questions/thank_you" => "ask_questions#thank_you", :as => 'thank_you' + match "ask_questions/sorry" => "ask_questions#sorry", :as => 'sorry' resources :ask_questions end end diff --git a/vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~HEAD b/vendor/built_in_modules/ask_new/test/dummy/app/mailers/.gitkeep~HEAD new file mode 100644 index 000000000..e69de29bb 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) %>
diff --git a/vendor/built_in_modules/survey/init.rb b/vendor/built_in_modules/survey/init.rb
index c4864de77..72e60452a 100644
--- a/vendor/built_in_modules/survey/init.rb
+++ b/vendor/built_in_modules/survey/init.rb
@@ -22,7 +22,8 @@ module Faq
default_widget do
enable ["typeA"]
query 'Survey.any_of( {:postdate.lte => Time.now} )'
- link_field :title, {:method => 'panel_survey_front_end_survey_path',:args=>:self}
+ # link_field :title, {:method => 'panel_survey_front_end_survey_path',:args=>:self}
+ field :title
field :time_range
field :write
field :result
- <%= 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 %>
|