From d2edc29945f8a383a8525d59536d4c3debb5df16 Mon Sep 17 00:00:00 2001 From: rulingcom Date: Tue, 3 Sep 2024 23:56:53 +0800 Subject: [PATCH] Adjust send_email field to multiple options. --- app/controllers/admin/asks_controller.rb | 2 +- app/models/ask_question.rb | 6 ++++- app/views/admin/asks/_form.html.erb | 31 +++++++++++++++++++++--- config/locales/en.yml | 4 +++ config/locales/zh_tw.yml | 4 +++ lib/ask/engine.rb | 2 ++ 6 files changed, 44 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/asks_controller.rb b/app/controllers/admin/asks_controller.rb index 1be26cc..fd97887 100644 --- a/app/controllers/admin/asks_controller.rb +++ b/app/controllers/admin/asks_controller.rb @@ -391,7 +391,7 @@ class Admin::AsksController < OrbitAdminController end temp_params = temp_params.merge({reviewer: current_user.member_profile, review_time: DateTime.now}) @ask_question.update_attributes(temp_params) - if @ask_question.send_email + if @ask_question.send_email? build_email(@ask_question) end diff --git a/app/models/ask_question.rb b/app/models/ask_question.rb index c068304..54ef4bb 100644 --- a/app/models/ask_question.rb +++ b/app/models/ask_question.rb @@ -20,8 +20,8 @@ class AskQuestion field :reply, type: String field :comment, type: String - field :send_email, type: Boolean, default: false field :situation, type: String, default: "is_email_not_confirmed" # 預設email未驗證 + field :send_email, type: Integer, default: 0 field :email_id field :verify_email_id field :custom_values, type: Hash, default: {} @@ -75,5 +75,9 @@ class AskQuestion def display_format_string(num, str_length) format("%0#{str_length}d", num) end + + def send_email? + self.send_email == 1 + end end end diff --git a/app/views/admin/asks/_form.html.erb b/app/views/admin/asks/_form.html.erb index 6e376ca..b019e4c 100644 --- a/app/views/admin/asks/_form.html.erb +++ b/app/views/admin/asks/_form.html.erb @@ -97,9 +97,34 @@ - <%= f.label :send_email %><%= f.radio_button :send_email, 1, checked: @ask_question.send_email? %><%= t('ask.yes') %> -      - <%= f.radio_button :send_email, 0, checked: !@ask_question.send_email? %><%= t('ask.no') %> + <%= f.label :send_email, class: "control-label muted" %> + +
+ + + + + + + + + +
diff --git a/config/locales/en.yml b/config/locales/en.yml index 64571e3..ed18bf8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -99,6 +99,10 @@ en: is_published: Processed and Published 'yes': 'Yes' 'no': 'No' + system_Email: System Email + phone: Phone + fax: Fax + paper: Paper required: Required datepicker: Select a Date enable_range_setting: Enable Time Range Setting diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 437de26..1b17c53 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -102,6 +102,10 @@ zh_tw: is_published: 已處理並發佈網頁 'yes': 是 'no': 否 + system_Email: 系統發信 + phone: 電話 + fax: 傳真 + paper: 回覆函 required: 必填 datepicker: 選擇日期 enable_range_setting: 啟用時間區段設定 diff --git a/lib/ask/engine.rb b/lib/ask/engine.rb index b961725..0dfc200 100644 --- a/lib/ask/engine.rb +++ b/lib/ask/engine.rb @@ -112,6 +112,8 @@ module Ask end end fix_reviewer + AskQuestion.where(send_email: false).update_all(send_email: 0) + AskQuestion.where(send_email: true).update_all(send_email: 1) OrbitApp.registration "Ask", :type => "ModuleApp" do module_label "ask.ask" base_url File.expand_path File.dirname(__FILE__)