本文整理匯總了Python中student.roles.CourseInstructorRole.has_user方法的典型用法代碼示例。如果您正苦於以下問題:Python CourseInstructorRole.has_user方法的具體用法?Python CourseInstructorRole.has_user怎麽用?Python CourseInstructorRole.has_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類student.roles.CourseInstructorRole
的用法示例。
在下文中一共展示了CourseInstructorRole.has_user方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: try_remove_instructor
# 需要導入模塊: from student.roles import CourseInstructorRole [as 別名]
# 或者: from student.roles.CourseInstructorRole import has_user [as 別名]
def try_remove_instructor(request, locator, user):
# remove all roles in this course from this user: but fail if the user
# is the last instructor in the course team
instructors = CourseInstructorRole(locator)
if instructors.has_user(user):
if instructors.users_with_role().count() == 1:
msg = {"error":_("You may not remove the last instructor from a course")}
raise CannotOrphanCourse(msg)
else:
auth.remove_users(request.user, instructors, user)