add :index and :show for template

This commit is contained in:
EricTYL 2020-02-13 15:53:53 +08:00
parent e632168326
commit 862b4bd8df
5 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,57 @@
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')
}
}
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

View File

@ -0,0 +1 @@
<%= render_view %>

View File

@ -0,0 +1 @@
<%= render_view %>

View File

@ -3,6 +3,7 @@ en:
activity: "Activity"
personal_activity: "Activity"
personal_activity:
attendee: "Attendee"
participant: "Participant"
year: "Year"
activity_name: "Activity Name"

View File

@ -15,6 +15,14 @@ Rails.application.routes.draw do
get 'download_excel'
end
end
resources :members do
collection do
scope '(:name-:uid)' do
resources :activities, :only => [:new]
end
end
end
end
end
end