个人的所有课程接口、课程的所有课程接口及留言接口
This commit is contained in:
parent
226d5e9889
commit
ddba71decf
|
@ -228,4 +228,67 @@ class CoursesService
|
|||
end
|
||||
end
|
||||
|
||||
#我的课程列表
|
||||
def my_course_list params,current_user
|
||||
unless current_user.admin?
|
||||
if !current_user.active?
|
||||
raise '404' #当前账户不可访问,返回404(可视为当前用户不存在)
|
||||
end
|
||||
end
|
||||
membership = @user.coursememberships.all
|
||||
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||
|
||||
end
|
||||
|
||||
#课程作业列表
|
||||
def course_homework_list course,current_user
|
||||
if course.is_public != 0 || current_user.member_of_course?(course) || current_user.admin?
|
||||
@bids = course.homeworks.order('deadline DESC')
|
||||
else
|
||||
raise '403'
|
||||
end
|
||||
end
|
||||
|
||||
#obj 回复所属父留言的留言对象
|
||||
def create_reply params,obj
|
||||
parent_id = params[:reference_id]
|
||||
author_id = User.current.id
|
||||
reply_user_id = params[:reference_user_id]
|
||||
reply_id = params[:reference_message_id] # 暂时不实现
|
||||
content = params[:user_notes]
|
||||
@show_name = params[:show_name] == "true"
|
||||
options = {:user_id => author_id,
|
||||
:status => true,
|
||||
:m_parent_id => parent_id,
|
||||
:m_reply_id => reply_id,
|
||||
:reply_id => reply_user_id,
|
||||
:notes => content,
|
||||
:is_readed => false}
|
||||
@jfm = add_reply_adapter options,obj
|
||||
[@show_name,@jfm]
|
||||
end
|
||||
|
||||
def add_reply_adapter options,obj
|
||||
#添加对课程留言的支持
|
||||
#留言回复应该不关系其所属的Class,而关心的是其所属的父留言
|
||||
#obj = obj_distinguish_url_origin || User.find_by_id(2)
|
||||
if obj.kind_of? User
|
||||
obj.add_jour(nil, nil, nil, options)
|
||||
elsif obj.kind_of? Project
|
||||
Project.add_new_jour(nil, nil, obj.id, options)
|
||||
elsif obj.kind_of? Course
|
||||
Course.add_new_jour(nil, nil, obj.id, options)
|
||||
elsif obj.kind_of? Bid
|
||||
obj.add_jour(nil, nil, nil, options)
|
||||
elsif obj.kind_of? Contest
|
||||
obj.add_jour(nil, nil, obj.id, options) #new added
|
||||
elsif obj.kind_of? Softapplication
|
||||
obj.add_jour(nil, nil, obj.id, options) #new added
|
||||
elsif obj.kind_of? HomeworkAttach
|
||||
obj.add_jour(nil, nil, obj.id, options) #new added
|
||||
else
|
||||
raise "create reply obj unknow type.#{obj.class}"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue