From 4dbd540335092286ed179d614d73320c04de8944 Mon Sep 17 00:00:00 2001 From: Bomrah Harry Date: Thu, 12 Oct 2023 21:12:15 +0800 Subject: [PATCH] added confirm counter, re signup msg, added token --- app/controllers/seminars_controller.rb | 8 +++++--- app/models/seminar_signup.rb | 1 + .../admin/seminars/_seminar_signup_render_table.html.erb | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 96c3486..8e7659f 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -392,7 +392,7 @@ class SeminarsController < ApplicationController } end - + { "seminar" => seminar, "seminar_signup" => seminar_signup, @@ -545,6 +545,7 @@ class SeminarsController < ApplicationController tmp_seminar_signup_params = seminar_signup_params @seminar_signup = SeminarSignup.find(params[:signup_id]) @seminar_signup.update_attributes(tmp_seminar_signup_params) + @seminar_signup.generate_token if !params[:seminar_signup_values].nil? params[:seminar_signup_values].each_with_index do |r,i| field_value = r.last[:id].present? @@ -574,7 +575,7 @@ class SeminarsController < ApplicationController end send_mail('signup',tmp_seminar_signup_params[:email],tmp_seminar_signup_params[:seminar_main_id],extra_text) end - redirect_with_js("#{params[:referer_url].to_s.chomp('/').gsub(/\/([^\/?#]+)(|[^\/]+)$/){|f| '/'+$1}}?method=con_upload") + redirect_with_js("#{params[:referer_url].to_s.chomp('/').gsub(/\/([^\/?#]+)(|[^\/]+)$/){|f| '/'+$1}}?method=signup_ok#{status_param}&serial_number=#{@seminar_signup.display_serial_number}&seminar=#{@seminar.uid}") end def signup_ok @@ -863,11 +864,12 @@ class SeminarsController < ApplicationController end seminar = SeminarMain.where(:uid => uid).first if(!seminar.nil?) - signup = seminar.seminar_signups.where(:id => params[:cid], :token => params[:token], :is_confirmed => false).first + signup = seminar.seminar_signups.where(:id => params[:cid], :token => params[:token]).first if(!signup.nil?) signup.token = nil signup.is_confirmed = true signup.is_confirmed_date = DateTime.now + signup.signup_confirmed_counter = signup.signup_confirmed_counter + 1 signup.save confirm = true end diff --git a/app/models/seminar_signup.rb b/app/models/seminar_signup.rb index 7ff726c..d955b2f 100644 --- a/app/models/seminar_signup.rb +++ b/app/models/seminar_signup.rb @@ -13,6 +13,7 @@ class SeminarSignup field :signup_confirmed, type: Boolean, default: false field :is_confirmed_date, type: DateTime field :signup_confirmed_date, type: DateTime + field :signup_confirmed_counter, type: Integer, default: 0 field :emails_sent, type: Array, default: [] field :emails_sent_time, type: Array, default: [] field :name # become Last Name for TICC diff --git a/app/views/admin/seminars/_seminar_signup_render_table.html.erb b/app/views/admin/seminars/_seminar_signup_render_table.html.erb index ecc3dab..bcdf2f1 100644 --- a/app/views/admin/seminars/_seminar_signup_render_table.html.erb +++ b/app/views/admin/seminars/_seminar_signup_render_table.html.erb @@ -66,7 +66,7 @@ <% val = t("seminar.registration_status_#{seminar_signup.status}") if !seminar_signup.status.blank? %> <% elsif names[1] == 'is_confirmed' %> <% if seminar_signup.is_confirmed - val = "#{t("seminar_signup.email_confirmed")}" + val = "#{t("seminar_signup.email_confirmed")}(#{seminar_signup.signup_confirmed_counter.to_s})" else val = "#{t("seminar_signup.email_not_confirmed")}" end