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


Python ManualEnrollmentAudit.retire_manual_enrollments方法代码示例

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


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

示例1: test_retirement

# 需要导入模块: from student.models import ManualEnrollmentAudit [as 别名]
# 或者: from student.models.ManualEnrollmentAudit import retire_manual_enrollments [as 别名]
 def test_retirement(self):
     """
     Tests that calling the retirement method for a specific enrollment retires
     the enrolled_email and reason columns of each row associated with that
     enrollment.
     """
     enrollment = CourseEnrollment.enroll(self.user, self.course.id)
     other_enrollment = CourseEnrollment.enroll(self.user, self.other_course.id)
     ManualEnrollmentAudit.create_manual_enrollment_audit(
         self.instructor, self.user.email, ALLOWEDTOENROLL_TO_ENROLLED,
         'manually enrolling unenrolled user', enrollment
     )
     ManualEnrollmentAudit.create_manual_enrollment_audit(
         self.instructor, self.user.email, ALLOWEDTOENROLL_TO_ENROLLED,
         'manually enrolling unenrolled user again', enrollment
     )
     ManualEnrollmentAudit.create_manual_enrollment_audit(
         self.instructor, self.user.email, ALLOWEDTOENROLL_TO_ENROLLED,
         'manually enrolling unenrolled user', other_enrollment
     )
     ManualEnrollmentAudit.create_manual_enrollment_audit(
         self.instructor, self.user.email, ALLOWEDTOENROLL_TO_ENROLLED,
         'manually enrolling unenrolled user again', other_enrollment
     )
     self.assertTrue(ManualEnrollmentAudit.objects.filter(enrollment=enrollment).exists())
     # retire the ManualEnrollmentAudit objects associated with the above enrollments
     enrollments = CourseEnrollment.objects.filter(user=self.user)
     ManualEnrollmentAudit.retire_manual_enrollments(enrollments=enrollments, retired_email="xxx")
     self.assertTrue(ManualEnrollmentAudit.objects.filter(enrollment=enrollment).exists())
     self.assertFalse(ManualEnrollmentAudit.objects.filter(enrollment=enrollment).exclude(
         enrolled_email="xxx"
     ))
     self.assertFalse(ManualEnrollmentAudit.objects.filter(enrollment=enrollment).exclude(
         reason=""
     ))
开发者ID:appsembler,项目名称:edx-platform,代码行数:37,代码来源:test_models.py

示例2: post

# 需要导入模块: from student.models import ManualEnrollmentAudit [as 别名]
# 或者: from student.models.ManualEnrollmentAudit import retire_manual_enrollments [as 别名]
    def post(self, request):
        """
        POST /api/user/v1/accounts/retire_misc/

        {
            'username': 'user_to_retire'
        }

        Retires the user with the given username in the LMS.
        """

        username = request.data['username']

        try:
            retirement = UserRetirementStatus.get_retirement_for_retirement_action(username)
            RevisionPluginRevision.retire_user(retirement.user)
            ArticleRevision.retire_user(retirement.user)
            PendingNameChange.delete_by_user_value(retirement.user, field='user')
            PasswordHistory.retire_user(retirement.user.id)
            course_enrollments = CourseEnrollment.objects.filter(user=retirement.user)
            ManualEnrollmentAudit.retire_manual_enrollments(course_enrollments, retirement.retired_email)

            CreditRequest.retire_user(retirement.original_username, retirement.retired_username)
            ApiAccessRequest.retire_user(retirement.user)
            CreditRequirementStatus.retire_user(retirement.user.username)

            # This signal allows code in higher points of LMS to retire the user as necessary
            USER_RETIRE_LMS_MISC.send(sender=self.__class__, user=retirement.user)

            # This signal allows code in higher points of LMS to unsubscribe the user
            # from various types of mailings.
            USER_RETIRE_MAILINGS.send(
                sender=self.__class__,
                email=retirement.original_email,
                new_email=retirement.retired_email,
                user=retirement.user
            )
        except UserRetirementStatus.DoesNotExist:
            return Response(status=status.HTTP_404_NOT_FOUND)
        except RetirementStateError as exc:
            return Response(text_type(exc), status=status.HTTP_400_BAD_REQUEST)
        except Exception as exc:  # pylint: disable=broad-except
            return Response(text_type(exc), status=status.HTTP_500_INTERNAL_SERVER_ERROR)

        return Response(status=status.HTTP_204_NO_CONTENT)
开发者ID:mreyk,项目名称:edx-platform,代码行数:47,代码来源:views.py


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