add link to member's front page for index and show views

This commit is contained in:
EricTYL 2020-01-02 13:59:36 +08:00
parent adb2310745
commit f0f7eeb9c2
2 changed files with 9 additions and 3 deletions

View File

@ -2,11 +2,13 @@ class PersonalLabsController < ApplicationController
def index def index
labs = Lab.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) labs = Lab.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
lab_list = labs.collect do |lab| lab_list = labs.collect do |lab|
member = lab.member_profile
path = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#'
{ {
"year" => lab.year, "year" => lab.year,
"lab_title" => lab.lab_title, "lab_title" => lab.lab_title,
"location" => lab.location, "location" => lab.location,
"member" => (lab.member_profile.name rescue ""), "member" => "<a href='#{path}'>#{member.name}</a>",
"link_to_show" => OrbitHelper.url_to_show(lab.to_param) "link_to_show" => OrbitHelper.url_to_show(lab.to_param)
} }
end end
@ -39,6 +41,7 @@ class PersonalLabsController < ApplicationController
"extension_no", "extension_no",
"url", "url",
"note", "note",
#"owner",
"file" "file"
] ]

View File

@ -99,6 +99,9 @@ class Lab
files << "<li><a href='#{url}'' target='_blank'>#{title}</li>" files << "<li><a href='#{url}'' target='_blank'>#{title}</li>"
end end
value = files.join("") value = files.join("")
when "owner"
path = OrbitHelper.url_to_plugin_show(self.member_profile.to_param, 'member') rescue '#'
value = "<a href='#{path}'>#{self.member_profile.name}</a>"
else else
value = self.send(field) rescue "" value = self.send(field) rescue ""
end end