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/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 @@
<%= f.text_field :contribute_file_count %> - (空白無限制) + (<%= t('seminar.blank_no_limit') %>)
- + +
+ <%= f.fields_for :seminar_reviews,@review do |seminar_reviews_form| %> +
+ +
+ <% if !@member.nil? %> + <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'seminar_main[seminar_reviews_attributes][0][reviewer_id][]', email_members:@member} %> + <% else %> + <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'seminar_main[seminar_reviews_attributes][0][reviewer_id][]', email_members:[]} %> + <% end %> +
+
+
+ +
+ <%= seminar_reviews_form.datetime_picker :review_start_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @seminar.new_record? %> +
+
+
+ +
+ <%= seminar_reviews_form.datetime_picker :review_end_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @seminar.new_record? %> +
+
+ <% end %> +
diff --git a/config/locales/en.yml b/config/locales/en.yml index 010de05..9c345f4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -15,6 +15,11 @@ en: verification_failed: 驗證碼錯誤 seminar: + reviewer: 審查委員 + review_end_date: 審查結束日期 + review_start_date: 審查開始日期 + review: 審稿 + blank_no_limit: 空白無限制 export_csv: 匯出CSV recaptcha: 驗證碼 yes_: 是 diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index dcc1eac..47acaf9 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -15,6 +15,11 @@ zh_tw: verification_failed: 驗證碼錯誤 seminar: + reviewer: 審查委員 + review_end_date: 審查結束日期 + review_start_date: 審查開始日期 + review: 審稿 + blank_no_limit: 空白無限制 export_csv: 匯出CSV recaptcha: 驗證碼 yes_: 是