2014-07-02 06:25:50 +00:00
|
|
|
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
|
2014-07-14 13:28:55 +00:00
|
|
|
field :rss2_id
|
2014-07-02 06:25:50 +00:00
|
|
|
field :create_user_id, :type => BSON::ObjectId
|
|
|
|
field :update_user_id, :type => BSON::ObjectId
|
|
|
|
|
|
|
|
paginates_per 10
|
|
|
|
|
|
|
|
before_validation :add_http
|
|
|
|
|
|
|
|
def duration
|
2014-07-15 09:23:50 +00:00
|
|
|
if !self.start_date.nil? or !self.end_date.nil?
|
|
|
|
self.start_date.strftime('%Y.%m')+' ~ '+self.end_date.strftime('%Y.%m')
|
|
|
|
else
|
|
|
|
""
|
|
|
|
end
|
2014-07-02 06:25:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def slug_title
|
2014-07-30 06:19:50 +00:00
|
|
|
[self.organizationt_title,self.department,self.job_title].join(' ')
|
2014-07-02 06:25:50 +00:00
|
|
|
end
|
|
|
|
|
2014-08-01 11:47:16 +00:00
|
|
|
def get_plugin_data(fields_to_show)
|
|
|
|
plugin_datas = []
|
|
|
|
fields_to_show.each do |field|
|
|
|
|
plugin_data = self.get_plugin_field_data(field)
|
|
|
|
next if plugin_data.blank? or plugin_data['value'].blank?
|
|
|
|
plugin_datas << plugin_data
|
|
|
|
end
|
|
|
|
plugin_datas
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_plugin_field_data(field)
|
|
|
|
case field
|
|
|
|
when "language"
|
|
|
|
value = I18n.t(self.language) rescue ""
|
|
|
|
when "experience_type"
|
|
|
|
value = self.experience_type.title rescue ""
|
|
|
|
else
|
|
|
|
value = self.send(field) rescue ""
|
|
|
|
end
|
|
|
|
|
|
|
|
value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value
|
|
|
|
|
|
|
|
{
|
|
|
|
"key"=>field,
|
|
|
|
"title_class"=>"experience-#{field.gsub('_','-')}-field",
|
|
|
|
"value_class"=>"experience-#{field.gsub('_','-')}-value",
|
|
|
|
"title"=>I18n.t('personal_experience.'+field),
|
|
|
|
"value"=>value
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2014-07-02 06:25:50 +00:00
|
|
|
protected
|
|
|
|
|
|
|
|
def add_http
|
|
|
|
unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//]
|
|
|
|
self.url = 'http://' + self.url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|