2014-07-02 03:54:14 +00:00
|
|
|
class Diploma
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
include OrbitModel::Status
|
|
|
|
include Slug
|
|
|
|
|
|
|
|
field :school_name, localize: true
|
|
|
|
field :country, localize: true
|
|
|
|
field :department, localize: true
|
|
|
|
field :degree, localize: true
|
|
|
|
|
|
|
|
field :language
|
|
|
|
field :keywords
|
|
|
|
field :start_date , :type => Date
|
|
|
|
field :end_date , :type => Date
|
|
|
|
field :url
|
|
|
|
field :note
|
2014-07-14 13:27:59 +00:00
|
|
|
field :rss2_id
|
2014-07-02 03:54:14 +00:00
|
|
|
field :create_user_id, :type => BSON::ObjectId
|
|
|
|
field :update_user_id, :type => BSON::ObjectId
|
|
|
|
|
|
|
|
belongs_to :member_profile
|
|
|
|
|
|
|
|
paginates_per 10
|
|
|
|
|
|
|
|
before_validation :add_http
|
|
|
|
|
|
|
|
def duration
|
2014-07-15 07:34:51 +00:00
|
|
|
if !self.start_date.nil? or !self.end_date.nil?
|
|
|
|
(self.start_date.strftime('%Y.%m') rescue "")+' ~ '+(self.end_date.strftime('%Y.%m') rescue "")
|
|
|
|
else
|
|
|
|
""
|
|
|
|
end
|
2014-07-02 03:54:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def slug_title
|
|
|
|
self.school_name+' '+self.department+' '+self.degree
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def add_http
|
|
|
|
unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//]
|
|
|
|
self.url = 'http://' + self.url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|