From 1e52c3bf912e4dfd181158b9db64d319a3529bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Wed, 28 Feb 2024 14:15:01 +0800 Subject: [PATCH] Fix bug. --- app/controllers/seminars_controller.rb | 48 +++++++++++++++----------- app/views/seminars/con_login.html.erb | 2 +- app/views/seminars/con_upload.html.erb | 8 ++--- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 50bae30..6db4690 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -345,7 +345,7 @@ class SeminarsController < ApplicationController sign_up = link_to(sign_up_text, seminar.get_frontend_url(seminar_url), :target=>'_blank', :title=>sign_up_text) end - if !seminar.registration_status.blank? && seminar.registration_status.include?('C') && seminar.contribute_start_date <= time_now && ( seminar.contribute_end_date.nil? || seminar.contribute_end_date+1 >= time_now ) + if !seminar.registration_status.blank? && seminar.registration_status.include?('C') && (seminar.contribute_start_date.nil? || seminar.contribute_start_date <= time_now) && ( seminar.contribute_end_date.nil? || seminar.contribute_end_date+1 >= time_now ) if @@session[:seminar_signup_id].present? && @@session[:seminar_main_id] == seminar.id button_text = t('seminar_signup.uploads') contribute_action = link_to(button_text, seminar.get_frontend_url(seminar_url, :con_upload), :title=>button_text) @@ -522,20 +522,24 @@ class SeminarsController < ApplicationController def add_file_proc - update_params = seminar_signup_contribute_params.merge('seminar_submission_values'=>params['seminar_submission_values']) + update_params = seminar_signup_contribute_params.merge('seminar_submission_values'=>params['seminar_submission_values'].to_h) flag = true update_params.permit! - if !update_params['seminar_submission_values'].nil? - if update_params['seminar_submission_values']['0']['value'].class==String - value = update_params['seminar_submission_values']['0']['value'] - if !value.to_s.blank? - flag = false - end + if update_params['seminar_submission_values'].present? + if update_params['seminar_submission_values']['0']['value'].nil? + flag = false else - update_params['seminar_submission_values']['0']['value'].each do |key,value| - if !value.to_s.blank? + if update_params['seminar_submission_values']['0']['value'].class==String + value = update_params['seminar_submission_values']['0']['value'] + if !value.to_s.blank? flag = false end + else + update_params['seminar_submission_values']['0']['value'].each do |key,value| + if !value.to_s.blank? + flag = false + end + end end end else @@ -574,20 +578,24 @@ class SeminarsController < ApplicationController def update @con = SeminarSignupContribute.find(params[:seminar_signup_contribute][:id]) - update_params = seminar_signup_contribute_params.merge('seminar_submission_values'=>params['seminar_submission_values']) + update_params = seminar_signup_contribute_params.merge('seminar_submission_values'=>params['seminar_submission_values'].to_h) update_params.permit! - unless update_params['seminar_submission_values'].nil? - flag = true - if update_params['seminar_submission_values']['0']['value'].class==String - value = update_params['seminar_submission_values']['0']['value'] - if !value.to_s.blank? - flag = false - end + if update_params['seminar_submission_values'].present? + if update_params['seminar_submission_values']['0']['value'].nil? + flag = false else - update_params['seminar_submission_values']['0']['value'].each do |key,value| - if !value.to_s.blank? + flag = true + if update_params['seminar_submission_values']['0']['value'].class==String + value = update_params['seminar_submission_values']['0']['value'] + if !value.to_s.blank? flag = false end + else + update_params['seminar_submission_values']['0']['value'].each do |key,value| + if !value.to_s.blank? + flag = false + end + end end end if flag diff --git a/app/views/seminars/con_login.html.erb b/app/views/seminars/con_login.html.erb index 7125135..f179018 100644 --- a/app/views/seminars/con_login.html.erb +++ b/app/views/seminars/con_login.html.erb @@ -9,7 +9,7 @@ color: red; } -<% if (@seminar.contribute_start_date <= @time_now && (@seminar.contribute_end_date.nil? or @seminar.contribute_end_date+1 >= @time_now ) rescue false) %> +<% if (@seminar.contribute_start_date.nil? || @seminar.contribute_start_date <= @time_now) && (@seminar.contribute_end_date.nil? or @seminar.contribute_end_date+1 >= @time_now ) %>