Fix bug.
This commit is contained in:
parent
b10a11075b
commit
ee69221b8f
|
@ -198,6 +198,11 @@ class AsksController < ApplicationController
|
|||
temp_params = create_params
|
||||
all_to_save = []
|
||||
ask_setting = AskCategorySetting.enabled.where(category_id: params['ask_question']['category_id']).first
|
||||
override_sort_number = nil
|
||||
if ask_setting.use_default
|
||||
override_sort_number = ask_setting.default_sort_number
|
||||
ask_setting = nil
|
||||
end
|
||||
if ask_setting.nil?
|
||||
ask_setting = AskSetting.first
|
||||
ask_setting = AskSetting.create() if ask_setting.nil?
|
||||
|
@ -264,7 +269,7 @@ class AsksController < ApplicationController
|
|||
end
|
||||
end
|
||||
if (email_regex ? ::Regexp.new(email_regex).match(temp_params["mail"].to_s) : true) && flag
|
||||
@disp_fields_infos = AskSetting.get_disp_fields_infos(true, ask_setting, true, nil, true)
|
||||
@disp_fields_infos = AskSetting.get_disp_fields_infos(true, ask_setting, true, override_sort_number, true)
|
||||
@usage_rule = ask_setting.usage_rule
|
||||
if temp_params['mail'].blank?
|
||||
temp_params = temp_params.merge({
|
||||
|
|
|
@ -165,4 +165,5 @@ class AskCategorySetting
|
|||
field :reject_customs, type: Array, default: [] #From AskSetting
|
||||
field :agree_customs, type: Array, default: [] #From AskSetting
|
||||
scope :enabled, ->{any_of([{:use_default.ne=>true}, {:use_default=>true, :default_sort_number.nin=>[nil, {}]}])}
|
||||
end
|
||||
scope :custom_enabled, ->{where({:use_default.ne=>true})}
|
||||
end
|
||||
|
|
|
@ -146,7 +146,8 @@ class AskSetting
|
|||
ask_setting = nil
|
||||
if cat_is_record
|
||||
ask_setting = cat
|
||||
is_cat_record = !(override_sort_number.nil?) || cat.class == AskCategorySetting
|
||||
is_cat_record = (cat.class == AskCategorySetting)
|
||||
is_cat_record2 = is_cat_record || !(override_sort_number.nil?)
|
||||
else
|
||||
if cat.present?
|
||||
ask_setting = AskCategorySetting.enabled.where(:category_id=>cat).first
|
||||
|
@ -203,10 +204,10 @@ class AskSetting
|
|||
disp_fields_infos[tmp_k] = sort_number[tmp_k]
|
||||
end
|
||||
ask_category_settings = []
|
||||
if is_cat_record
|
||||
if is_cat_record2
|
||||
ask_category_settings = []
|
||||
else
|
||||
ask_category_settings = AskCategorySetting.enabled.to_a
|
||||
ask_category_settings = AskCategorySetting.custom_enabled.to_a
|
||||
end
|
||||
ask_category_settings.each do |c|
|
||||
category = Category.find(c.category_id) rescue nil
|
||||
|
@ -246,7 +247,8 @@ class AskSetting
|
|||
ask_setting = nil
|
||||
if cat_is_record
|
||||
ask_setting = cat
|
||||
is_cat_record = !(override_sort_number.nil?) || cat.class == AskCategorySetting
|
||||
is_cat_record = (cat.class == AskCategorySetting)
|
||||
is_cat_record2 = is_cat_record || !(override_sort_number.nil?)
|
||||
else
|
||||
if cat.present?
|
||||
ask_setting = AskCategorySetting.enabled.where(:category_id=>cat).first
|
||||
|
@ -311,10 +313,10 @@ class AskSetting
|
|||
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
|
||||
ask_category_settings = []
|
||||
if is_cat_record
|
||||
if is_cat_record2
|
||||
ask_category_settings = []
|
||||
else
|
||||
ask_category_settings = AskCategorySetting.enabled.to_a
|
||||
ask_category_settings = AskCategorySetting.custom_enabled.to_a
|
||||
end
|
||||
ask_category_settings.each do |c|
|
||||
category = Category.find(c.category_id) rescue nil
|
||||
|
|
Loading…
Reference in New Issue