diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index 800e67a..d95ad02 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -58,11 +58,10 @@ class Admin::SeminarsController < OrbitAdminController end def new - + @member = nil @seminar = SeminarMain.new - @seminar_items = SeminarItem.all - + @review = @seminar.seminar_reviews.new() end def create @@ -85,9 +84,14 @@ class Admin::SeminarsController < OrbitAdminController end def edit - @seminar_items = SeminarItem.all - + attribute = SeminarMain.where(id: params[:id]) + if attribute.first.seminar_reviews.first.nil? + @review = attribute.first.seminar_reviews.new() + else + @review = attribute.first.seminar_reviews.first + end + @member = MemberProfile.find(@review.reviewer_id) rescue nil end def update @@ -190,5 +194,4 @@ class Admin::SeminarsController < OrbitAdminController params.require(:seminar_main).permit! end - end diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index d513de4..baf931f 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -1,6 +1,7 @@ class SeminarsController < ApplicationController helper MemberHelper + include ActionView::Context #vary important (only add this can access @@session from view) include Admin::SeminarsHelper # include SimpleCaptcha::ControllerHelpers def index @@ -36,13 +37,11 @@ class SeminarsController < ApplicationController time_now = Time.now - session = OrbitHelper.get_session - params = OrbitHelper.params seminar = SeminarMain.find_by(uid: params[:uid]) - 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 !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? sign_up = t('seminar.sign_up_not_open') @@ -52,9 +51,9 @@ class SeminarsController < ApplicationController sign_up = t('seminar.sign_up_overdue') end - if !seminar.registration_status.blank? and seminar.registration_status.include?('C') and seminar.contribute_start_date <= time_now and ( seminar.contribute_end_date.nil? or seminar.contribute_end_date+1 >= time_now ) - if !session[:seminar_signup_id].blank? - if session[:seminar_main_id] == seminar.id + 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 @@ -205,13 +204,11 @@ class SeminarsController < ApplicationController def add_file - session = OrbitHelper.get_session + if !@@session[:seminar_main_id].blank? - if !session[:seminar_main_id].blank? + seminar = SeminarMain.find_by(id: @@session[:seminar_main_id]) - seminar = SeminarMain.find_by(id: session[:seminar_main_id]) - - seminar_signup = SeminarSignup.find_by(_id: session[:seminar_signup_id], seminar_main_id: session[:seminar_main_id] ) + seminar_signup = SeminarSignup.find_by(_id: @@session[:seminar_signup_id], seminar_main_id: @@session[:seminar_main_id] ) else @@ -246,13 +243,11 @@ class SeminarsController < ApplicationController time_now = Time.now - session = OrbitHelper.get_session + if !@@session[:seminar_main_id].blank? - if !session[:seminar_main_id].blank? + seminar = SeminarMain.find_by(id: @@session[:seminar_main_id]) - seminar = SeminarMain.find_by(id: session[:seminar_main_id]) - - seminar_signup = SeminarSignup.find_by(_id: session[:seminar_signup_id], seminar_main_id: session[:seminar_main_id] ) + seminar_signup = SeminarSignup.find_by(_id: @@session[:seminar_signup_id], seminar_main_id: @@session[:seminar_main_id] ) else diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb index 7b284ad..c9badcc 100644 --- a/app/models/seminar_main.rb +++ b/app/models/seminar_main.rb @@ -35,13 +35,14 @@ class SeminarMain has_many :seminar_item_contents, :autosave => true, :dependent => :destroy has_many :seminar_signups, :autosave => true, :dependent => :destroy has_many :seminar_signup_fields, :autosave => true, :dependent => :destroy - + has_many :seminar_reviews, :autosave => true, :dependent => :destroy + accepts_nested_attributes_for :seminar_links, :allow_destroy => true accepts_nested_attributes_for :seminar_files, :allow_destroy => true accepts_nested_attributes_for :seminar_item_contents, :allow_destroy => true accepts_nested_attributes_for :seminar_signups, :allow_destroy => true accepts_nested_attributes_for :seminar_signup_fields, :allow_destroy => true - + accepts_nested_attributes_for :seminar_reviews, :allow_destroy => true def self.time_range(date1 = null, date2 = null) diff --git a/app/models/seminar_review.rb b/app/models/seminar_review.rb new file mode 100644 index 0000000..8ed7aee --- /dev/null +++ b/app/models/seminar_review.rb @@ -0,0 +1,12 @@ +# encoding: utf-8 +require "orbit_form_helper" +class SeminarReview + + include Mongoid::Document + include Mongoid::Timestamps + + field :review_start_date, :type => Date, :default => Time.now + field :review_end_date, :type => Date, :default => Time.now + field :reviewer_id + belongs_to :seminar_main +end diff --git a/app/views/admin/seminars/_form.html.erb b/app/views/admin/seminars/_form.html.erb index f6e9605..e6c94fd 100644 --- a/app/views/admin/seminars/_form.html.erb +++ b/app/views/admin/seminars/_form.html.erb @@ -18,7 +18,8 @@
@@ -102,12 +103,38 @@