From 09f3131eae7c92185c68a694ec15a79774906f9e Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Thu, 2 Jan 2020 11:28:43 +0800 Subject: [PATCH] add link to member's front page for both index and show views --- app/controllers/personal_courses_controller.rb | 6 ++++-- app/models/course.rb | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/personal_courses_controller.rb b/app/controllers/personal_courses_controller.rb index 3376472..ab61351 100644 --- a/app/controllers/personal_courses_controller.rb +++ b/app/controllers/personal_courses_controller.rb @@ -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" => ("" + member.name + ""), "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 \ No newline at end of file +end diff --git a/app/models/course.rb b/app/models/course.rb index 3a71050..42c7954 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -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 = "#{self.member_profile.name}" else value = self.send(field) rescue "" end @@ -123,4 +126,4 @@ class Course } end -end \ No newline at end of file +end