From 7224a5bb54615b49b5367879cd252c017550da1f Mon Sep 17 00:00:00 2001 From: Bohung Date: Tue, 14 Jun 2022 16:13:28 +0800 Subject: [PATCH] Fix bug. --- app/controllers/admin/seminars_controller.rb | 35 ++------------------ app/models/seminar_signup.rb | 2 +- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index cddce7f..f2f0dcf 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -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) diff --git a/app/models/seminar_signup.rb b/app/models/seminar_signup.rb index ca62fa7..a7586c4 100644 --- a/app/models/seminar_signup.rb +++ b/app/models/seminar_signup.rb @@ -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