diff --git a/app/controllers/asks_controller.rb b/app/controllers/asks_controller.rb
index 4bd170c..2dde28e 100644
--- a/app/controllers/asks_controller.rb
+++ b/app/controllers/asks_controller.rb
@@ -361,9 +361,9 @@ class AsksController < ApplicationController
email_er.email_id = email.id
email_er.save
- @group_mail = email_er.mail
- @manager_emails = email_er.reviewer_emails
- @mail_sentdate = DateTime.now
+ group_mail = email_er.mail
+ manager_emails = email_er.reviewer_emails
+ mail_sentdate = DateTime.now
site = current_site rescue Site.first
mail_from = site.title_translations[site.default_locale]
@@ -375,9 +375,9 @@ class AsksController < ApplicationController
email_er.email.update_attributes(
:mail_lang=> site.default_locale,
:create_user=>(current_user rescue nil),
- :mail_sentdate=>@mail_sentdate,
+ :mail_sentdate=>mail_sentdate,
:module_app=>@module_app,
- :mail_to=>@group_mail,
+ :mail_to=>group_mail,
:mail_subject=>mail_subject,
:template=>'asks/email',
:template_data=>{
@@ -394,16 +394,16 @@ class AsksController < ApplicationController
"site_host" => host_url,
"usage_rule" => @usage_rule
},
- :mail_reply_to => (@manager_emails.empty? ? nil : @manager_emails)
+ :mail_reply_to => (manager_emails.empty? ? nil : manager_emails)
)
- if !@manager_emails.empty?
+ if !manager_emails.empty?
Email.new(
:mail_lang=> site.default_locale,
:create_user=>(current_user rescue nil),
- :mail_sentdate=>@mail_sentdate,
+ :mail_sentdate=>mail_sentdate,
:module_app=>@module_app,
- :mail_to=>@manager_emails,
- :mail_subject=>mail_subject+" #{@group_mail}",
+ :mail_to=>manager_emails,
+ :mail_subject=>mail_subject+" #{group_mail}",
:template=>'asks/email',
:template_data=>{
# "title" => email_er.title,
diff --git a/app/models/ask_category_setting.rb b/app/models/ask_category_setting.rb
index 8b4cc25..1a11553 100644
--- a/app/models/ask_category_setting.rb
+++ b/app/models/ask_category_setting.rb
@@ -155,15 +155,18 @@ class AskCategorySetting
field :default_setting_required, type: Hash,default: {title:true,ask_category_id: true,name: true,sex: true,mail: true,phone: false,appointment: false,recaptcha: true,agree_show: false,agree_usage: true}
field :default_setting_field_name, type: Hash,default: {}
field :default_setting_prompt_word, type: Hash,default: {}
- field :use_default, type: Boolean, default: false
+
field :custom_fields, type: Hash,default: {}
field :usage_rule, type: String, default: ''
- field :category_id, type: String
field :title_layout, type: Integer, default: 0
field :need_check_customs, type: Array, default: [] #From AskSetting
field :reject_customs, type: Array, default: [] #From AskSetting
field :agree_customs, type: Array, default: [] #From AskSetting
+
+ field :category_id, type: String
+ field :use_default, type: Boolean, default: false
+
scope :enabled, ->{any_of([{:use_default.ne=>true}, {:use_default=>true, :default_sort_number.nin=>[nil, {}]}])}
scope :custom_enabled, ->{where({:use_default.ne=>true})}
end
diff --git a/app/models/ask_file.rb b/app/models/ask_file.rb
index c2af899..04e8adb 100644
--- a/app/models/ask_file.rb
+++ b/app/models/ask_file.rb
@@ -1,7 +1,7 @@
class AskFile
- include Mongoid::Document
- include Mongoid::Timestamps
+ include Mongoid::Document
+ include Mongoid::Timestamps
- mount_uploader :file, AssetUploader
- field :ask_question_id
+ mount_uploader :file, AssetUploader
+ field :ask_question_id
end
\ No newline at end of file
diff --git a/app/models/ask_question.rb b/app/models/ask_question.rb
index d661de8..cd52757 100644
--- a/app/models/ask_question.rb
+++ b/app/models/ask_question.rb
@@ -5,7 +5,7 @@ class AskQuestion
include OrbitCategory::Categorizable
# include OrbitTag::Taggable
- # 欄位
+ # 欄位定義
field :serial_number, type: Integer
field :ip, type: String
field :name, type: String
@@ -15,7 +15,7 @@ class AskQuestion
field :fax, type: String
field :title, type: String
field :content, type: String
- field :appointment, type:DateTime
+ field :appointment, type: DateTime
field :sex
field :reply, type: String
@@ -29,9 +29,8 @@ class AskQuestion
field :agree_usage, type: Boolean, default: false
field :review_time, type: DateTime
- belongs_to :reviewer , :class_name=>"MemberProfile", :foreign_key => :reviewer_id
+ belongs_to :reviewer, class_name: "MemberProfile", foreign_key: :reviewer_id
- # validates_presence_of :name, :identity, :mail, :title, :content
before_create do
last_serial_number = AskSetting.update_last_serial_number
self.serial_number = last_serial_number
@@ -43,9 +42,10 @@ class AskQuestion
def verify_email
verify_email = Email.where(:id=>self.verify_email_id).first
end
+
def reviewer_emails
- email_address = AskAdmin.or(:category_ids.in => [self.category_id, [], nil]).pluck(:email).select{|s| s.present?}.uniq rescue []
- authorizes = Authorization.where(:module_app_id=>ModuleApp.where(:key=>'ask').first.id).to_a rescue []
+ email_address = AskAdmin.or(:category_ids.in => [self.category_id, [], nil]).pluck(:email).select { |s| s.present? }.uniq rescue []
+ authorizes = Authorization.where(module_app_id: ModuleApp.where(key: 'ask').first.id).to_a rescue []
authorizes.each do |a|
if a.category_id
next if a.category_id != self.category_id
@@ -54,7 +54,7 @@ class AskQuestion
u = a.user
email_address << u.email if u && u.email
elsif a.role_id
- email_address = email_address + MemberProfile.where(:role_ids=>a.role_id).pluck(:email).select{|s| s.present?}.uniq
+ email_address = email_address + MemberProfile.where(role_ids: a.role_id).pluck(:email).select { |s| s.present? }.uniq
else
a.destroy
end
@@ -62,6 +62,7 @@ class AskQuestion
email_address = email_address.flatten
email_address.uniq
end
+
def get_serial_number(last_serial_number=nil, display_length=nil)
if display_length.nil? && last_serial_number.nil?
can_update_shared_hash = (defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash)
@@ -70,7 +71,9 @@ class AskQuestion
display_length = [last_serial_number.to_s.length + 1, 4].max if display_length.nil?
display_format_string(self.serial_number, display_length)
end
+
def display_format_string(num, str_length)
- return format("%0#{str_length}d", num)
+ format("%0#{str_length}d", num)
+ end
end
end
diff --git a/app/views/admin/asks/_index.html.erb b/app/views/admin/asks/_index.html.erb
index 507a9b3..2ebc945 100644
--- a/app/views/admin/asks/_index.html.erb
+++ b/app/views/admin/asks/_index.html.erb
@@ -182,7 +182,6 @@
situation_class_relation = {
"is_waiting"=>"label-important",
"is_processed"=>"label-warning",
- "is_referral"=>"",
"is_published"=>"label-success"
}
situation_trans = AskTicketStatus.all.map{|a| [a.key, a.title]}.to_h
@@ -203,7 +202,7 @@
<% when 'serial_number' %>
<%= b.get_serial_number(last_serial_number, display_length) %>
<% when 'situation' %>
- <%= situation_trans[b.situation] %>
+ <%= situation_trans[b.situation] %>
<% when 'ask_category_id' %>
<%= b.category.title rescue 'category not set' %>
<% when 'sex' %>
diff --git a/app/views/admin/asks/email.html.erb b/app/views/admin/asks/email.html.erb
index b8d4678..787578a 100644
--- a/app/views/admin/asks/email.html.erb
+++ b/app/views/admin/asks/email.html.erb
@@ -8,6 +8,6 @@
<%= @data['reply'].to_s.gsub(/[(\n)(\r)]/, "\n" => "
", "\r" => "" ).html_safe %>
此為系統自動發信,請勿直接回覆
+<%= t('ask.email_automation_hint') %>