From c756faf89fd40872d27afb6acfafa2b82fbc913b Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Wed, 11 Jan 2023 17:44:40 +0800 Subject: [PATCH] Fix bug. --- .../seminar-field-forms-submission.js | 9 +- app/assets/javascripts/seminar-field-forms.js | 12 +- app/controllers/admin/seminars_controller.rb | 23 +- app/controllers/seminars_controller.rb | 218 +++++++++--------- app/models/seminar_main.rb | 36 ++- app/models/seminar_signup_field.rb | 36 +-- app/models/seminar_submission_field.rb | 35 +-- .../admin/seminars/_attribute_field.html.erb | 46 ++-- .../_attribute_submission_field.html.erb | 46 ++-- .../seminars/_get_display_fields.html.erb | 18 +- .../seminars/_support_member_form_js.erb | 2 +- app/views/seminars/index.html.erb | 45 ++-- app/views/seminars/show.html.erb | 31 +-- config/locales/en.yml | 2 + config/locales/zh_tw.yml | 2 + 15 files changed, 289 insertions(+), 272 deletions(-) diff --git a/app/assets/javascripts/seminar-field-forms-submission.js b/app/assets/javascripts/seminar-field-forms-submission.js index c64b9fc..8259abf 100644 --- a/app/assets/javascripts/seminar-field-forms-submission.js +++ b/app/assets/javascripts/seminar-field-forms-submission.js @@ -96,7 +96,7 @@ function inputAppendLength() { // Role Attribute Template Data function setData(l, type, ol) { - var fields = $('#info').length ? "info[seminar_submission_fields]" : $('#sub_seminar_main').length ? "sub_seminar_main[seminar_submission_fields]" : "seminar_main[seminar_submission_fields]", + var fields = $('#sub_seminar_main').length ? "sub_seminar_main[seminar_submission_fields_attributes]" : "seminar_main[seminar_submission_fields_attributes]", data = { _add_more: ["add_more_" +l, fields+"["+l+"]["+type+"][add_more]"], _calendar: ["calendar_" +l, fields+"["+l+"]["+type+"][calendar]"], @@ -110,7 +110,7 @@ function setData(l, type, ol) { _option_list: ["option_list_"+l+"_"+ol, fields+"["+l+"]["+type+"][option_list]["+ol+"]", "option_list_"+ol], _placeholder: ["placeholder_" +l, fields+"["+l+"]["+type+"][placeholder]"], _title_translations: ["title_translations_" +l, fields+"["+l+"][title_translations]"], - _to_delete: ["to_delete_" +l, fields+"["+l+"][to_delete]"], + _destroy: ["destroy_" +l, fields+"["+l+"][_destroy]"], _to_require: ["to_require_" +l, fields+"["+l+"][to_require]"], }; return data; @@ -270,6 +270,7 @@ $(function() { attributesArray = []; attributesHeaderLength = null; templateType = null; + var default_templateType = 'typeA'; attributeIndex = null; if($('.add-target').length) { inputAppendLength(); @@ -286,7 +287,7 @@ $(function() { }; attributesHeaderLength = $('.attributes:not(:hidden)').length+1; attributesLength = $('#attributes-area .attributes').length; - $("#template-attributes").tmpl(setData(attributesLength, templateType, appendIndex)).appendTo( "#attributes-area" ); + $("#template-attributes").tmpl(setData(attributesLength, default_templateType, appendIndex)).appendTo( "#attributes-area" ); $('.toggle-check').togglebox(); }); @@ -426,7 +427,7 @@ $(function() { if(!$('.attributes:not(:hidden)').length) { $('#attributes-area').addClass('clickHere'); }; - }).find('.attribute_field_to_delete').attr('value', 'true');; + }).find('.attribute_field_destroy').attr('value', 'true');; }; if($(this).hasClass('trigger')) { // appendIndex = $(this).closest('.controls').find('.input-append').length; diff --git a/app/assets/javascripts/seminar-field-forms.js b/app/assets/javascripts/seminar-field-forms.js index 455fad3..8118423 100644 --- a/app/assets/javascripts/seminar-field-forms.js +++ b/app/assets/javascripts/seminar-field-forms.js @@ -96,7 +96,7 @@ function inputAppendLength() { // Role Attribute Template Data function setData(l, type, ol) { - var fields = $('#info').length ? "info[seminar_signup_fields]" : $('#sub_seminar_main').length ? "sub_seminar_main[seminar_signup_fields]" : "seminar_main[seminar_signup_fields]", + var fields = $('#sub_seminar_main').length ? "sub_seminar_main[seminar_signup_fields_attributes]" : "seminar_main[seminar_signup_fields_attributes]", data = { _add_more: ["add_more_" +l, fields+"["+l+"]["+type+"][add_more]"], _calendar: ["calendar_" +l, fields+"["+l+"]["+type+"][calendar]"], @@ -110,7 +110,7 @@ function setData(l, type, ol) { _option_list: ["option_list_"+l+"_"+ol, fields+"["+l+"]["+type+"][option_list]["+ol+"]", "option_list_"+ol], _placeholder: ["placeholder_" +l, fields+"["+l+"]["+type+"][placeholder]"], _title_translations: ["title_translations_" +l, fields+"["+l+"][title_translations]"], - _to_delete: ["to_delete_" +l, fields+"["+l+"][to_delete]"], + _destroy: ["destroy_" +l, fields+"["+l+"][_destroy]"], _to_require: ["to_require_" +l, fields+"["+l+"][to_require]"], }; return data; @@ -270,6 +270,7 @@ $(function() { attributesArray = []; attributesHeaderLength = null; templateType = null; + var default_templateType = 'typeA'; attributeIndex = null; if($('.add-target').length) { inputAppendLength(); @@ -286,10 +287,7 @@ $(function() { }; attributesHeaderLength = $('.attributes:not(:hidden)').length+1; attributesLength = $('#attributes-area .attributes').length; - if(templateType == null){ - templateType = "typeA"; - } - $("#template-attributes").tmpl(setData(attributesLength, templateType, appendIndex)).appendTo( "#attributes-area" ); + $("#template-attributes").tmpl(setData(attributesLength, default_templateType, appendIndex)).appendTo( "#attributes-area" ); $('.toggle-check').togglebox(); }); @@ -429,7 +427,7 @@ $(function() { if(!$('.attributes:not(:hidden)').length) { $('#attributes-area').addClass('clickHere'); }; - }).find('.attribute_field_to_delete').attr('value', 'true');; + }).find('.attribute_field_destroy').attr('value', 'true');; }; if($(this).hasClass('trigger')) { // appendIndex = $(this).closest('.controls').find('.input-append').length; diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index ea88ada..04cd3d3 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -501,26 +501,13 @@ class Admin::SeminarsController < OrbitAdminController @seminar_params["reviewer_ids"] = [] if @seminar_params["reviewer_ids"].nil? @seminar_params["organizer_id"] = nil if @seminar_params["organizer_id"].nil? end - if @seminar_params[:seminar_signup_fields] - @seminar_params[:seminar_signup_fields].each do |a| - @field_name = 'seminar_main' - field_status = a.last[:id].present? - @attribute_field = SeminarSignupField.add_seminar_signup_field(@seminar, a.last, a.last[:id], field_status) - @attribute = @seminar - end + if @seminar_params[:seminar_signup_fields_attributes] + @seminar.update_attributes(@seminar_params.slice(:seminar_signup_fields_attributes)) flash.now[:notice] = "Updated Fields" - @seminar.seminar_signup_fields.each{|t| t.destroy if t["to_delete"] == true} - redirect_to admin_seminars_path and return - elsif @seminar_params[:seminar_submission_fields] - params[:seminar_main][:seminar_submission_fields].each do |a| - @field_name = 'seminar_main' - field_status = a.last[:id].present? - @attribute_field = SeminarSubmissionField.add_seminar_signup_field(@seminar, a.last, a.last[:id], field_status) - @attribute = @seminar - end + elsif @seminar_params[:seminar_submission_fields_attributes] + @seminar.update_attributes(@seminar_params.slice(:seminar_submission_fields_attributes)) flash.now[:notice] = "Updated Fields" - @seminar.seminar_submission_fields.each{|t| t.destroy if t["to_delete"] == true} if @seminar.seminar_submission_fields.select{|sf| sf.markup == "seminar_preferred_session"}.count != 0 @seminar.update(:assign_mode => 2) default_sort_number = SeminarSignup.fields['sort_number'].options[:default] @@ -553,7 +540,6 @@ class Admin::SeminarsController < OrbitAdminController end redirect_to admin_seminars_path and return else - if !seminar_params['seminar_links_attributes'].nil? seminar_params['seminar_links_attributes'].each do |idx,link| seminar_params['seminar_links_attributes'].delete(idx.to_s) if link['url'].blank? @@ -562,6 +548,7 @@ class Admin::SeminarsController < OrbitAdminController @seminar.update_user_id = current_user.id if @seminar.update_attributes(seminar_params) + @seminar.update_enable_recaptcha @seminar.seminar_signup_fields.each{|t| t.destroy if t["to_delete"] == true} redirect_to params['referer_url'] and return else diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 7e0b634..5765b2f 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -1,5 +1,4 @@ class SeminarsController < ApplicationController - helper MemberHelper include MemberHelper include ActionView::Context #vary important (only add this can access @@session from view) @@ -25,36 +24,38 @@ class SeminarsController < ApplicationController time_now = DateTime.now session = OrbitHelper.request.session seminars = seminars.map do |seminar| - link_url = OrbitHelper.url_to_show(seminar.to_param) - if !seminar.registration_status.blank? && (seminar.signup_start_date <= time_now rescue false) && ( seminar.signup_end_date.nil? || seminar.signup_end_date+1 >= time_now ) - sign_up = ('' + I18n.t('seminar.signup') + '').html_safe - elsif seminar.registration_status.blank? - sign_up = I18n.t('seminar.sign_up_not_open') - elsif (seminar.signup_start_date > @time_now rescue false) - sign_up = I18n.t('seminar.sign_up_not_yet') + link_url = OrbitHelper.url_to_plugin_show(seminar.to_param, 'seminar') + registration_is_open = seminar.registration_status.present? + sign_up_not_yet = seminar.signup_start_date && @time_now && @seminar.signup_start_date > @time_now + sign_up_overdue = seminar.signup_end_date && @time_now && (@seminar.signup_end_date + 1.day <= @time_now) + seminar_url = (@custom_slug ? OrbitHelper.url_to_show(@custom_slug) : OrbitHelper.url_to_show(seminar.to_param)) + if !registration_is_open + sign_up = t('seminar.sign_up_not_open') + elsif sign_up_not_yet + sign_up = t('seminar.sign_up_not_yet') + elsif sign_up_overdue + sign_up = t('seminar.sign_up_overdue') else - sign_up = I18n.t('seminar.sign_up_overdue') + sign_up_text = t('seminar.signup') + sign_up = link_to(sign_up_text, seminar.get_frontend_url(link_url), :target=>'_blank', :title=>sign_up_text) end if !seminar.registration_status.blank? && seminar.registration_status.include?('C') && (seminar.contribute_start_date <= time_now rescue false) && ( seminar.contribute_end_date.nil? || (seminar.contribute_end_date+1 >= time_now rescue false) ) - sign_up += "".html_safe - if !session[:seminar_signup_id].blank? - if session[:seminar_main_id] == seminar.id - sign_up += ('' + t('seminar_signup.uploads') + '').html_safe + sign_up += content_tag :span, :style=> "margin-left: 1em;" do + if session[:seminar_signup_id].present? && session[:seminar_main_id] == seminar.id + button_text = t('seminar_signup.uploads') + link_to(button_text, seminar.get_frontend_url(link_url, :con_upload), {:title=>button_text}) else - sign_up += ('' + t('seminar_signup.con_login') + '').html_safe + button_text = t('seminar_signup.con_login') + link_to(button_text, seminar.get_frontend_url(link_url, :con_login), {:title=>button_text}) end - else - sign_up += ('' + t('seminar_signup.con_login') + '').html_safe end - sign_up += "".html_safe end files = seminar.seminar_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } } rescue [] - files.delete(nil) - links = seminar.seminar_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] + links = seminar.seminar_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title rescue '') } } rescue [] {"title" => seminar.title, "subtitle" => sign_up, "category" => (seminar.category.title rescue ""), - "link_to_show" => (link_url == "#" ? '' : link_url + "?method=show_data"), + "link_to_show" => (OrbitHelper.instance_variable_get(:@url_to_plugin_show_blank) ? 'javascript:void(0)' : seminar.get_frontend_url(link_url, :show_data)), "postdate" => seminar.seminar_start_date, "statuses" => {}, "bulletin_links" => links, @@ -185,14 +186,12 @@ class SeminarsController < ApplicationController sign_up = t('seminar.sign_up_overdue') 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 !@@session[:seminar_signup_id].blank? - if @@session[:seminar_main_id] == seminar.id - contribute_action = ('' + t('seminar_signup.uploads') + '').html_safe - else - contribute_action = ('' + t('seminar_signup.con_login') + '').html_safe - end + if @@session[:seminar_signup_id].present? && @@session[:seminar_main_id] == seminar.id + button_text = t('seminar_signup.uploads') + contribute_action = link_to(button_text, submission_url + '?method=con_upload', :title=>button_text) else - contribute_action = ('' + t('seminar_signup.con_login') + '').html_safe + button_text = t('seminar_signup.con_login') + contribute_action = link_to(button_text, submission_url + '?method=con_login', :title=>button_text) end end data = { @@ -288,6 +287,23 @@ class SeminarsController < ApplicationController :params=>params,:session=>@@session},:layout=>false).html_safe end end + def get_referer_url_for_notice(notice_words) + referer_url = params[:referer_url].to_s + split_path = referer_url.split("/") + last_path = split_path.last + if last_path.include?("?") + referer_url = split_path[0...-1].join('/') + '/' + last_path.split('?')[0] + uri_query = last_path.split("?")[1..-1].join('?') + uri_query.gsub!(/notice=[^&]*/,'').gsub!(/&+$/,'') + if uri_query.blank? + referer_url = referer_url + "?notice=#{notice_words}" + else + referer_url = referer_url + "?#{uri_query}¬ice=#{notice_words}" + end + else + referer_url = referer_url + "?notice=#{notice_words}" + end + end def show_privacy params = OrbitHelper.params @@ -310,31 +326,31 @@ class SeminarsController < ApplicationController params = OrbitHelper.params seminar = SeminarMain.find_by(uid: params[:uid]) - - if !seminar.registration_status.blank? && seminar.signup_start_date <= time_now && ( seminar.signup_end_date.nil? || seminar.signup_end_date+1 >= time_now ) - sign_up = ('' + t('seminar.signup') + '').html_safe - elsif seminar.registration_status.blank? + registration_is_open = seminar.registration_status.present? + sign_up_not_yet = seminar.signup_start_date && @time_now && @seminar.signup_start_date > @time_now + sign_up_overdue = seminar.signup_end_date && @time_now && (@seminar.signup_end_date + 1.day <= @time_now) + seminar_url = (@custom_slug ? OrbitHelper.url_to_show(@custom_slug) : OrbitHelper.url_to_show(seminar.to_param)) + if !registration_is_open sign_up = t('seminar.sign_up_not_open') - elsif seminar.signup_start_date > time_now + elsif sign_up_not_yet sign_up = t('seminar.sign_up_not_yet') - else + elsif sign_up_overdue sign_up = t('seminar.sign_up_overdue') + else + sign_up_text = t('seminar.signup') + 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 !@@session[:seminar_signup_id].blank? - if @@session[:seminar_main_id] == seminar.id - contribute_action = ('' + t('seminar_signup.uploads') + '').html_safe - else - contribute_action = ('' + t('seminar_signup.con_login') + '').html_safe - end + 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) else - contribute_action = ('' + t('seminar_signup.con_login') + '').html_safe + button_text = t('seminar_signup.con_login') + contribute_action = link_to(button_text, seminar.get_frontend_url(seminar_url, :con_login), :title=>button_text) end end - - { 'seminar' => seminar, 'sign_up' => sign_up, @@ -400,84 +416,62 @@ class SeminarsController < ApplicationController end def create - - @signup = SeminarSignup.where(email: params[:seminar_signup][:email], seminar_main_id: params[:seminar_signup][:seminar_main_id] ).first + seminar_id = params[:seminar_signup][:seminar_main_id] + @seminar = SeminarMain.where(id: seminar_id).first + if @seminar.enable_recaptcha && (!gotcha_valid?) + notice_words = t('recaptcha.errors.verification_failed') + referer_url = get_referer_url_for_notice(notice_words) + redirect_to referer_url, :notice => notice_words + return + end + @signup = SeminarSignup.where(email: params[:seminar_signup][:email], seminar_main_id: seminar_id ).first @seminar_signup = SeminarSignup.new(seminar_signup_params) - @seminar = SeminarMain.where(id:params[:seminar_signup][:seminar_main_id]).first - if @seminar.seminar_signup_field_sets.count!=0 - flag = @seminar.seminar_signup_field_sets.select{|v| v.field_name=='recaptcha'}[0].disabled - else - flag = false - end - if gotcha_valid? || flag - if @signup.blank? && @seminar_signup.save - # if gotcha_valid? && @seminar_signup.save - - if !params[:seminar_signup_values].nil? - seminar_signup_values_params.each_with_index do |r,i| - field_value = r.last[:id].present? - @custom_field_value = SeminarSignupValue.put_field_values(@seminar_signup, r.last, r.last[:seminar_signup_field_id], field_value) - end - seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar.id).to_a - seminar_reviews.each{|sr| sr.save} - @seminar = @seminar_signup.seminar_main - unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s} - unassigned_seminar_signup_ids.push(@seminar_signup.id.to_s) - seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar.id).to_a - seminar_reviews.each do |sr| - unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids - end - @seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s - @seminar.unassigned_mode_1_seminar_signup_ids << @seminar_signup.id.to_s - @seminar.save - else - @seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s - @seminar.unassigned_mode_1_seminar_signup_ids << @seminar_signup.id.to_s - @seminar.save + not_signup_yet = @signup.blank? + if not_signup_yet && @seminar_signup.save + if !params[:seminar_signup_values].nil? + seminar_signup_values_params.each_with_index do |r,i| + field_value = r.last[:id].present? + @custom_field_value = SeminarSignupValue.put_field_values(@seminar_signup, r.last, r.last[:seminar_signup_field_id], field_value) end - extra_text = "
#{I18n.t('seminar_signup.serial_number')}: #{@seminar_signup.display_serial_number}" - extra_text += render_to_string("seminars/signup_email_contents",:locals=>{:seminar=>@seminar, - :seminar_signup=>@seminar_signup},:layout=>false) - if params['seminar_signup']['status']=='C' - status_param = '&status=' - send_mail('submission',params[:seminar_signup][:email],params[:seminar_signup][:seminar_main_id],extra_text) - else - status_param = '' - send_mail('signup',params[:seminar_signup][:email],params[:seminar_signup][:seminar_main_id],extra_text) + seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar.id).to_a + seminar_reviews.each{|sr| sr.save} + @seminar = @seminar_signup.seminar_main + unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s} + unassigned_seminar_signup_ids.push(@seminar_signup.id.to_s) + seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar.id).to_a + seminar_reviews.each do |sr| + unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids end - redirect_to "#{params[:referer_url].to_s.chomp('/')}/?method=signup_ok#{status_param}&serial_number=#{@seminar_signup.display_serial_number}" + @seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s + @seminar.unassigned_mode_1_seminar_signup_ids << @seminar_signup.id.to_s + @seminar.save else - if !@signup.blank? - redirect_to "#{params[:referer_url]}", :notice => 'mail已存在' - else - referer_url = params[:referer_url].to_s - if referer_url.split("/").last.include?("?") - uri_query = referer_url.split("?").last.gsub(/notice=[^&]*/,'') - if uri_query == "" - referer_url = referer_url.split("?")[0...-1].join("?") + "?notice=#{t('recaptcha.errors.verification_failed')}" - else - referer_url = referer_url.split("?")[0...-1].join("?") + "¬ice=#{t('recaptcha.errors.verification_failed')}" - end - else - referer_url = referer_url + "?notice=#{t('recaptcha.errors.verification_failed')}" - end - redirect_to referer_url, :notice => t('recaptcha.errors.verification_failed') - end + @seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s + @seminar.unassigned_mode_1_seminar_signup_ids << @seminar_signup.id.to_s + @seminar.save end - else - referer_url = params[:referer_url].to_s - if referer_url.split("/").last.include?("?") - uri_query = referer_url.split("?").last.gsub(/notice=[^&]*/,'') - if uri_query == "" - referer_url = referer_url.split("?")[0...-1].join("?") + "?notice=#{t('recaptcha.errors.verification_failed')}" - else - referer_url = referer_url.split("?")[0...-1].join("?") + "¬ice=#{t('recaptcha.errors.verification_failed')}" - end + extra_text = "
#{I18n.t('seminar_signup.serial_number')}: #{@seminar_signup.display_serial_number}" + extra_text += render_to_string("seminars/signup_email_contents",:locals=>{:seminar=>@seminar, + :seminar_signup=>@seminar_signup},:layout=>false) + if params['seminar_signup']['status']=='C' + status_param = '&status=' + send_mail('submission',params[:seminar_signup][:email],params[:seminar_signup][:seminar_main_id],extra_text) else - referer_url = referer_url + "?notice=#{t('recaptcha.errors.verification_failed')}" + status_param = '' + send_mail('signup',params[:seminar_signup][:email],params[:seminar_signup][:seminar_main_id],extra_text) + end + redirect_to "#{params[:referer_url].to_s.chomp('/').gsub(/\/([^\/?#]+)(|[^\/]+)$/){|f| '/'+$1}}?method=signup_ok#{status_param}&serial_number=#{@seminar_signup.display_serial_number}" + else + if !not_signup_yet + notice_words = t('seminar.email_exist') + referer_url = get_referer_url_for_notice(notice_words) + redirect_to referer_url, :notice => notice_words + else + notice_words = t('seminar.sign_up_failed') + referer_url = get_referer_url_for_notice(notice_words) + redirect_to referer_url, :notice => notice_words end - redirect_to referer_url, :notice => t('recaptcha.errors.verification_failed') end end diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb index d746313..f95d74b 100644 --- a/app/models/seminar_main.rb +++ b/app/models/seminar_main.rb @@ -9,6 +9,7 @@ class SeminarMain include Slug ChoiceTypes = ["checkbox","radio","select"] ExceptFieldSetDisplays = ["password", "recaptcha"] + field :enable_recaptcha, :type => Boolean field :annc_count, :type => Integer, :default => 0 field :album_count, :type => Integer, :default => 0 field :copy_id @@ -25,11 +26,11 @@ class SeminarMain "F. Environmental and Reaction Engineering","G. Industrial Applications", "H. Student Oral Presentation Contest (in English)","I. Student Poster Competition" ] - field :seminar_start_date, :type => Date, :default => Time.now - field :seminar_end_date, :type => Date, :default => Time.now + field :seminar_start_date, :type => Date, :default => Date.today + field :seminar_end_date, :type => Date, :default => Date.today - field :signup_start_date, :type => Date, :default => Time.now - field :signup_end_date, :type => Date, :default => Time.now + field :signup_start_date, :type => Date, :default => Date.today + field :signup_end_date, :type => Date, :default => Date.today field :contribute_start_date, :type => Date field :contribute_end_date, :type => Date @@ -229,6 +230,33 @@ class SeminarMain Page.where(:bind_model=>self.class.to_s,:bind_uid=>self.uid).destroy end end + def get_frontend_url(tmp_seminar_url, call_action=nil) + @enable_custom_template = self.enable_custom_template + if call_action.nil? + if @enable_custom_template + extra_url = '/home/registration' + else + extra_url = '' + end + elsif call_action == :show_data + if @enable_custom_template + extra_url = '/home/introduction' + else + extra_url = '?method=show_data' + end + else + if @enable_custom_template + extra_url = "/home/submission" + else + extra_url = "?method=#{call_action}" + end + end + tmp_seminar_url + extra_url + end + def update_enable_recaptcha + self.enable_recaptcha = (self.seminar_signup_field_sets.where(:field_name=>'recaptcha', :disabled.ne=>true).count != 0) + self.save + end def self.time_range(date1 = null, date2 = null) if !date1.blank? diff --git a/app/models/seminar_signup_field.rb b/app/models/seminar_signup_field.rb index 60ff2d1..c0d87f3 100644 --- a/app/models/seminar_signup_field.rb +++ b/app/models/seminar_signup_field.rb @@ -6,14 +6,14 @@ class SeminarSignupField include ::Admin::SeminarsFieldHelper field :key, type: String - field :af_count + # field :af_count field :title, type: String, localize: true field :markup, default: "text_field" field :option_list, type: Hash,default: {} field :markup_options, type: Hash field :built_in, type: Boolean, default: false field :disabled, type: Boolean, default: false - field :to_delete, type: Boolean, default: false + # field :to_delete, type: Boolean, default: false field :to_require,type: Boolean, default: true @@ -27,7 +27,15 @@ class SeminarSignupField has_many :seminar_signup_values, autosave: true, dependent: :destroy accepts_nested_attributes_for :seminar_signup_values, :allow_destroy => true before_save :check_option_list - + before_save do |record| + record.instance_variable_set(:@key_changed, record.key_changed?) + true + end + after_save do |record| + if record.instance_variable_get(:@key_changed) + record.seminar_signup_values.update_all(:key=>record.key) + end + end def markup_value get_data["option_list"] end @@ -100,24 +108,16 @@ class SeminarSignupField def self.add_seminar_signup_field(seminar,seminar_param, seminar_signup_field_id=nil,field_status) @field_name = 'seminar' if field_status.eql?(true) - @seminar_signup_field_counter = seminar.seminar_signup_fields.count rescue nil @seminar_signup_field = self.find(seminar_signup_field_id) rescue nil - old_key = @seminar_signup_field.key - @seminar_signup_field.update(seminar_param) - @seminar_signup_field.save - attribute_values = @seminar_signup_field.seminar_signup_values - if attribute_values.count > 0 - attribute_values.each do |av| - av.key = seminar_param["key"] - av.save - end + if @seminar_signup_field.nil? + @seminar_signup_field = seminar.seminar_signup_fields.build(seminar_param) + @seminar_signup_field.save + else + @seminar_signup_field.update(seminar_param) end - @seminar_signup_field[:af_count] = @seminar_signup_field_counter else - @seminar_signup_field_counter = seminar.seminar_signup_fields.count rescue nil - @seminar_signup_field = seminar.seminar_signup_fields.build(seminar_param) rescue nil - @seminar_signup_field.save - @seminar_signup_field[:af_count] = @seminar_signup_field_counter + @seminar_signup_field = seminar.seminar_signup_fields.build(seminar_param) + @seminar_signup_field.save end return @seminar_signup_field end diff --git a/app/models/seminar_submission_field.rb b/app/models/seminar_submission_field.rb index cd6968d..c86a56c 100644 --- a/app/models/seminar_submission_field.rb +++ b/app/models/seminar_submission_field.rb @@ -6,14 +6,14 @@ class SeminarSubmissionField include ::Admin::SeminarsFieldHelper field :key, type: String - field :af_count + # field :af_count field :title, type: String, localize: true field :markup, default: "text_field" field :option_list, type: Hash,default: {} field :markup_options, type: Hash field :built_in, type: Boolean, default: false field :disabled, type: Boolean, default: false - field :to_delete, type: Boolean, default: false + # field :to_delete, type: Boolean, default: false field :to_require,type: Boolean, default: true @@ -27,6 +27,15 @@ class SeminarSubmissionField has_many :seminar_submission_values, autosave: true, dependent: :destroy accepts_nested_attributes_for :seminar_submission_values, :allow_destroy => true before_save :check_option_list + before_save do |record| + record.instance_variable_set(:@key_changed, record.key_changed?) + true + end + after_save do |record| + if record.instance_variable_get(:@key_changed) + record.seminar_submission_values.update_all(:key=>record.key) + end + end def get_basic_field_name_org "seminar_submission_values" end @@ -125,24 +134,16 @@ class SeminarSubmissionField def self.add_seminar_signup_field(seminar,seminar_param, seminar_submission_field_id=nil,field_status) @field_name = 'seminar' if field_status.eql?(true) - @seminar_submission_field_counter = seminar.seminar_submission_fields.count rescue nil @seminar_submission_field = self.find(seminar_submission_field_id) rescue nil - old_key = @seminar_submission_field.key - @seminar_submission_field.update(seminar_param) - @seminar_submission_field.save - attribute_values = @seminar_submission_field.seminar_submission_values - if attribute_values.count > 0 - attribute_values.each do |av| - av.key = seminar_param["key"] - av.save - end + if @seminar_submission_field.nil? + @seminar_submission_field = seminar.seminar_submission_fields.build(seminar_param) + @seminar_submission_field.save + else + @seminar_submission_field.update(seminar_param) end - @seminar_submission_field[:af_count] = @seminar_submission_field_counter else - @seminar_submission_field_counter = seminar.seminar_submission_fields.count rescue nil - @seminar_submission_field = seminar.seminar_submission_fields.build(seminar_param) rescue nil - @seminar_submission_field.save - @seminar_submission_field[:af_count] = @seminar_submission_field_counter + @seminar_submission_field = seminar.seminar_submission_fields.build(seminar_param) + @seminar_submission_field.save end return @seminar_submission_field end diff --git a/app/views/admin/seminars/_attribute_field.html.erb b/app/views/admin/seminars/_attribute_field.html.erb index c71dd8a..46df8ba 100644 --- a/app/views/admin/seminars/_attribute_field.html.erb +++ b/app/views/admin/seminars/_attribute_field.html.erb @@ -1,16 +1,16 @@
<% - attribute_field.af_count ? @af_counter = attribute_field_counter + attribute_field.af_count : @af_counter = attribute_field_counter + @af_counter = attribute_field_counter %>
- <%= hidden_field "#{@field_name}[seminar_signup_fields][#{@af_counter}]","disabled",:value=>attribute_field.disabled,:class=>"toggle-check", :data=>{:deploy=>"right"} %> + <%= hidden_field "#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}]","disabled",:value=>attribute_field.disabled,:class=>"toggle-check", :data=>{:deploy=>"right"} %>
<%= t(:delete_)%> - <%= hidden_field "#{@field_name}[seminar_signup_fields][#{@af_counter}]","to_delete",:value=>false,:class=>"attribute_field_to_delete"%> + <%= hidden_field "#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}]","_destroy",:value=>false,:class=>"attribute_field_destroy"%> Reset

Field <%= @af_counter + 1 %>

@@ -18,27 +18,27 @@
- <%= text_field "#{@field_name}[seminar_signup_fields][#{@af_counter}]","key",:value=>attribute_field.key, :data=>{:type=>"key"} %> + <%= text_field "#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}]","key",:value=>attribute_field.key, :data=>{:type=>"key"} %>
- <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field.title_translations,:class_ext=>"pull-left",:label_ext=>t(:name),:field_name=>"#{@field_name}[seminar_signup_fields][#{@af_counter}][title_translations]"}%> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field.title_translations,:class_ext=>"pull-left",:label_ext=>t(:name),:field_name=>"#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}][title_translations]"}%>
- > <%$seminar_list[:markups].each do |key,val|%> <% next if val["display_only"] && val["display_only"] != "seminar_signup_field" %> <% if key != 'address' %> @@ -57,25 +57,25 @@
- <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field["typeA"]["placeholder"],:field_name=>"#{@field_name}[seminar_signup_fields][#{@af_counter}][typeA][placeholder]"}%> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field["typeA"]["placeholder"],:field_name=>"#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}][typeA][placeholder]"}%> <% end if show_seminar_type_panel(attribute_field,"typeA") != 'typeA hide' %> <%= content_tag :div,:class=>"field-type default fade in #{show_seminar_type_panel(attribute_field,"typeB")}" do %> - <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:label_ext=>t(:initial),:values=>attribute_field["typeB"]["initial"],:field_name=>"#{@field_name}[seminar_signup_fields][#{@af_counter}][typeB][initial]"}%> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:label_ext=>t(:initial),:values=>attribute_field["typeB"]["initial"],:field_name=>"#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}][typeB][initial]"}%> <% if attribute_field.self_defined_markup_options?%> - <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "#{@field_name}[seminar_signup_fields][#{@af_counter}][attribute][seminar][statuses]"} %> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}][attribute][seminar][statuses]"} %> <%else #normal list%> - <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "#{@field_name}[seminar_signup_fields][#{@af_counter}][typeB][option_list]"} %> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}][typeB][option_list]"} %> <% end #of self_defined_markup_options?%> <% end if show_seminar_type_panel(attribute_field,"typeB") != 'typeB hide' %> @@ -84,17 +84,17 @@
- <%= select "#{@field_name}[seminar_signup_fields][#{@af_counter}][typeC]","format",Admin::AttributeValuesViewHelper::OPT,:class=>"dataType",:selected=>attribute_field["typeC"]["format"] %> + <%= select "#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}][typeC]","format",Admin::AttributeValuesViewHelper::OPT,:class=>"dataType",:selected=>attribute_field["typeC"]["format"] %>
@@ -102,10 +102,10 @@
@@ -116,18 +116,18 @@
- <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:field_name=>"#{@field_name}[seminar_signup_fields][#{@af_counter}][typeD][placeholder]",:values=>attribute_field["typeD"]["placeholder"]} %> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:field_name=>"#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}][typeD][placeholder]",:values=>attribute_field["typeD"]["placeholder"]} %> <% end if show_seminar_type_panel(attribute_field,"typeD") != 'typeD hide' %> <%= content_tag :div,:class=>"field-type default fade in #{show_seminar_type_panel(attribute_field,"typeE")}" do%> - <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:field_name=>"#{@field_name}[seminar_signup_fields][#{@af_counter}][typeE][option_list]",:values=>attribute_field["typeE"]["option_list"]}%> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:field_name=>"#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}][typeE][option_list]",:values=>attribute_field["typeE"]["option_list"]}%> <% end if show_seminar_type_panel(attribute_field,"typeE") != 'typeE hide' %> - <%= hidden_field "#{@field_name}[seminar_signup_fields][#{@af_counter}]","id",:value=>attribute_field.id%> + <%= hidden_field "#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}]","id",:value=>attribute_field.id%> \ No newline at end of file diff --git a/app/views/admin/seminars/_attribute_submission_field.html.erb b/app/views/admin/seminars/_attribute_submission_field.html.erb index a2228f6..30a089d 100644 --- a/app/views/admin/seminars/_attribute_submission_field.html.erb +++ b/app/views/admin/seminars/_attribute_submission_field.html.erb @@ -1,16 +1,16 @@
<% - attribute_submission_field.af_count ? @af_counter = attribute_submission_field_counter + attribute_submission_field.af_count : @af_counter = attribute_submission_field_counter + @af_counter = attribute_submission_field_counter %>
- <%= hidden_field "#{@field_name}[seminar_submission_fields][#{@af_counter}]","disabled",:value=>attribute_submission_field.disabled,:class=>"toggle-check", :data=>{:deploy=>"right"} %> + <%= hidden_field "#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}]","disabled",:value=>attribute_submission_field.disabled,:class=>"toggle-check", :data=>{:deploy=>"right"} %>
<%= t(:delete_)%> - <%= hidden_field "#{@field_name}[seminar_submission_fields][#{@af_counter}]","to_delete",:value=>false,:class=>"attribute_submission_field_to_delete"%> + <%= hidden_field "#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}]","_destroy",:value=>false,:class=>"attribute_field_destroy"%> Reset

Field <%= @af_counter + 1 %>

@@ -18,27 +18,27 @@
- <%= text_field "#{@field_name}[seminar_submission_fields][#{@af_counter}]","key",:value=>attribute_submission_field.key, :data=>{:type=>"key"} %> + <%= text_field "#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}]","key",:value=>attribute_submission_field.key, :data=>{:type=>"key"} %>
- <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_submission_field.title_translations,:class_ext=>"pull-left",:label_ext=>t(:name),:field_name=>"#{@field_name}[seminar_submission_fields][#{@af_counter}][title_translations]"}%> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_submission_field.title_translations,:class_ext=>"pull-left",:label_ext=>t(:name),:field_name=>"#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}][title_translations]"}%>
- > <%$seminar_list[:markups].each do |key,val|%> <% next if val["display_only"] && val["display_only"] != "seminar_submission_field" %> <% if key != 'address' %> @@ -57,25 +57,25 @@
- <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_submission_field["typeA"]["placeholder"],:field_name=>"#{@field_name}[seminar_submission_fields][#{@af_counter}][typeA][placeholder]"}%> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_submission_field["typeA"]["placeholder"],:field_name=>"#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}][typeA][placeholder]"}%> <% end if show_seminar_type_panel(attribute_submission_field,"typeA") != 'typeA hide' %> <%= content_tag :div,:class=>"field-type default fade in #{show_seminar_type_panel(attribute_submission_field,"typeB")}" do %> - <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:label_ext=>t(:initial),:values=>attribute_submission_field["typeB"]["initial"],:field_name=>"#{@field_name}[seminar_submission_fields][#{@af_counter}][typeB][initial]"}%> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:label_ext=>t(:initial),:values=>attribute_submission_field["typeB"]["initial"],:field_name=>"#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}][typeB][initial]"}%> <% if attribute_submission_field.self_defined_markup_options?%> - <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_submission_field["option_list"],:field_name=> "#{@field_name}[seminar_submission_fields][#{@af_counter}][attribute][seminar][statuses]"} %> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_submission_field["option_list"],:field_name=> "#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}][attribute][seminar][statuses]"} %> <%else #normal list%> - <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_submission_field["option_list"],:field_name=> "#{@field_name}[seminar_submission_fields][#{@af_counter}][typeB][option_list]"} %> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_submission_field["option_list"],:field_name=> "#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}][typeB][option_list]"} %> <% end #of self_defined_markup_options?%> <% end if show_seminar_type_panel(attribute_submission_field,"typeB") != 'typeB hide' %> @@ -84,17 +84,17 @@
- <%= select "#{@field_name}[seminar_submission_fields][#{@af_counter}][typeC]","format",Admin::AttributeValuesViewHelper::OPT,:class=>"dataType",:selected=>attribute_submission_field["typeC"]["format"] %> + <%= select "#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}][typeC]","format",Admin::AttributeValuesViewHelper::OPT,:class=>"dataType",:selected=>attribute_submission_field["typeC"]["format"] %>
@@ -102,10 +102,10 @@
@@ -116,16 +116,16 @@
- <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:field_name=>"#{@field_name}[seminar_submission_fields][#{@af_counter}][typeD][placeholder]",:values=>attribute_submission_field["typeD"]["placeholder"]} %> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:field_name=>"#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}][typeD][placeholder]",:values=>attribute_submission_field["typeD"]["placeholder"]} %> <% end if show_seminar_type_panel(attribute_submission_field,"typeD") != 'typeD hide' %> <%= content_tag :div,:class=>"field-type default fade in #{show_seminar_type_panel(attribute_submission_field,"typeE")}" do%> - <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:field_name=>"#{@field_name}[seminar_submission_fields][#{@af_counter}][typeE][option_list]",:values=>attribute_submission_field["typeE"]["option_list"]}%> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:field_name=>"#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}][typeE][option_list]",:values=>attribute_submission_field["typeE"]["option_list"]}%> <% end if show_seminar_type_panel(attribute_submission_field,"typeE") != 'typeE hide' %> <%= content_tag :div,:class=>"field-type default fade in #{show_seminar_type_panel(attribute_submission_field,"typeF")}" do%>
@@ -139,6 +139,6 @@
<% end if show_seminar_type_panel(attribute_submission_field,"typeF") != 'typeF hide' %> - <%= hidden_field "#{@field_name}[seminar_submission_fields][#{@af_counter}]","id",:value=>attribute_submission_field.id%> + <%= hidden_field "#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}]","id",:value=>attribute_submission_field.id%> \ No newline at end of file diff --git a/app/views/admin/seminars/_get_display_fields.html.erb b/app/views/admin/seminars/_get_display_fields.html.erb index 54e84db..14e98f8 100644 --- a/app/views/admin/seminars/_get_display_fields.html.erb +++ b/app/views/admin/seminars/_get_display_fields.html.erb @@ -32,10 +32,11 @@ <% @seminar.seminar_signup_field_customs.each do |field_set| %> <% s = field_set.seminar_signup_field %> <% next if (s.nil? || s.key.blank?) %> - <% default_hidden << "seminar_signup_field_custom.#{s.key}" if (field_set.hidden) %> + <% default_hidden << "seminar_signup_fields.#{s.key}" if (field_set.hidden) %> <% end %> <% end %> <% @seminar.seminar_signup_fields.each do |s| %> + <% next if s.title.blank? %> <% default_hidden << "seminar_signup_fields.#{s.key}" %> <% @field_names << "seminar_signup_fields.#{s.key}" %> <% @field_name_translations << s.title %> @@ -110,16 +111,18 @@ <% @field_name_translations << t(th) %> <% end %> <% end %> - <% seminar_signup_field_customs = SeminarSignupFieldCustom.all.map{|field_set| SeminarSignupField.where(id: field_set.seminar_signup_field_id).first}.select{|s| !s.nil?}.uniq{|s| s.key } %> + <% seminar_signup_fields = SeminarSignupField.where(:key.nin=>["", nil]).uniq{|s| s.key} %> + <% seminar_signup_field_customs = SeminarSignupFieldCustom.where(:seminar_signup_field_id.in=> seminar_signup_fields.map(&:id)).to_a %> <% if seminar_signup_field_customs.count != 0 %> - <% seminar_signup_field_customs.each do |s| %> + <% seminar_signup_field_customs.each do |field_set| %> <% s = field_set.seminar_signup_field %> - <% next if (s.nil? || s.key.blank?) %> - <% default_hidden << "seminar_signup_field_custom.#{s.key}" if (field_set.hidden) %> + <% next if s.title.blank? %> + <% default_hidden << "seminar_signup_fields.#{s.key}" if (field_set.hidden) %> <% end %> <% end %> - <% seminar_signup_fields = SeminarSignupField.all.uniq{|s| s.key} %> <% seminar_signup_fields.each do |s| %> + <% next if s.title.blank? %> + <% default_hidden << "seminar_signup_fields.#{s.key}" %> <% @field_names << "seminar_signup_fields.#{s.key}" %> <% @field_name_translations << s.title %> <% end %> @@ -138,8 +141,9 @@ <% default_show << "seminar_signup_contributes.description" if show3 %> <% @field_names << 'seminar_signup_contributes.description' %> <% @field_name_translations << t('seminar_signup.description') %> - <% seminar_submission_fields = SeminarSignupField.all.uniq{|s| s.key} %> + <% seminar_submission_fields = SeminarSubmissionField.where(:key.nin=>["", nil]).uniq{|s| s.key} %> <% seminar_submission_fields.each do |s| %> + <% next if s.title.blank? %> <% @field_names << "seminar_submission_fields.#{s.key}" %> <% @field_name_translations << s.title %> <% end %> diff --git a/app/views/admin/seminars/_support_member_form_js.erb b/app/views/admin/seminars/_support_member_form_js.erb index 6205f84..12dabb9 100644 --- a/app/views/admin/seminars/_support_member_form_js.erb +++ b/app/views/admin/seminars/_support_member_form_js.erb @@ -6,7 +6,7 @@ Delete Reply - +

Field ${attributesHeaderLength}

diff --git a/app/views/seminars/index.html.erb b/app/views/seminars/index.html.erb index 9b70e05..e0108df 100644 --- a/app/views/seminars/index.html.erb +++ b/app/views/seminars/index.html.erb @@ -23,25 +23,26 @@ <% @seminars.each do |seminar| - - if !seminar.registration_status.blank? and (seminar.signup_start_date <= @time_now rescue false) and ( seminar.signup_end_date.nil? or seminar.signup_end_date+1 >= @time_now ) - sign_up = ('' + t('seminar.signup') + '').html_safe - elsif seminar.registration_status.blank? - sign_up = t('seminar.sign_up_not_open') - elsif (seminar.signup_start_date > @time_now rescue false) - sign_up = t('seminar.sign_up_not_yet') - else - sign_up = t('seminar.sign_up_overdue') - end + registration_is_open = seminar.registration_status.present? + sign_up_not_yet = seminar.signup_start_date && @time_now && seminar.signup_start_date > @time_now + sign_up_overdue = seminar.signup_end_date && @time_now && (seminar.signup_end_date + 1.day <= @time_now) + seminar_url = OrbitHelper.url_to_show(seminar.to_param) + if !registration_is_open + sign_up = t('seminar.sign_up_not_open') + elsif sign_up_not_yet + sign_up = t('seminar.sign_up_not_yet') + elsif sign_up_overdue + sign_up = t('seminar.sign_up_overdue') + else + sign_up_text = t('seminar.signup') + sign_up = link_to(sign_up_text, seminar.get_frontend_url(seminar_url), :target=>'_blank', :title=>sign_up_text) + end + seminar_title = seminar.title %> <%= seminar.category.title %> - <% if (seminar.enable_custom_template rescue false) %> - <%= ('' + seminar.title + '').html_safe %> - <% else %> - <%= ('' + seminar.title + '').html_safe %> - <% end %> + <%= link_to(seminar_title, seminar.get_frontend_url(seminar_url, :show_data), :target=>'_blank', :title=>seminar_title) %> <%= SeminarMain.time_range(seminar.seminar_start_date, seminar.seminar_end_date) %> <%= seminar.act_place %> @@ -49,15 +50,13 @@ <%= sign_up %>
<%= - if !seminar.registration_status.blank? and seminar.registration_status.include?('C') and (seminar.contribute_start_date <= @time_now rescue false) and ( seminar.contribute_end_date.nil? or (seminar.contribute_end_date+1 >= @time_now rescue false) ) - if !session[:seminar_signup_id].blank? - if session[:seminar_main_id] == seminar.id - ('' + t('seminar_signup.uploads') + '').html_safe - else - ('' + t('seminar_signup.con_login') + '').html_safe - end + if registration_is_open && seminar.registration_status.include?('C') && (seminar.contribute_start_date.nil? || seminar.contribute_start_date <= @time_now rescue false) && ( seminar.contribute_end_date.nil? || (seminar.contribute_end_date+1.day >= @time_now rescue false) ) + if session[:seminar_signup_id].present? && session[:seminar_main_id] == seminar.id + button_text = t('seminar_signup.uploads') + link_to(button_text, seminar.get_frontend_url(seminar_url, :con_upload), :title=>button_text) else - ('' + t('seminar_signup.con_login') + '').html_safe + button_text = t('seminar_signup.con_login') + link_to(button_text, seminar.get_frontend_url(seminar_url, :con_login), :title=>button_text) end end %> diff --git a/app/views/seminars/show.html.erb b/app/views/seminars/show.html.erb index 4107704..2608529 100644 --- a/app/views/seminars/show.html.erb +++ b/app/views/seminars/show.html.erb @@ -9,9 +9,22 @@ else prefix_url = OrbitHelper.url_to_show(@seminar.to_param) end + registration_is_open = @seminar.registration_status.present? + sign_up_not_yet = @seminar.signup_start_date && @time_now && @seminar.signup_start_date > @time_now + sign_up_overdue = @seminar.signup_end_date && @time_now && (@seminar.signup_end_date + 1.day <= @time_now) %> -<% if !@seminar.registration_status.blank? and @seminar.signup_start_date < @time_now and ( @seminar.signup_end_date.nil? or @seminar.signup_end_date+1 > @time_now ) %> - +<% if !registration_is_open %> + +<%= t('seminar.sign_up_not_open') %> + +<% elsif sign_up_not_yet %> + +<%= t('seminar.sign_up_not_yet') %> + +<% elsif sign_up_overdue %> + +<%= t('seminar.sign_up_overdue') %> +<% else %> <%#= stylesheet_link_tag "lib/main-forms" %> <%= stylesheet_link_tag "basic/bootstrap-datetimepicker" %> <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> @@ -322,16 +335,4 @@ alert("1ssss2"); })(); -<% elsif @seminar.registration_status.blank? %> - -<%= t('seminar.sign_up_not_open') %> - -<% elsif @seminar.signup_start_date > @time_now %> - -<%= t('seminar.sign_up_not_yet') %> - -<% else %> - -<%= t('seminar.sign_up_overdue') %> - -<% end %> +<% end %> \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index fd200be..1a7e1f3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -85,6 +85,7 @@ en: dashboard: Dashboard display_field: Display field note: Note + email_exist: "Email exist!" email_signup_success: Signup success email_submission_success: Submission registration success email_add_file_success: Add file success @@ -153,6 +154,7 @@ en: sign_up_not_yet: Does Not Yet Allow Sign Up #報名時間未開始 sign_up_not_open: Does Not Open Sign Up #未開放報名 sign_up_overdue: Sign Up Overdue #報名時間已過 + sign_up_failed: "Sign up failed!" contribute_file_count: Count of Contribute Files #投稿檔案數 frontend: diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index bbb5d8d..58e1a9e 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -86,6 +86,7 @@ zh_tw: dashboard: 儀錶板 display_field: 顯示的欄位 note: 附註 + email_exist: "email已存在!" email_signup_success: 報名成功 email_submission_success: 投稿註冊成功 email_add_file_success: 新增上傳成功 @@ -154,6 +155,7 @@ zh_tw: sign_up_not_yet: 報名時間未開始 sign_up_not_open: 未開放報名 sign_up_overdue: 報名時間已過 + sign_up_failed: "報名失敗" contribute_file_count: 投稿檔案數 frontend: