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

This commit is contained in:
EricTYL 2020-01-02 11:28:43 +08:00
parent 7771a2e6a6
commit 09f3131eae
2 changed files with 8 additions and 3 deletions

View File

@ -2,12 +2,14 @@ class PersonalCoursesController < ApplicationController
def index
courses = Course.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
courses_list = courses.collect do |course|
member = course.member_profile
path = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#'
{
"year" => course.year,
"title" => course.title,
"category" => (course.course_category.title rescue ""),
"semester" => (course.course_semester.title rescue ""),
"authors" => (course.member_profile.name rescue ""),
"authors" => ("<a href='#{path}'>" + member.name + "</a>"),
"link_to_show" => OrbitHelper.url_to_show(course.to_param)
}
end
@ -45,4 +47,4 @@ class PersonalCoursesController < ApplicationController
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
end
end
end

View File

@ -108,6 +108,9 @@ class Course
end
end
value = files.join("")
when "authors"
path = OrbitHelper.url_to_plugin_show(self.member_profile.to_param, 'member') rescue '#'
value = "<a href='#{path}'>#{self.member_profile.name}</a>"
else
value = self.send(field) rescue ""
end
@ -123,4 +126,4 @@ class Course
}
end
end
end