59 lines
2.2 KiB
Ruby
59 lines
2.2 KiB
Ruby
class PersonalVolunteersController < ApplicationController
|
|
def index
|
|
volunteer_services = VolunteerService.where(:is_hidden => false)
|
|
.order_by(:year=>'desc')
|
|
.page(OrbitHelper.params[:page_no])
|
|
.per(OrbitHelper.page_data_count)
|
|
|
|
volunteer_services_list = volunteer_services.collect do |volunteer_service|
|
|
member = volunteer_service.member_profile
|
|
path_to_member = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#'
|
|
|
|
{
|
|
'attendee' => ("<a href='#{path_to_member}'>" + member.name + "</a>"),
|
|
'volunteer_name' => volunteer_service.volunteer_name,
|
|
'volunteer_organizer' => volunteer_service.volunteer_organizer,
|
|
'volunteer_area' => volunteer_service.volunteer_area,
|
|
'volunteer_start_date' => volunteer_service.volunteer_start_date,
|
|
'volunteer_end_date' => volunteer_service.volunteer_end_date,
|
|
'year' => volunteer_service.year,
|
|
'note' => volunteer_service.note,
|
|
'link_to_show' => OrbitHelper.url_to_plugin_show(volunteer_service.to_param,'personal_volunteer')
|
|
}
|
|
end
|
|
|
|
# return values for template
|
|
{
|
|
'volunteer_services' => volunteer_services_list,
|
|
'extras' => {
|
|
'widget-title' => t('module_name.personal_volunteer'),
|
|
'volunteer_name' => t('personal_volunteer.volunteer_name'),
|
|
'volunteer_organizer' => t('personal_volunteer.volunteer_organizer'),
|
|
'volunteer_area' => t('personal_volunteer.volunteer_area'),
|
|
'volunteer_start_date' => t('personal_volunteer.volunteer_start_date'),
|
|
'volunteer_end_date' => t('personal_volunteer.volunteer_end_date'),
|
|
'year' => t('personal_volunteer.year'),
|
|
'note' => t('personal_volunteer.note')
|
|
},
|
|
"total_pages" => volunteer_services.total_pages
|
|
}
|
|
end
|
|
|
|
def show
|
|
params = OrbitHelper.params
|
|
plugin = VolunteerService.where(:is_hidden => false).find_by(uid: params[:uid])
|
|
fields_to_show = [
|
|
'attendee',
|
|
'volunteer_name',
|
|
'volunteer_organizer',
|
|
'volunteer_area',
|
|
'volunteer_start_date',
|
|
'volunteer_end_date',
|
|
'year',
|
|
'note'
|
|
]
|
|
|
|
{ 'plugin_datas' => plugin.get_plugin_data(fields_to_show) }
|
|
end
|
|
end
|