65 lines
1.9 KiB
Ruby
65 lines
1.9 KiB
Ruby
class Activity
|
|
include Mongoid::Document
|
|
include Mongoid::Timestamps
|
|
#include Mongoid::Attributes::Dynamic
|
|
#include Admin::PersonalActivitiesHelper
|
|
include OrbitModel::Status
|
|
include MemberHelper
|
|
include Slug
|
|
|
|
# Language
|
|
field :activity_name, as: :slug_title, type: String, localize: true
|
|
field :activity_organizer, type: String, localize: true
|
|
field :activity_area, type: String, localize: true
|
|
|
|
# Basic
|
|
field :year, type: String
|
|
field :activity_start_date, type: DateTime
|
|
field :activity_end_date, type: DateTime
|
|
field :note, type: String
|
|
|
|
belongs_to :member_profile
|
|
|
|
def get_plugin_data(fields_to_show)
|
|
plugin_datas = []
|
|
fields_to_show.each do |field|
|
|
plugin_data = self.get_plugin_field_data(field) rescue nil
|
|
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 'attendee'
|
|
path = OrbitHelper.url_to_plugin_show(self.member_profile.to_param, 'member') rescue '#'
|
|
value = "<a href='#{path}'>#{self.member_profile.name}</a>"
|
|
when 'activity_name'
|
|
value = self.activity_name rescue ''
|
|
when 'activity_organizer'
|
|
value = self.activity_organizer rescue ''
|
|
when 'activity_area'
|
|
value = self.activity_area rescue ''
|
|
when 'activity_start_date'
|
|
value = self.activity_start_date rescue ''
|
|
when 'activity_end_date'
|
|
value = self.activity_end_date rescue ''
|
|
when 'year'
|
|
value = self.year rescue ''
|
|
when 'note'
|
|
value = self.note rescue ''
|
|
else
|
|
value = self.send(field) rescue ''
|
|
end
|
|
|
|
{
|
|
'key' => field,
|
|
'title_class' => "activity-#{field.gsub('_','-')}-field",
|
|
'value_class' => "activity-#{field.gsub('_','-')}-value",
|
|
'title' => I18n.t('personal_activity.'+ field),
|
|
'value' => value
|
|
}
|
|
end
|
|
end
|