当前位置: 首页>>代码示例>>Python>>正文


Python CourseStaffRole.has_user方法代码示例

本文整理汇总了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))
开发者ID:AdityaKashyap,项目名称:edx-platform,代码行数:14,代码来源:test_roles.py

示例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)
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:20,代码来源:utils.py


注:本文中的student.roles.CourseStaffRole.has_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。