48 lines
1.0 KiB
Ruby
48 lines
1.0 KiB
Ruby
class Experience
|
|
include Mongoid::Document
|
|
include Mongoid::Timestamps
|
|
include OrbitModel::Status
|
|
include Slug
|
|
|
|
field :organizationt_title, localize: true
|
|
field :department, localize: true
|
|
field :job_title, localize: true
|
|
|
|
belongs_to :experience_type
|
|
belongs_to :member_profile
|
|
|
|
field :language
|
|
field :start_date , :type => Date
|
|
field :end_date , :type => Date
|
|
field :keywords
|
|
field :url
|
|
field :note
|
|
field :rss2_id
|
|
field :create_user_id, :type => BSON::ObjectId
|
|
field :update_user_id, :type => BSON::ObjectId
|
|
|
|
paginates_per 10
|
|
|
|
before_validation :add_http
|
|
|
|
def duration
|
|
if !self.start_date.nil? or !self.end_date.nil?
|
|
self.start_date.strftime('%Y.%m')+' ~ '+self.end_date.strftime('%Y.%m')
|
|
else
|
|
""
|
|
end
|
|
end
|
|
|
|
def slug_title
|
|
[self.organizationt_title,self.department,self.job_title].join(' ')
|
|
end
|
|
|
|
protected
|
|
|
|
def add_http
|
|
unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//]
|
|
self.url = 'http://' + self.url
|
|
end
|
|
end
|
|
|
|
end |