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


Python models.ManualEnrollmentAudit类代码示例

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


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

示例1: test_retirement

 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,代码行数:35,代码来源:test_models.py

示例2: test_change_enrollment

 def test_change_enrollment(self):
     self.assertIsNone(ManualEnrollmentAudit.get_manual_enrollment_by_email(self.student.email))
     response = self.client.post(self.url, data={
         'course_id': unicode(self.course.id),  # pylint: disable=no-member
         'old_mode': CourseMode.AUDIT,
         'new_mode': CourseMode.VERIFIED,
         'reason': 'Financial Assistance'
     })
     self.assertEqual(response.status_code, 200)
     self.assertIsNotNone(ManualEnrollmentAudit.get_manual_enrollment_by_email(self.student.email))
     self.assert_enrollment(CourseMode.VERIFIED)
开发者ID:lemontreeran,项目名称:edx-platform,代码行数:11,代码来源:test_views.py

示例3: test_get_manual_enrollment_history

 def test_get_manual_enrollment_history(self):
     ManualEnrollmentAudit.create_manual_enrollment_audit(
         self.user,
         self.student.email,
         ENROLLED_TO_ENROLLED,
         'Financial Assistance',
         CourseEnrollment.objects.get(course_id=self.course.id, user=self.student)  # pylint: disable=no-member
     )
     response = self.client.get(self.url)
     self.assertEqual(response.status_code, 200)
     self.assertDictContainsSubset({
         'enrolled_by': self.user.email,
         'reason': 'Financial Assistance',
     }, json.loads(response.content)[0]['manual_enrollment'])
开发者ID:luisvasq,项目名称:edx-platform,代码行数:14,代码来源:test_views.py

示例4: test_change_enrollment

 def test_change_enrollment(self, search_string_type):
     self.assertIsNone(ManualEnrollmentAudit.get_manual_enrollment_by_email(self.student.email))
     url = reverse(
         'support:enrollment_list',
         kwargs={'username_or_email': getattr(self.student, search_string_type)}
     )
     response = self.client.post(url, data={
         'course_id': unicode(self.course.id),  # pylint: disable=no-member
         'old_mode': CourseMode.AUDIT,
         'new_mode': CourseMode.VERIFIED,
         'reason': 'Financial Assistance'
     })
     self.assertEqual(response.status_code, 200)
     self.assertIsNotNone(ManualEnrollmentAudit.get_manual_enrollment_by_email(self.student.email))
     self.assert_enrollment(CourseMode.VERIFIED)
开发者ID:luisvasq,项目名称:edx-platform,代码行数:15,代码来源:test_views.py

示例5: get_enrollment_info

    def get_enrollment_info(self, user, course_id):
        """
        Returns the User Enrollment information.
        """
        course = get_course_by_id(course_id, depth=0)
        is_course_staff = bool(has_access(user, 'staff', course))
        manual_enrollment_reason = 'N/A'

        # check the user enrollment role
        if user.is_staff:
            platform_name = configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)
            enrollment_role = _('{platform_name} Staff').format(platform_name=platform_name)
        elif is_course_staff:
            enrollment_role = _('Course Staff')
        else:
            enrollment_role = _('Student')

        course_enrollment = CourseEnrollment.get_enrollment(user=user, course_key=course_id)

        if is_course_staff:
            enrollment_source = _('Staff')
        else:
            # get the registration_code_redemption object if exists
            registration_code_redemption = RegistrationCodeRedemption.registration_code_used_for_enrollment(
                course_enrollment)
            # get the paid_course registration item if exists
            paid_course_reg_item = PaidCourseRegistration.get_course_item_for_user_enrollment(
                user=user,
                course_id=course_id,
                course_enrollment=course_enrollment
            )

            # from where the user get here
            if registration_code_redemption is not None:
                enrollment_source = _('Used Registration Code')
            elif paid_course_reg_item is not None:
                enrollment_source = _('Credit Card - Individual')
            else:
                manual_enrollment = ManualEnrollmentAudit.get_manual_enrollment(course_enrollment)
                if manual_enrollment is not None:
                    enrollment_source = _(
                        'manually enrolled by username: {username}'
                    ).format(username=manual_enrollment.enrolled_by.username)

                    manual_enrollment_reason = manual_enrollment.reason
                else:
                    enrollment_source = _('Manually Enrolled')

        enrollment_date = course_enrollment.created.strftime("%B %d, %Y")
        currently_enrolled = course_enrollment.is_active

        course_enrollment_data = collections.OrderedDict()
        course_enrollment_data['Enrollment Date'] = enrollment_date
        course_enrollment_data['Currently Enrolled'] = currently_enrolled
        course_enrollment_data['Enrollment Source'] = enrollment_source
        course_enrollment_data['Manual (Un)Enrollment Reason'] = manual_enrollment_reason
        course_enrollment_data['Enrollment Role'] = enrollment_role
        return course_enrollment_data
开发者ID:Colin-Fredericks,项目名称:edx-platform,代码行数:58,代码来源:paidcourse_enrollment_report.py

示例6: post

    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,代码行数:45,代码来源:views.py

示例7: test_change_enrollment_bad_data

 def test_change_enrollment_bad_data(self, data, error_message):
     # `self` isn't available from within the DDT declaration, so
     # assign the course ID here
     if 'course_id' in data and data['course_id'] is None:
         data['course_id'] = unicode(self.course.id)  # pylint: disable=no-member
     response = self.client.post(self.url, data)
     self.assertEqual(response.status_code, 400)
     self.assertIsNotNone(re.match(error_message, response.content))
     self.assert_enrollment(CourseMode.AUDIT)
     self.assertIsNone(ManualEnrollmentAudit.get_manual_enrollment_by_email(self.student.email))
开发者ID:luisvasq,项目名称:edx-platform,代码行数:10,代码来源:test_views.py

示例8: assert_update_enrollment

 def assert_update_enrollment(self, search_string_type, new_mode):
     """ Dry method to update the enrollment and assert response."""
     self.assertIsNone(ManualEnrollmentAudit.get_manual_enrollment_by_email(self.student.email))
     url = reverse(
         'support:enrollment_list',
         kwargs={'username_or_email': getattr(self.student, search_string_type)}
     )
     response = self.client.post(url, data={
         'course_id': unicode(self.course.id),  # pylint: disable=no-member
         'old_mode': CourseMode.AUDIT,
         'new_mode': new_mode,
         'reason': 'Financial Assistance'
     })
     # Enrollment cannot be changed to credit mode.
     if new_mode == CourseMode.CREDIT_MODE:
         self.assertEqual(response.status_code, 400)
     else:
         self.assertEqual(response.status_code, 200)
         self.assertIsNotNone(ManualEnrollmentAudit.get_manual_enrollment_by_email(self.student.email))
         self.assert_enrollment(new_mode)
开发者ID:luisvasq,项目名称:edx-platform,代码行数:20,代码来源:test_views.py

示例9: test_student_manually_enrolled_in_detailed_enrollment_source

    def test_student_manually_enrolled_in_detailed_enrollment_source(self):
        """
        test to check the manually enrolled user enrollment report status
        and enrollment source.
        """
        student = UserFactory()
        enrollment = CourseEnrollment.enroll(student, self.course.id)
        ManualEnrollmentAudit.create_manual_enrollment_audit(
            self.instructor, student.email, ALLOWEDTOENROLL_TO_ENROLLED,
            'manually enrolling unenrolled user', enrollment
        )

        task_input = {'features': []}
        with patch('instructor_task.tasks_helper._get_current_task'):
            result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report')

        enrollment_source = u'manually enrolled by user_id {user_id}, enrollment state transition: {transition}'.format(
            user_id=self.instructor.id, transition=ALLOWEDTOENROLL_TO_ENROLLED)  # pylint: disable=no-member
        self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
        self._verify_cell_data_in_csv(student.username, 'Enrollment Source', enrollment_source)
        self._verify_cell_data_in_csv(student.username, 'Payment Status', 'TBD')
开发者ID:inares,项目名称:edx-platform,代码行数:21,代码来源:test_tasks_helper.py

示例10: manual_enrollment_data

    def manual_enrollment_data(enrollment_data, course_key):
        """
        Returns serialized information about the manual enrollment
        belonging to this enrollment, if it exists.

        Args:
          enrollment_data (dict): Representation of a single course enrollment.
          course_key (CourseKey): The course for this enrollment.

        Returns:
          None: If no manual enrollment change has been made.
          dict: Serialization of the latest manual enrollment change.
        """
        user = User.objects.get(username=enrollment_data['user'])
        enrollment = CourseEnrollment.get_enrollment(user, course_key)
        manual_enrollment_audit = ManualEnrollmentAudit.get_manual_enrollment(enrollment)
        if manual_enrollment_audit is None:
            return {}
        return ManualEnrollmentSerializer(instance=manual_enrollment_audit).data
开发者ID:10clouds,项目名称:edx-platform,代码行数:19,代码来源:enrollments.py

示例11: post

 def post(self, request, username_or_email):
     """Allows support staff to alter a user's enrollment."""
     try:
         user = User.objects.get(Q(username=username_or_email) | Q(email=username_or_email))
         course_id = request.data['course_id']
         course_key = CourseKey.from_string(course_id)
         old_mode = request.data['old_mode']
         new_mode = request.data['new_mode']
         reason = request.data['reason']
         enrollment = CourseEnrollment.objects.get(user=user, course_id=course_key)
         if enrollment.mode != old_mode:
             return HttpResponseBadRequest(u'User {username} is not enrolled with mode {old_mode}.'.format(
                 username=user.username,
                 old_mode=old_mode
             ))
         if new_mode == CourseMode.CREDIT_MODE:
             return HttpResponseBadRequest(u'Enrollment cannot be changed to credit mode.')
     except KeyError as err:
         return HttpResponseBadRequest(u'The field {} is required.'.format(text_type(err)))
     except InvalidKeyError:
         return HttpResponseBadRequest(u'Could not parse course key.')
     except (CourseEnrollment.DoesNotExist, User.DoesNotExist):
         return HttpResponseBadRequest(
             u'Could not find enrollment for user {username} in course {course}.'.format(
                 username=username_or_email,
                 course=unicode(course_key)
             )
         )
     try:
         # Wrapped in a transaction so that we can be sure the
         # ManualEnrollmentAudit record is always created correctly.
         with transaction.atomic():
             update_enrollment(user.username, course_id, mode=new_mode, include_expired=True)
             manual_enrollment = ManualEnrollmentAudit.create_manual_enrollment_audit(
                 request.user,
                 enrollment.user.email,
                 ENROLLED_TO_ENROLLED,
                 reason=reason,
                 enrollment=enrollment
             )
             return JsonResponse(ManualEnrollmentSerializer(instance=manual_enrollment).data)
     except CourseModeNotFoundError as err:
         return HttpResponseBadRequest(text_type(err))
开发者ID:cmscom,项目名称:edx-platform,代码行数:43,代码来源:enrollments.py

示例12: test_update_enrollments_with_expired_mode

 def test_update_enrollments_with_expired_mode(self, search_string_type):
     """ Verify that enrollment can be updated to verified mode. """
     self.set_course_end_date_and_expiry()
     self.assertIsNone(ManualEnrollmentAudit.get_manual_enrollment_by_email(self.student.email))
     self.assert_update_enrollment(search_string_type, CourseMode.VERIFIED)
开发者ID:luisvasq,项目名称:edx-platform,代码行数:5,代码来源:test_views.py


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