This commit is contained in:
BoHung Chiu 2022-06-14 16:13:28 +08:00
parent 2cd08c4731
commit 7224a5bb54
2 changed files with 4 additions and 33 deletions

View File

@ -503,22 +503,6 @@ class Admin::SeminarsController < OrbitAdminController
def edit
@seminar_items = SeminarItem.all
@seminar = SeminarMain.where(id: params[:id]).first
except_attributes = SeminarSignup::HiddenFields
@seminar.seminar_signup_field_sets.each do |signup_field_set|
if (!(SeminarSignup.attribute_names.include? signup_field_set.field_name) && signup_field_set.field_name != 'recaptcha') || except_attributes.include?(signup_field_set.field_name)
signup_field_set.delete
end
end
@seminar.seminar_submission_field_sets.each do |submission_field_set|
if (!(SeminarSignupContribute.attribute_names.include? submission_field_set.field_name)) || except_attributes.include?(submission_field_set.field_name)
submission_field_set.delete
end
end
@seminar.seminar_signup_field_customs.each do |custom_set|
if !(@seminar.seminar_signup_fields.collect(&:id).include? custom_set.seminar_signup_field_id)
custom_set.delete
end
end
create_set (true)
@signup_sets = @seminar.seminar_signup_field_sets
@submission_set = @seminar.seminar_submission_field_sets
@ -754,7 +738,9 @@ class Admin::SeminarsController < OrbitAdminController
end
def create_set (save_flag)
except_attributes = SeminarSignup::HiddenFields
@seminar.seminar_signup_field_sets.where(:field_name.in=>except_attributes).destroy
if @seminar.seminar_signup_field_sets.where(:field_name.in=>except_attributes).destroy != 0
@seminar = @seminar.reload
end
SeminarSignup.attribute_names.each do |attr_signup|
next if except_attributes.include?(attr_signup)
signup_set = @seminar.seminar_signup_field_sets.select{|v| v.field_name==attr_signup }
@ -783,21 +769,6 @@ class Admin::SeminarsController < OrbitAdminController
end
end
end
signup_set = @seminar.seminar_signup_field_sets.select{|v| v.field_name== 'recaptcha' }
if signup_set.length==0
name1 = Hash.new
now_locale = I18n.locale
I18n.available_locales.each do |locale|
I18n.locale = locale
name1[locale] = t("seminar_signup.recaptcha")
end
I18n.locale = now_locale
if save_flag
@seminar.seminar_signup_field_sets.create(field_name:'recaptcha',name:name1,placeholder:name1,hidden:true)
else
@seminar.seminar_signup_field_sets.new(field_name:'recaptcha',name:name1,placeholder:name1,hidden:true)
end
end
@seminar.seminar_submission_field_sets.where(:field_name.in=>except_attributes).destroy
SeminarSignupContribute.attribute_names.each do |attr_submission|
next if except_attributes.include?(attr_submission)

View File

@ -4,7 +4,7 @@ class SeminarSignup
include Mongoid::Document
include Mongoid::Timestamps
HiddenFields = ['seminar_signup_id','_id', 'created_at', 'updated_at','seminar_main_id',"serial_number","final_session","final_sessions","preferred_sessions",'seminar_session_id',"seminar_session_ids","preferred_session","sort_number","abstract_number","presentation_type"]
DefaultEnableFields = ['status','name','tel','phone','email','password']
DefaultEnableFields = ['status','name','tel','phone','email','password','recaptcha']
field :sort_number , type: Integer, default: 10000
field :status