本文整理汇总了Python中student.roles.CourseStaffRole.has_user方法的典型用法代码示例。如果您正苦于以下问题:Python CourseStaffRole.has_user方法的具体用法?Python CourseStaffRole.has_user怎么用?Python CourseStaffRole.has_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类student.roles.CourseStaffRole
的用法示例。
在下文中一共展示了CourseStaffRole.has_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_users_doesnt_add_duplicate_entry
# 需要导入模块: from student.roles import CourseStaffRole [as 别名]
# 或者: from student.roles.CourseStaffRole import has_user [as 别名]
def test_add_users_doesnt_add_duplicate_entry(self):
"""
Tests that calling add_users multiple times before a single call
to remove_users does not result in the user remaining in the group.
"""
role = CourseStaffRole(self.course_key)
role.add_users(self.student)
self.assertTrue(role.has_user(self.student))
# Call add_users a second time, then remove just once.
role.add_users(self.student)
role.remove_users(self.student)
self.assertFalse(role.has_user(self.student))
示例2: assign_staff_role_to_ccx
# 需要导入模块: from student.roles import CourseStaffRole [as 别名]
# 或者: from student.roles.CourseStaffRole import has_user [as 别名]
def assign_staff_role_to_ccx(ccx_locator, user, master_course_id):
"""
Check if user has ccx_coach role on master course then assign him staff role on ccx only
if role is not already assigned. Because of this coach can open dashboard from master course
as well as ccx.
:param ccx_locator: CCX key
:param user: User to whom we want to assign role.
:param master_course_id: Master course key
"""
coach_role_on_master_course = CourseCcxCoachRole(master_course_id)
# check if user has coach role on master course
if coach_role_on_master_course.has_user(user):
# Check if user has staff role on ccx.
role = CourseStaffRole(ccx_locator)
if not role.has_user(user):
# assign user the staff role on ccx
with ccx_course(ccx_locator) as course:
allow_access(course, user, "staff", send_email=False)