修復寄信問題

This commit is contained in:
邱博亞 2023-06-05 22:55:26 +08:00
parent cbb211401b
commit d1266dcfa1
1 changed files with 24 additions and 3 deletions

View File

@ -15,6 +15,10 @@
yes_trans = t('ask.yes') yes_trans = t('ask.yes')
no_trans = t('ask.no') no_trans = t('ask.no')
locale = I18n.locale.to_s locale = I18n.locale.to_s
ask_setting = AskCategorySetting.enabled.where(category_id: question.category_id.to_s).first
ask_setting = AskSetting.first if ask_setting.nil?
is_cat_record = (ask_setting.class == AskCategorySetting)
tmp_ask_cat_id = (is_cat_record ? ask_setting.id.to_s : '')
%> %>
<% @data['disp_fields_infos'].each do |f, field_info| %> <% @data['disp_fields_infos'].each do |f, field_info| %>
<% next if f == 'recaptcha' %> <% next if f == 'recaptcha' %>
@ -24,8 +28,25 @@
is_cat = false is_cat = false
is_custom = false is_custom = false
if f.include?("@") if f.include?("@")
f = field_info["key"] field = f
is_custom = true is_custom = true
is_field_enable = false
if field.start_with?("default@")
f = is_cat_record ? field : field[8..-1]
v = ask_setting.custom_fields[f]
if v
is_field_enable = true
end
elsif field.start_with?("custom@") && is_cat_record
if field.include?(tmp_ask_cat_id)
f = field[8+tmp_ask_cat_id.length..-1]
v = ask_setting.custom_fields[f]
if v
is_field_enable = true
end
end
end
next if !is_field_enable
elsif f == 'ask_category_id' elsif f == 'ask_category_id'
f = 'category_id' f = 'category_id'
is_cat = true is_cat = true
@ -50,9 +71,9 @@
elsif type == "date" elsif type == "date"
val = val["datetime"].values[0].values rescue [] val = val["datetime"].values[0].values rescue []
if val.count == 2 if val.count == 2
val = val[0].gsub('-', '/') + " ~ " + val[1].gsub('-', '/') val = val[0].to_s.gsub('-', '/') + " ~ " + val[1].to_s.gsub('-', '/')
else else
val = val[0].gsub('-', '/') val = val[0].to_s.gsub('-', '/')
end end
elsif type == "instructions" elsif type == "instructions"
val = field_info["instructions"][locale].to_s.html_safe rescue "" val = field_info["instructions"][locale].to_s.html_safe rescue ""