personal-activity/app/controllers/personal_activities_control...

59 lines
2.0 KiB
Ruby

class PersonalActivitiesController < ApplicationController
def index
activities = Activity.where(:is_hidden => false)
.order_by(:year=>'desc')
.page(OrbitHelper.params[:page_no])
.per(OrbitHelper.page_data_count)
activities_list = activities.collect do |activity|
member = activity.member_profile
path_to_member = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#'
{
'attendee' => ("<a href='#{path_to_member}'>" + member.name + "</a>"),
'activity_name' => activity.activity_name,
'activity_organizer' => activity.activity_organizer,
'activity_area' => activity.activity_area,
'activity_start_date' => activity.activity_start_date,
'activity_end_date' => activity.activity_end_date,
'year' => activity.year,
'note' => activity.note,
'link_to_show' => OrbitHelper.url_to_plugin_show(activity.to_param,'personal_activity')
}
end
# return values for template
{
'activities' => activities_list,
'extras' => {
'widget-title' => t('module_name.activity'),
'activity_name' => t('personal_activity.activity_name'),
'activity_organizer' => t('personal_activity.activity_organizer'),
'activity_area' => t('personal_activity.activity_area'),
'activity_start_date' => t('personal_activity.activity_start_date'),
'activity_end_date' => t('personal_activity.activity_end_date'),
'year' => t('personal_activity.year'),
'note' => t('personal_activity.note')
},
"total_pages" => activities.total_pages
}
end
def show
params = OrbitHelper.params
plugin = Activity.where(:is_hidden => false).find_by(uid: params[:uid])
fields_to_show = [
'attendee',
'activity_name',
'activity_organizer',
'activity_area',
'activity_start_date',
'activity_end_date',
'year',
'note'
]
{ 'plugin_datas' => plugin.get_plugin_data(fields_to_show) }
end
end