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 @@