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


Python StudentProfileDAO.get_profile_by_user方法代码示例

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


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

示例1: get

# 需要导入模块: from models.models import StudentProfileDAO [as 别名]
# 或者: from models.models.StudentProfileDAO import get_profile_by_user [as 别名]
    def get(self):
        """Handles GET requests."""
        models.MemcacheManager.begin_readonly()
        try:
            user = self.personalize_page_and_get_user()
            if user is None:
                student = TRANSIENT_STUDENT
            else:
                student = Student.get_enrolled_student_by_user(user)
                profile = StudentProfileDAO.get_profile_by_user(user)
                self.template_value['has_global_profile'] = profile is not None
                if not student:
                    student = TRANSIENT_STUDENT

            if (student.is_transient and
                not self.app_context.get_environ()['course']['browsable']):
                self.redirect('/preview')
                return

            # If we are on this page due to visiting the course base URL
            # (and not base url plus "/course"), redirect registered students
            # to the last page they were looking at.
            last_location = self.get_redirect_location(student)
            if last_location:
                self.redirect(last_location)
                return

            tracker = self.get_progress_tracker()
            units = self.get_track_matching_student(student)
            units = filter_assessments_used_within_units(units)
            self.template_value['units'] = units
            self.template_value['show_registration_page'] = True

            if student and not student.is_transient:
                augment_assessment_units(self.get_course(), student)
                self.template_value['course_progress'] = (
                    tracker.get_course_progress(student))
            elif user:
                profile = StudentProfileDAO.get_profile_by_user_id(
                    user.user_id())
                additional_registration_fields = self.app_context.get_environ(
                    )['reg_form']['additional_registration_fields']
                if profile is not None and not additional_registration_fields:
                    self.template_value['show_registration_page'] = False
                    self.template_value['register_xsrf_token'] = (
                        XsrfTokenManager.create_xsrf_token('register-post'))

            self.template_value['transient_student'] = student.is_transient
            self.template_value['progress'] = tracker.get_unit_progress(student)
            course = self.app_context.get_environ()['course']
            set_image_or_video_exists(self.template_value, course)

            self.template_value['is_progress_recorded'] = is_progress_recorded(
                self, student)
            self.template_value['navbar'] = {'course': True}
        finally:
            models.MemcacheManager.end_readonly()
        self.render('course.html')
开发者ID:danieldalonzo,项目名称:coursebuilder-core,代码行数:60,代码来源:lessons.py


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