add reviwer field in admin's form

This commit is contained in:
chiu 2019-10-05 00:11:39 +08:00
parent 4d0ba23f55
commit 41ca98636d
6 changed files with 64 additions and 11 deletions

View File

@ -58,11 +58,10 @@ class Admin::SeminarsController < OrbitAdminController
end end
def new def new
@member = nil
@seminar = SeminarMain.new @seminar = SeminarMain.new
@seminar_items = SeminarItem.all @seminar_items = SeminarItem.all
@review = @seminar.seminar_reviews.new()
end end
def create def create
@ -85,9 +84,14 @@ class Admin::SeminarsController < OrbitAdminController
end end
def edit def edit
@seminar_items = SeminarItem.all @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 end
def update def update
@ -190,5 +194,4 @@ class Admin::SeminarsController < OrbitAdminController
params.require(:seminar_main).permit! params.require(:seminar_main).permit!
end end
end end

View File

@ -35,13 +35,14 @@ class SeminarMain
has_many :seminar_item_contents, :autosave => true, :dependent => :destroy has_many :seminar_item_contents, :autosave => true, :dependent => :destroy
has_many :seminar_signups, :autosave => true, :dependent => :destroy has_many :seminar_signups, :autosave => true, :dependent => :destroy
has_many :seminar_signup_fields, :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_links, :allow_destroy => true
accepts_nested_attributes_for :seminar_files, :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_item_contents, :allow_destroy => true
accepts_nested_attributes_for :seminar_signups, :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_signup_fields, :allow_destroy => true
accepts_nested_attributes_for :seminar_reviews, :allow_destroy => true
def self.time_range(date1 = null, date2 = null) def self.time_range(date1 = null, date2 = null)

View File

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

View File

@ -19,6 +19,7 @@
<ul class="nav nav-pills module-nav"> <ul class="nav nav-pills module-nav">
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li> <li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
<li><a href="#signup" data-toggle="tab"><%= t('seminar.signup') %></a></li> <li><a href="#signup" data-toggle="tab"><%= t('seminar.signup') %></a></li>
<li><a href="#review" data-toggle="tab"><%= t('seminar.review') %></a></li>
</ul> </ul>
<!-- Module --> <!-- Module -->
@ -102,12 +103,38 @@
<label class="control-label muted"><%= t('seminar.contribute_file_count') %></label> <label class="control-label muted"><%= t('seminar.contribute_file_count') %></label>
<div class="controls"> <div class="controls">
<%= f.text_field :contribute_file_count %> <%= f.text_field :contribute_file_count %>
(空白無限制) (<%= t('seminar.blank_no_limit') %>)
</div> </div>
</div> </div>
</div> </div>
<!-- Review Module -->
<div class="tab-pane fade in " id="review">
<%= f.fields_for :seminar_reviews,@review do |seminar_reviews_form| %>
<div class="control-group big-group">
<label class="control-label muted"><%= t("seminar.reviewer") %></label>
<div class="controls">
<% 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 %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('seminar.review_start_date') %></label>
<div class="controls">
<%= seminar_reviews_form.datetime_picker :review_start_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @seminar.new_record? %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('seminar.review_end_date') %></label>
<div class="controls">
<%= seminar_reviews_form.datetime_picker :review_end_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @seminar.new_record? %>
</div>
</div>
<% end %>
</div>
</div> </div>
<!-- Language Tabs --> <!-- Language Tabs -->

View File

@ -15,6 +15,11 @@ en:
verification_failed: 驗證碼錯誤 verification_failed: 驗證碼錯誤
seminar: seminar:
reviewer: 審查委員
review_end_date: 審查結束日期
review_start_date: 審查開始日期
review: 審稿
blank_no_limit: 空白無限制
export_csv: 匯出CSV export_csv: 匯出CSV
recaptcha: 驗證碼 recaptcha: 驗證碼
yes_: yes_:

View File

@ -15,6 +15,11 @@ zh_tw:
verification_failed: 驗證碼錯誤 verification_failed: 驗證碼錯誤
seminar: seminar:
reviewer: 審查委員
review_end_date: 審查結束日期
review_start_date: 審查開始日期
review: 審稿
blank_no_limit: 空白無限制
export_csv: 匯出CSV export_csv: 匯出CSV
recaptcha: 驗證碼 recaptcha: 驗證碼
yes_: yes_: