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


Python CourseEnrollmentAllowed.for_user方法代码示例

本文整理汇总了Python中student.models.CourseEnrollmentAllowed.for_user方法的典型用法代码示例。如果您正苦于以下问题:Python CourseEnrollmentAllowed.for_user方法的具体用法?Python CourseEnrollmentAllowed.for_user怎么用?Python CourseEnrollmentAllowed.for_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在student.models.CourseEnrollmentAllowed的用法示例。


在下文中一共展示了CourseEnrollmentAllowed.for_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from student.models import CourseEnrollmentAllowed [as 别名]
# 或者: from student.models.CourseEnrollmentAllowed import for_user [as 别名]
    def __init__(self, course_id, email):
        # N.B. retired users are not a concern here because they should be
        # handled at a higher level (i.e. in enroll_email).  Besides, this
        # class creates readonly objects.
        exists_user = User.objects.filter(email=email).exists()
        if exists_user:
            user = User.objects.get(email=email)
            mode, is_active = CourseEnrollment.enrollment_mode_for_user(user, course_id)
            # is_active is `None` if the user is not enrolled in the course
            exists_ce = is_active is not None and is_active
            full_name = user.profile.name
            ceas = CourseEnrollmentAllowed.for_user(user).filter(course_id=course_id).all()
        else:
            mode = None
            exists_ce = False
            full_name = None
            ceas = CourseEnrollmentAllowed.objects.filter(email=email, course_id=course_id).all()
        exists_allowed = ceas.exists()
        state_auto_enroll = exists_allowed and ceas[0].auto_enroll

        self.user = exists_user
        self.enrollment = exists_ce
        self.allowed = exists_allowed
        self.auto_enroll = bool(state_auto_enroll)
        self.full_name = full_name
        self.mode = mode
开发者ID:jolyonb,项目名称:edx-platform,代码行数:28,代码来源:enrollment.py


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