diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index dbc4732..625a307 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -59,6 +59,11 @@ class Admin::SeminarsController < OrbitAdminController @fields_values << f.option_list end end + if @seminar.enable_summary_choice + @fields << "seminar_signup_contributes.description" + @fields_translations << I18n.t("seminar_signup.description") + @fields_values << @seminar.summary_chioices.map.with_index{|v,i| [i.to_s,{I18n.locale=>v}]}.to_h + end @fields_values = @fields_values.collect.with_index{|fields_values,i| [i, fields_values.values.map{|v| v[I18n.locale]} ] }.to_h end def update_reviewer_setting diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index e875a62..3143012 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -150,6 +150,15 @@ class SeminarsController < ApplicationController 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.save else @seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s @seminar.save diff --git a/app/helpers/admin/seminars_field_helper.rb b/app/helpers/admin/seminars_field_helper.rb index f3d385c..8e53536 100644 --- a/app/helpers/admin/seminars_field_helper.rb +++ b/app/helpers/admin/seminars_field_helper.rb @@ -52,7 +52,7 @@ module Admin::SeminarsFieldHelper @prefiled_value ||=[] control_group_wrapper do a = self.typeE[:option_list].collect do |key,value| - label_tag(key,check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), { :id=>"#{get_basic_field_name_org}_#{self.id}"})+value[I18n.locale.to_s],@markup_options.merge(:class=>"checkbox inline")) + label_tag("#{get_basic_field_name_org}_#{self.id}_#{key}",check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), { :id=>"#{get_basic_field_name_org}_#{self.id}_#{key}"})+value[I18n.locale.to_s],@markup_options.merge(:class=>"checkbox inline")) end.join.html_safe rescue "" end end @@ -138,7 +138,7 @@ module Admin::SeminarsFieldHelper @prefiled_value ||=[] control_group_wrapper do self.typeE[:option_list].collect do |key,value| - label_tag(key,radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {:required=>@require})+value[I18n.locale.to_s],@markup_options.merge(:class=>"radio inline")) + label_tag("#{get_basic_field_name_org}_#{self.id}_#{key}",radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {:required=>@require,:id=>"#{get_basic_field_name_org}_#{self.id}_#{key}"})+value[I18n.locale.to_s],@markup_options.merge(:class=>"radio inline")) end.join.html_safe end end diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb index 49de8e0..fd1565f 100644 --- a/app/models/seminar_main.rb +++ b/app/models/seminar_main.rb @@ -6,13 +6,19 @@ class SeminarMain # encoding: utf-8 include OrbitCategory::Categorizable include Slug - + ChoiceTypes = ["checkbox","radio","select"] field :signup_note, localize: true field :title, as: :slug_title, type: String, localize: true field :speaker, localize: true field :content, localize: true field :act_place, localize: true - + field :enable_summary_choice, :type => Boolean, :default => false + field :summary_chioice_type, :type => String, :default => "checkbox" + field :summary_chioices, :type => Array, :default => ["A. Energy Conversion","B. Biocatalysis","C. Electrocatalysis", + " D. Photocatalysis","E. Catalytic and Porous Materials", + "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 diff --git a/app/models/seminar_review.rb b/app/models/seminar_review.rb index fb407d6..5557d40 100644 --- a/app/models/seminar_review.rb +++ b/app/models/seminar_review.rb @@ -33,9 +33,11 @@ class SeminarReview next if fn.nil? if fn == "seminar_signup_fields" default_seminar_signup_ids += SeminarSignupValue.where(:seminar_signup_field_id=>id,:val.in=>self.default_topics_values[i].to_a).pluck(:seminar_signup_id) - elsif "seminar_submission_fields" + elsif fn == "seminar_submission_fields" seminar_signup_contribute_ids = SeminarSubmissionValue.where(:seminar_submission_field_id=>id,:val.in=>self.default_topics_values[i].to_a).pluck(:seminar_signup_contribute) default_seminar_signup_ids += SeminarSignupContribute.where(:id.in=>seminar_signup_contribute_ids).pluck(:seminar_signup_id) + elsif fn == "seminar_signup_contributes" + default_seminar_signup_ids += SeminarSignupContribute.where(:description.in=>self.default_topics_values[i].to_a).pluck(:seminar_signup_id) end end default_seminar_signup_ids.uniq! diff --git a/app/models/seminar_signup.rb b/app/models/seminar_signup.rb index cd08c32..baa912e 100644 --- a/app/models/seminar_signup.rb +++ b/app/models/seminar_signup.rb @@ -22,6 +22,10 @@ class SeminarSignup accepts_nested_attributes_for :seminar_signup_values, allow_destroy: true accepts_nested_attributes_for :seminar_signup_contributes, allow_destroy: true + before_create do + unit = self.unit_translations.values.select{|v| v.present?}.first + self.unit_translations = I18n.available_locales.map{|l| [l.to_s,unit]}.to_h + end after_destroy do seminar_main = self.seminar_main seminar_reviews = seminar_main.seminar_reviews diff --git a/app/views/admin/seminars/_form.html.erb b/app/views/admin/seminars/_form.html.erb index 27d3a1c..cb294d0 100644 --- a/app/views/admin/seminars/_form.html.erb +++ b/app/views/admin/seminars/_form.html.erb @@ -233,6 +233,27 @@ <% end %> +