管理者新增指定類別功能,新增審核者紀錄功能,修復錯誤
This commit is contained in:
parent
8eaa74ec9c
commit
102a4f49cc
|
@ -389,7 +389,7 @@ class Admin::AsksController < OrbitAdminController
|
||||||
temp_params['custom_values'][to_save[0]] = [temp_params['custom_values'][to_save[0]].original_filename ,to_save[1].file.url]
|
temp_params['custom_values'][to_save[0]] = [temp_params['custom_values'][to_save[0]].original_filename ,to_save[1].file.url]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
temp_params = temp_params.merge({reviewer: current_user.member_profile, review_time: DateTime.now})
|
||||||
@ask_question.update_attributes(temp_params)
|
@ask_question.update_attributes(temp_params)
|
||||||
if @ask_question.send_email
|
if @ask_question.send_email
|
||||||
build_email(@ask_question)
|
build_email(@ask_question)
|
||||||
|
|
|
@ -255,7 +255,6 @@ class AsksController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
puts "flag", flag
|
|
||||||
flag = !ask_setting.default_setting['recaptcha'] || gotcha_valid?
|
flag = !ask_setting.default_setting['recaptcha'] || gotcha_valid?
|
||||||
if flag
|
if flag
|
||||||
all_to_save.each do |to_save|
|
all_to_save.each do |to_save|
|
||||||
|
@ -291,7 +290,8 @@ class AsksController < ApplicationController
|
||||||
email_er.email_id = email.id
|
email_er.email_id = email.id
|
||||||
email_er.save
|
email_er.save
|
||||||
|
|
||||||
@group_mail = email_er.email_address
|
@group_mail = email_er.mail
|
||||||
|
@manager_emails = email_er.reviewer_emails
|
||||||
@mail_sentdate = DateTime.now
|
@mail_sentdate = DateTime.now
|
||||||
|
|
||||||
site = current_site rescue Site.first
|
site = current_site rescue Site.first
|
||||||
|
@ -300,13 +300,14 @@ class AsksController < ApplicationController
|
||||||
if host_url == "http://"
|
if host_url == "http://"
|
||||||
host_url = request.protocol + request.host_with_port
|
host_url = request.protocol + request.host_with_port
|
||||||
end
|
end
|
||||||
|
mail_subject = mail_from+" #{t('ask.new_question')}:"
|
||||||
email_er.email.update_attributes(
|
email_er.email.update_attributes(
|
||||||
:mail_lang=> site.default_locale,
|
:mail_lang=> site.default_locale,
|
||||||
:create_user=>(current_user rescue nil),
|
:create_user=>(current_user rescue nil),
|
||||||
:mail_sentdate=>@mail_sentdate,
|
:mail_sentdate=>@mail_sentdate,
|
||||||
:module_app=>@module_app,
|
:module_app=>@module_app,
|
||||||
:mail_to=>@group_mail,
|
:mail_to=>@group_mail,
|
||||||
:mail_subject=>mail_from+" #{t('ask.new_question')}:",
|
:mail_subject=>mail_subject,
|
||||||
:template=>'asks/email',
|
:template=>'asks/email',
|
||||||
:template_data=>{
|
:template_data=>{
|
||||||
# "title" => email_er.title,
|
# "title" => email_er.title,
|
||||||
|
@ -321,8 +322,35 @@ class AsksController < ApplicationController
|
||||||
"ask_question_id" => email_er.id.to_s,
|
"ask_question_id" => email_er.id.to_s,
|
||||||
"site_host" => host_url,
|
"site_host" => host_url,
|
||||||
"usage_rule" => @usage_rule
|
"usage_rule" => @usage_rule
|
||||||
}
|
},
|
||||||
|
:mail_reply_to => (@manager_emails.empty? ? nil : @manager_emails)
|
||||||
)
|
)
|
||||||
|
if !@manager_emails.empty?
|
||||||
|
Email.new(
|
||||||
|
:mail_lang=> site.default_locale,
|
||||||
|
:create_user=>(current_user rescue nil),
|
||||||
|
:mail_sentdate=>@mail_sentdate,
|
||||||
|
:module_app=>@module_app,
|
||||||
|
:mail_to=>@group_mail,
|
||||||
|
:mail_subject=>mail_subject+" #{@group_mail}",
|
||||||
|
:template=>'asks/email',
|
||||||
|
:template_data=>{
|
||||||
|
# "title" => email_er.title,
|
||||||
|
"name" => email_er.name,
|
||||||
|
"identity" => email_er[:identity],
|
||||||
|
"mail" => email_er.mail,
|
||||||
|
"phone" => email_er.phone,
|
||||||
|
# "fax" => email_er.fax,
|
||||||
|
# "content" => email_er.content
|
||||||
|
"appointment" => email_er.appointment,
|
||||||
|
"disp_fields_infos" => @disp_fields_infos,
|
||||||
|
"ask_question_id" => email_er.id.to_s,
|
||||||
|
"site_host" => host_url,
|
||||||
|
"usage_rule" => @usage_rule,
|
||||||
|
"edit_url" => "#{host_url}/#{site.default_locale}/admin/asks/#{email_er.id}/edit"
|
||||||
|
}
|
||||||
|
).save
|
||||||
|
end
|
||||||
# email_er.email.deliver
|
# email_er.email.deliver
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -357,7 +385,7 @@ class AsksController < ApplicationController
|
||||||
has_ask_category_id = false
|
has_ask_category_id = false
|
||||||
disp_fields_infos.each do |field, info|
|
disp_fields_infos.each do |field, info|
|
||||||
if field.start_with?("default@")
|
if field.start_with?("default@")
|
||||||
k = field[8..-1]
|
k = is_cat_record ? field : field[8..-1]
|
||||||
v = ask_setting.custom_fields[k]
|
v = ask_setting.custom_fields[k]
|
||||||
if v
|
if v
|
||||||
field_name = info['trans']
|
field_name = info['trans']
|
||||||
|
|
|
@ -3,4 +3,5 @@ class AskAdmin
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
field :email, type: String
|
field :email, type: String
|
||||||
|
has_and_belongs_to_many :categories
|
||||||
end
|
end
|
|
@ -136,10 +136,10 @@ class AskCategorySetting
|
||||||
end
|
end
|
||||||
def get_email_regex(frontend=false)
|
def get_email_regex(frontend=false)
|
||||||
tmp = self.email_regex
|
tmp = self.email_regex
|
||||||
if tmp
|
if tmp && frontend
|
||||||
tmp = tmp.gsub("\\A","^").gsub("\\z","$").gsub("\\","\\\\\\\\")
|
tmp = tmp.gsub("\\A","^").gsub("\\z","$").gsub("\\","\\\\\\\\")
|
||||||
end
|
end
|
||||||
tmp = nil if !(self.email_regex_enable) || (self.application_form_signup_field_sets.where(:field_name=>'email').pluck(:disabled)[0] rescue false)
|
tmp = nil if !(self.email_regex_enable) || ((self.default_setting[:mail] == false) rescue false)
|
||||||
tmp
|
tmp
|
||||||
end
|
end
|
||||||
field :tmp_sort_number, type: Hash, default: {} # For Frontend
|
field :tmp_sort_number, type: Hash, default: {} # For Frontend
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
class AskListSetting
|
class AskListSetting
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
DefaultFields = ['serial_number','situation','ask_category_id','title','name','sex','mail','phone','appointment','created_at','ip']
|
DefaultFields = ['serial_number','situation','ask_category_id','title','name','sex','mail','phone','appointment','created_at','ip','reviewer','review_time']
|
||||||
DefaultEnabled = ['serial_number','situation','ask_category_id','title','name','phone','appointment','created_at','ip']
|
DefaultEnabled = ['serial_number','situation','ask_category_id','title','name','phone','appointment','created_at','ip','reviewer','review_time']
|
||||||
field :default_fields, type: Array, default: []
|
field :default_fields, type: Array, default: []
|
||||||
field :custom_fields, type: Array, default: []
|
field :custom_fields, type: Array, default: []
|
||||||
field :category_id
|
field :category_id
|
||||||
def default_fields
|
def default_fields
|
||||||
tmp = super()
|
tmp = super()
|
||||||
return tmp if tmp.length>0
|
if tmp.empty?
|
||||||
self.class::DefaultEnabled
|
tmp = self.class::DefaultEnabled
|
||||||
|
end
|
||||||
|
return tmp
|
||||||
end
|
end
|
||||||
def custom_fields_list
|
def custom_fields_list
|
||||||
locale = I18n.locale
|
locale = I18n.locale
|
||||||
|
|
|
@ -26,6 +26,10 @@ class AskQuestion
|
||||||
field :custom_values, type: Hash,default: {}
|
field :custom_values, type: Hash,default: {}
|
||||||
field :agree_show,type: Boolean,default: false
|
field :agree_show,type: Boolean,default: false
|
||||||
field :agree_usage,type: Boolean,default: false
|
field :agree_usage,type: Boolean,default: false
|
||||||
|
|
||||||
|
field :review_time, type: DateTime
|
||||||
|
belongs_to :reviewer , :class_name=>"MemberProfile", :foreign_key => :reviewer_id
|
||||||
|
|
||||||
# validates_presence_of :name, :identity, :mail, :title, :content
|
# validates_presence_of :name, :identity, :mail, :title, :content
|
||||||
before_create do
|
before_create do
|
||||||
last_serial_number = AskSetting.update_last_serial_number
|
last_serial_number = AskSetting.update_last_serial_number
|
||||||
|
@ -34,8 +38,8 @@ class AskQuestion
|
||||||
def email
|
def email
|
||||||
mail = Email.find(self.email_id) rescue nil
|
mail = Email.find(self.email_id) rescue nil
|
||||||
end
|
end
|
||||||
def email_address
|
def reviewer_emails
|
||||||
email_address = AskAdmin.pluck(:email).select{|s| s.present?}.uniq 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 = Authorization.where(:module_app_id=>ModuleApp.where(:key=>'ask').first.id).to_a rescue []
|
||||||
authorizes.each do |a|
|
authorizes.each do |a|
|
||||||
if a.category_id
|
if a.category_id
|
||||||
|
@ -50,7 +54,6 @@ class AskQuestion
|
||||||
a.destroy
|
a.destroy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
email_address = email_address +[self.mail] if !self.mail.blank?
|
|
||||||
email_address = email_address.flatten
|
email_address = email_address.flatten
|
||||||
email_address.uniq
|
email_address.uniq
|
||||||
end
|
end
|
||||||
|
|
|
@ -192,7 +192,11 @@ class AskSetting
|
||||||
tmp_locales = I18n.available_locales.map{|l| l.to_s}
|
tmp_locales = I18n.available_locales.map{|l| l.to_s}
|
||||||
tmp_locales = [locale] + (tmp_locales - [locale])
|
tmp_locales = [locale] + (tmp_locales - [locale])
|
||||||
ask_setting.custom_fields.each do |k,v|
|
ask_setting.custom_fields.each do |k,v|
|
||||||
tmp_k = (k.start_with?('default@') ? k : "default@#{k}")
|
tmp_k = k
|
||||||
|
if !k.start_with?('default@')
|
||||||
|
prefix = is_cat_record ? "custom@#{cat.id}@" : 'default@'
|
||||||
|
tmp_k = "#{prefix}#{k}"
|
||||||
|
end
|
||||||
disp_fields_infos[tmp_k] = sort_number[tmp_k]
|
disp_fields_infos[tmp_k] = sort_number[tmp_k]
|
||||||
end
|
end
|
||||||
ask_category_settings = []
|
ask_category_settings = []
|
||||||
|
@ -202,15 +206,15 @@ class AskSetting
|
||||||
ask_category_settings = AskCategorySetting.enabled.to_a
|
ask_category_settings = AskCategorySetting.enabled.to_a
|
||||||
end
|
end
|
||||||
ask_category_settings.each do |c|
|
ask_category_settings.each do |c|
|
||||||
cat = Category.find(c.category_id) rescue nil
|
category = Category.find(c.category_id) rescue nil
|
||||||
if cat.nil?
|
if category.nil?
|
||||||
c.destroy
|
c.destroy
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
c.custom_fields.each do |k,v|
|
c.custom_fields.each do |k,v|
|
||||||
next if k.start_with?('default@')
|
next if k.start_with?('default@')
|
||||||
tmp_k = "custom@#{c.id}@#{k}"
|
tmp_k = "custom@#{c.id}@#{k}"
|
||||||
cat_title = cat.title rescue ""
|
cat_title = category.title rescue ""
|
||||||
disp_fields_infos[tmp_k] = sort_number[tmp_k]
|
disp_fields_infos[tmp_k] = sort_number[tmp_k]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -296,7 +300,11 @@ class AskSetting
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
next if trans.class != String
|
next if trans.class != String
|
||||||
tmp_k = (k.start_with?('default@') ? k : "default@#{k}")
|
tmp_k = k
|
||||||
|
if !k.start_with?('default@')
|
||||||
|
prefix = is_cat_record ? "custom@#{cat.id}@" : 'default@'
|
||||||
|
tmp_k = "#{prefix}#{k}"
|
||||||
|
end
|
||||||
disp_fields_infos[tmp_k] = {"trans"=>trans,"sort_number"=>sort_number[tmp_k],"key"=>k,"type"=>v["type"],"options"=>v["options"],"instructions"=>v["instructions"]}
|
disp_fields_infos[tmp_k] = {"trans"=>trans,"sort_number"=>sort_number[tmp_k],"key"=>k,"type"=>v["type"],"options"=>v["options"],"instructions"=>v["instructions"]}
|
||||||
end
|
end
|
||||||
ask_category_settings = []
|
ask_category_settings = []
|
||||||
|
@ -306,8 +314,8 @@ class AskSetting
|
||||||
ask_category_settings = AskCategorySetting.enabled.to_a
|
ask_category_settings = AskCategorySetting.enabled.to_a
|
||||||
end
|
end
|
||||||
ask_category_settings.each do |c|
|
ask_category_settings.each do |c|
|
||||||
cat = Category.find(c.category_id) rescue nil
|
category = Category.find(c.category_id) rescue nil
|
||||||
if cat.nil?
|
if category.nil?
|
||||||
c.destroy
|
c.destroy
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
@ -322,7 +330,7 @@ class AskSetting
|
||||||
next if trans.class != String
|
next if trans.class != String
|
||||||
next if k.start_with?('default@')
|
next if k.start_with?('default@')
|
||||||
tmp_k = "custom@#{c.id}@#{k}"
|
tmp_k = "custom@#{c.id}@#{k}"
|
||||||
cat_title = cat.title rescue ""
|
cat_title = category.title rescue ""
|
||||||
disp_fields_infos[tmp_k] = {"trans"=>"#{cat_title}-#{trans}","sort_number"=>sort_number[tmp_k],"key"=>k,"type"=>v["type"],"options"=>v["options"],"instructions"=>v["instructions"]}
|
disp_fields_infos[tmp_k] = {"trans"=>"#{cat_title}-#{trans}","sort_number"=>sort_number[tmp_k],"key"=>k,"type"=>v["type"],"options"=>v["options"],"instructions"=>v["instructions"]}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -349,10 +357,10 @@ class AskSetting
|
||||||
end
|
end
|
||||||
def get_email_regex(frontend=false)
|
def get_email_regex(frontend=false)
|
||||||
tmp = self.email_regex
|
tmp = self.email_regex
|
||||||
if tmp
|
if tmp && frontend
|
||||||
tmp = tmp.gsub("\\A","^").gsub("\\z","$").gsub("\\","\\\\\\\\")
|
tmp = tmp.gsub("\\A","^").gsub("\\z","$").gsub("\\","\\\\\\\\")
|
||||||
end
|
end
|
||||||
tmp = nil if !(self.email_regex_enable) || (self.application_form_signup_field_sets.where(:field_name=>'email').pluck(:disabled)[0] rescue false)
|
tmp = nil if !(self.email_regex_enable) || ((self.default_setting[:mail] == false) rescue false)
|
||||||
tmp
|
tmp
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
<h2><%= @ask_admin.new_record? ? t(:add) : t(:edit) %></h2>
|
||||||
|
|
||||||
|
<div id="widget-title">
|
||||||
|
<div class="control-group">
|
||||||
|
<%= f.label :email, class: 'control-label' %>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :email, class: 'input-xxlarge', data: {"fv-validation" => "required;check_email;", "fv-messages" => "必填欄位;Email不正確;"} %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<%= f.label :category, class: 'control-label' %>
|
||||||
|
<div class="controls">
|
||||||
|
<label>
|
||||||
|
<%= check_box f.object_name,"category_ids", {checked: f.object.category_ids.empty?, multiple: true}, "", nil %>
|
||||||
|
<%= t(:all) %>
|
||||||
|
</label>
|
||||||
|
<% @module_app.categories.each do |category| %>
|
||||||
|
<label>
|
||||||
|
<%= check_box f.object_name,"category_ids", {checked: f.object.category_ids.include?(category.id), multiple: true}, category.id, nil %>
|
||||||
|
<%= category.title %>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-actions">
|
||||||
|
<%= f.submit t(:submit), class: 'btn btn-primary' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
$(function(){
|
||||||
|
var fv = new FormValidator($("#ask_admin_email"));
|
||||||
|
fv.validate_functions.check_email = function(value){
|
||||||
|
reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
|
||||||
|
if (reg.test(value)) {
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
|
@ -27,20 +27,6 @@
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<%= form_for @ask_admin, url: @url, html: { class: 'form-horizontal' } do |f| %>
|
<%= form_for @ask_admin, url: @url, html: { class: 'form-horizontal' } do |f| %>
|
||||||
|
<%= render :partial => 'ask_admin_form', locals: {f: f} %>
|
||||||
<h2><%= @ask_admin.new_record? ? t(:add) : t(:edit) %></h2>
|
|
||||||
|
|
||||||
<div id="widget-title">
|
|
||||||
<div class="control-group">
|
|
||||||
<%= f.label :email, class: 'control-label' %>
|
|
||||||
<div class="controls">
|
|
||||||
<%= f.text_field :email, class: 'input-xxlarge' %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-actions">
|
|
||||||
<%= f.submit t(:submit), class: 'btn btn-primary' %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -29,34 +29,5 @@
|
||||||
<%= javascript_include_tag 'validator' %>
|
<%= javascript_include_tag 'validator' %>
|
||||||
<%= form_for @ask_admin, url: admin_ask_admins_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
<%= form_for @ask_admin, url: admin_ask_admins_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||||
|
|
||||||
<h2><%= @ask_admin.new_record? ? t(:add) : t(:edit) %></h2>
|
<%= render :partial => 'ask_admin_form', locals: {f: f} %>
|
||||||
|
<% end %>
|
||||||
<div id="widget-title">
|
|
||||||
<div class="control-group">
|
|
||||||
<%= f.label :email, class: 'control-label' %>
|
|
||||||
<div class="controls">
|
|
||||||
<%= f.text_field :email, class: 'input-xxlarge', data: {"fv-validation" => "required;check_email;", "fv-messages" => "必填欄位;Email不正確;"} %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-actions">
|
|
||||||
<%= f.submit t(:submit), class: 'btn btn-primary' %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<script type='text/javascript'>
|
|
||||||
$(function(){
|
|
||||||
var fv = new FormValidator($("#new_ask_admin"));
|
|
||||||
fv.validate_functions.check_email = function(value){
|
|
||||||
reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
|
|
||||||
if (reg.test(value)) {
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
|
@ -226,6 +226,10 @@
|
||||||
<%= b.created_at.strftime("%Y-%m-%d %H:%M") rescue nil %>
|
<%= b.created_at.strftime("%Y-%m-%d %H:%M") rescue nil %>
|
||||||
<% when 'ip' %>
|
<% when 'ip' %>
|
||||||
<%= b.ip %>
|
<%= b.ip %>
|
||||||
|
<% when 'reviewer' %>
|
||||||
|
<%= b.reviewer.name rescue "" %>
|
||||||
|
<% when 'review_time' %>
|
||||||
|
<%= b.review_time.strftime("%Y-%m-%d %H:%M") rescue nil %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if edit_box_display_index == i %>
|
<% if edit_box_display_index == i %>
|
||||||
<%= render partial: 'edit_box_for_index', :locals => {is_editable: is_editable, b: b} %>
|
<%= render partial: 'edit_box_for_index', :locals => {is_editable: is_editable, b: b} %>
|
||||||
|
@ -256,4 +260,4 @@
|
||||||
$(this)[0].form.submit();
|
$(this)[0].form.submit();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- <h1><%= @data['title'] %></h1> -->
|
<!-- <h1><%= @data['title'] %></h1> -->
|
||||||
|
<% if @data['edit_url'] %>
|
||||||
|
<%= link_to t("edit"), @data['edit_url'] %>
|
||||||
|
<% end %>
|
||||||
<table>
|
<table>
|
||||||
<% question = AskQuestion.find(@data['ask_question_id']) rescue nil %>
|
<% question = AskQuestion.find(@data['ask_question_id']) rescue nil %>
|
||||||
<% if question %>
|
<% if question %>
|
||||||
|
|
|
@ -146,21 +146,6 @@
|
||||||
// return false;
|
// return false;
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
$(function(){
|
|
||||||
var fv = new FormValidator($("#new_ask_question"));
|
|
||||||
fv.validate_functions.check_email = function(value){
|
|
||||||
reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
|
|
||||||
if (reg.test(value)) {
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// fv.validate_functions.test_function = function(value, element){
|
|
||||||
|
|
||||||
// }
|
|
||||||
})
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
function scrollIntoView(selector, offset = 0) {
|
function scrollIntoView(selector, offset = 0) {
|
||||||
window.scroll(0, document.querySelector(selector).offsetTop - offset);
|
window.scroll(0, document.querySelector(selector).offsetTop - offset);
|
||||||
|
@ -168,6 +153,14 @@ $(document).ready(function(){
|
||||||
var email_regex = "<%=email_regex%>";
|
var email_regex = "<%=email_regex%>";
|
||||||
if(email_regex.length != 0){
|
if(email_regex.length != 0){
|
||||||
email_regex = new RegExp(email_regex);
|
email_regex = new RegExp(email_regex);
|
||||||
|
var fv = new FormValidator($("#new_ask_question"));
|
||||||
|
fv.validate_functions.check_email = function(value){
|
||||||
|
if (email_regex.test(value)) {
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
var submit_flag = false;
|
var submit_flag = false;
|
||||||
$(".ask-question-form").each(function(i, form){
|
$(".ask-question-form").each(function(i, form){
|
||||||
var $form = $(form);
|
var $form = $(form);
|
||||||
|
|
|
@ -147,4 +147,6 @@ en:
|
||||||
status: Status
|
status: Status
|
||||||
send_email: Whether to reply email
|
send_email: Whether to reply email
|
||||||
agree_show: Do you agree on displaying your request and our reply on the webpage without your personal information?
|
agree_show: Do you agree on displaying your request and our reply on the webpage without your personal information?
|
||||||
agree_show_explain: Whether to agree on displaying your request and our reply on the webpage without your personal information?
|
agree_show_explain: Whether to agree on displaying your request and our reply on the webpage without your personal information?
|
||||||
|
reviewer: Reviewer
|
||||||
|
review_time: Review Time
|
|
@ -157,4 +157,6 @@ zh_tw:
|
||||||
status: 狀態
|
status: 狀態
|
||||||
send_email: 是否回信
|
send_email: 是否回信
|
||||||
agree_show: 是否同意您提出之需求及回覆內容以不呈現發問者資訊方式刊載於網站供他人參考?
|
agree_show: 是否同意您提出之需求及回覆內容以不呈現發問者資訊方式刊載於網站供他人參考?
|
||||||
agree_show_explain: 是否同意刊載於網站給他人參考
|
agree_show_explain: 是否同意刊載於網站給他人參考
|
||||||
|
reviewer: 審核者
|
||||||
|
review_time: 審核時間
|
|
@ -41,6 +41,28 @@ module Ask
|
||||||
if ask_setting.email_regex_enable
|
if ask_setting.email_regex_enable
|
||||||
AskCategorySetting.all.update_all(email_regex_enable: ask_setting.email_regex_enable,email_regex: ask_setting.email_regex)
|
AskCategorySetting.all.update_all(email_regex_enable: ask_setting.email_regex_enable,email_regex: ask_setting.email_regex)
|
||||||
end
|
end
|
||||||
|
AskCategorySetting.all.each do |ask_category_setting|
|
||||||
|
sort_number = ask_category_setting.sort_number
|
||||||
|
have_custom_key = false
|
||||||
|
sort_number.keys.each do |sort_number_key|
|
||||||
|
have_default_key ||= sort_number_key.include?("default@default@")
|
||||||
|
have_custom_key ||= sort_number_key.include?("custom@")
|
||||||
|
end
|
||||||
|
if !have_custom_key
|
||||||
|
new_sort_number = {}
|
||||||
|
sort_number.keys.each do |sort_number_key|
|
||||||
|
new_sort_number_key = sort_number_key
|
||||||
|
if sort_number_key.include?("default@default@")
|
||||||
|
new_sort_number_key = sort_number_key.sub(/default@/, '')
|
||||||
|
else
|
||||||
|
new_sort_number_key = sort_number_key.sub(/default@/, "custom@#{ask_category_setting.id}@")
|
||||||
|
end
|
||||||
|
new_sort_number[new_sort_number_key] = sort_number[sort_number_key]
|
||||||
|
end
|
||||||
|
ask_category_setting.sort_number = new_sort_number
|
||||||
|
ask_category_setting.save
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if defined?(AskListSetting)
|
if defined?(AskListSetting)
|
||||||
ask_list_setting = AskListSetting.first
|
ask_list_setting = AskListSetting.first
|
||||||
|
@ -64,6 +86,31 @@ module Ask
|
||||||
rescue => e
|
rescue => e
|
||||||
puts ['AskSetting not found',e]
|
puts ['AskSetting not found',e]
|
||||||
end
|
end
|
||||||
|
require File.expand_path('../../../app/models/ask_question', __FILE__)
|
||||||
|
require File.expand_path('app/models/user_action', Rails.root)
|
||||||
|
def fix_reviewer
|
||||||
|
ask_question_no_reviewer_len = AskQuestion.where(:id.in => UserAction.where(controller: 'admin/asks', action: 'update').pluck(:request_path).map{|v| v.split('/')[-1]}, :reviewer_id => nil).count
|
||||||
|
if ask_question_no_reviewer_len==0
|
||||||
|
return
|
||||||
|
end
|
||||||
|
UserAction.where(controller: 'admin/asks', action: 'update').each do |user_action|
|
||||||
|
user = user_action.user
|
||||||
|
askquestion_id = user_action.request_path.split('/')[-1]
|
||||||
|
askquestion = AskQuestion.where(id: askquestion_id).first
|
||||||
|
if askquestion && user.member_profile_id
|
||||||
|
askquestion.update_attributes(reviewer_id: user.member_profile_id, review_time: user_action.created_at)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if defined?(AskListSetting)
|
||||||
|
AskListSetting.each do |ask_list_setting|
|
||||||
|
if ask_list_setting.default_fields.length != AskListSetting::DefaultEnabled.length
|
||||||
|
ask_list_setting.default_fields += ['reviewer', 'review_time']
|
||||||
|
ask_list_setting.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
fix_reviewer
|
||||||
OrbitApp.registration "Ask", :type => "ModuleApp" do
|
OrbitApp.registration "Ask", :type => "ModuleApp" do
|
||||||
module_label "ask.ask"
|
module_label "ask.ask"
|
||||||
base_url File.expand_path File.dirname(__FILE__)
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
|
|
Loading…
Reference in New Issue