Merge branch 'master' into 'master'

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

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

See merge request !1
This commit is contained in:
EricTYL 2020-01-02 17:05:34 +08:00
commit bf2b6b2d32
2 changed files with 8 additions and 3 deletions

View File

@ -2,12 +2,14 @@ class PersonalCoursesController < ApplicationController
def index def index
courses = Course.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) 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| courses_list = courses.collect do |course|
member = course.member_profile
path = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#'
{ {
"year" => course.year, "year" => course.year,
"title" => course.title, "title" => course.title,
"category" => (course.course_category.title rescue ""), "category" => (course.course_category.title rescue ""),
"semester" => (course.course_semester.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) "link_to_show" => OrbitHelper.url_to_show(course.to_param)
} }
end end

View File

@ -108,6 +108,9 @@ class Course
end end
end end
value = files.join("") 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 else
value = self.send(field) rescue "" value = self.send(field) rescue ""
end end