|
|
|
@ -131,9 +131,18 @@ class CoursesService
|
|
|
|
|
#显示课程通知(包括评论) 需验证权限
|
|
|
|
|
def show_course_news params,current_user
|
|
|
|
|
@news = News.find(params[:id])
|
|
|
|
|
@course = @news.course
|
|
|
|
|
if @course
|
|
|
|
|
if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course)))
|
|
|
|
|
raise '403'
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
raise 'news in unknown course'
|
|
|
|
|
end
|
|
|
|
|
@comments = @news.comments
|
|
|
|
|
@comments.reverse! if current_user.wants_comments_in_reverse_order?
|
|
|
|
|
{:news => @news,:comments => @comments}
|
|
|
|
|
|
|
|
|
|
#comments = []
|
|
|
|
|
#@comments.each do |comment|
|
|
|
|
|
# comments << {:author_id => comment.author_id,:author_name => comment.author.name,:commont_content => comment.comments,:time => format_time(comment.created_on)}
|
|
|
|
|