修改课程成员列表接口,增加权限判断
This commit is contained in:
parent
efa08adf4e
commit
95d8c1a09d
|
@ -75,7 +75,7 @@ module Mobile
|
||||||
end
|
end
|
||||||
get 'teachers' do
|
get 'teachers' do
|
||||||
cs = CoursesService.new
|
cs = CoursesService.new
|
||||||
teachers = cs.course_teacher_or_student_list({role: 1}, params[:course_id])
|
teachers = cs.course_teacher_or_student_list({role: 1}, params[:course_id],current_user)
|
||||||
{status: 0, data: teachers}
|
{status: 0, data: teachers}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ module Mobile
|
||||||
end
|
end
|
||||||
get 'teachers' do
|
get 'teachers' do
|
||||||
cs = CoursesService.new
|
cs = CoursesService.new
|
||||||
teachers = cs.course_teacher_or_student_list({role: 2}, params[:course_id])
|
teachers = cs.course_teacher_or_student_list({role: 2}, params[:course_id],current_user)
|
||||||
{status: 0, data: teachers}
|
{status: 0, data: teachers}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -245,9 +245,14 @@ class CoursesController < ApplicationController
|
||||||
#@members = @course.member_principals.includes(:roles, :principal).all.sort
|
#@members = @course.member_principals.includes(:roles, :principal).all.sort
|
||||||
end
|
end
|
||||||
cs = CoursesService.new
|
cs = CoursesService.new
|
||||||
@members = cs.course_teacher_or_student_list(params,@course)
|
@members = cs.course_teacher_or_student_list(params,@course,User.current)
|
||||||
@members = paginateHelper @members
|
@members = paginateHelper @members
|
||||||
render :layout => 'base_courses'
|
render :layout => 'base_courses'
|
||||||
|
|
||||||
|
rescue Exception => e
|
||||||
|
if e.message == '403'
|
||||||
|
render_403
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#判断指定用户是否为课程教师
|
#判断指定用户是否为课程教师
|
||||||
|
|
|
@ -49,19 +49,27 @@ class CoursesService
|
||||||
end
|
end
|
||||||
|
|
||||||
#课程老师或课程学生列表
|
#课程老师或课程学生列表
|
||||||
def course_teacher_or_student_list params,course
|
def course_teacher_or_student_list params,course,current_user
|
||||||
@teachers= searchTeacherAndAssistant(course)
|
if course.is_a?(Course)
|
||||||
|
c = course
|
||||||
|
else
|
||||||
|
c = Course.find(course)
|
||||||
|
end
|
||||||
|
if !(current_user.admin? || c.is_public == 1 || (c.is_public == 0 && current_user.member_of_course?(c)))
|
||||||
|
raise '403'
|
||||||
|
end
|
||||||
|
@teachers= searchTeacherAndAssistant(c)
|
||||||
#@canShowCode = isCourseTeacher(User.current.id,course) && params[:role] != '1'
|
#@canShowCode = isCourseTeacher(User.current.id,course) && params[:role] != '1'
|
||||||
case params[:role]
|
case params[:role]
|
||||||
when '1'
|
when '1'
|
||||||
#@subPage_title = l :label_teacher_list
|
#@subPage_title = l :label_teacher_list
|
||||||
@members = searchTeacherAndAssistant(course)
|
@members = searchTeacherAndAssistant(c)
|
||||||
when '2'
|
when '2'
|
||||||
#@subPage_title = l :label_student_list
|
#@subPage_title = l :label_student_list
|
||||||
@members = searchStudent(course)
|
@members = searchStudent(c)
|
||||||
else
|
else
|
||||||
#@subPage_title = ''
|
#@subPage_title = ''
|
||||||
@members = @course.member_principals.includes(:roles, :principal).all.sort
|
@members = c.member_principals.includes(:roles, :principal).all.sort
|
||||||
end
|
end
|
||||||
@members
|
@members
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue