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


Python PaidCourseRegistration.add_to_order方法代码示例

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


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

示例1: test_reg_code_with_multiple_courses_and_checkout_scenario

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
    def test_reg_code_with_multiple_courses_and_checkout_scenario(self):
        self.add_reg_code(self.course_key)

        # Two courses in user shopping cart
        self.login_user()
        PaidCourseRegistration.add_to_order(self.cart, self.course_key)
        PaidCourseRegistration.add_to_order(self.cart, self.testing_course.id)
        self.assertEquals(self.cart.orderitem_set.count(), 2)

        resp = self.client.post(reverse('shoppingcart.views.use_code'), {'code': self.reg_code})
        self.assertEqual(resp.status_code, 200)

        resp = self.client.get(reverse('shoppingcart.views.show_cart', args=[]))
        self.assertIn('Check Out', resp.content)
        self.cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')

        resp = self.client.get(reverse('shoppingcart.views.show_receipt', args=[self.cart.id]))
        self.assertEqual(resp.status_code, 200)

        ((template, context), _) = render_mock.call_args  # pylint: disable=W0621
        self.assertEqual(template, 'shoppingcart/receipt.html')
        self.assertEqual(context['order'], self.cart)
        self.assertEqual(context['order'].total_cost, self.testing_cost)

        course_enrollment = CourseEnrollment.objects.filter(user=self.user)
        self.assertEqual(course_enrollment.count(), 2)
开发者ID:Appius,项目名称:edx-platform,代码行数:28,代码来源:test_views.py

示例2: test_clear_cart

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
 def test_clear_cart(self):
     self.login_user()
     PaidCourseRegistration.add_to_order(self.cart, self.course_key)
     CertificateItem.add_to_order(self.cart, self.verified_course_key, self.cost, 'honor')
     self.assertEquals(self.cart.orderitem_set.count(), 2)
     resp = self.client.post(reverse('shoppingcart.views.clear_cart', args=[]))
     self.assertEqual(resp.status_code, 200)
     self.assertEquals(self.cart.orderitem_set.count(), 0)
开发者ID:Appius,项目名称:edx-platform,代码行数:10,代码来源:test_views.py

示例3: add_to_cart

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
 def add_to_cart(self):
     """
     Adds content to self.user's cart
     """
     course = CourseFactory.create(org='MITx', number='999', display_name='Robot Super Course')
     CourseModeFactory.create(course_id=course.id)
     cart = Order.get_cart_for_user(self.user)
     PaidCourseRegistration.add_to_order(cart, course.id)
开发者ID:edx,项目名称:edx-platform,代码行数:10,代码来源:test_context_processor.py

示例4: test_user_cart_has_both_items

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
 def test_user_cart_has_both_items(self):
     """
     This test exists b/c having both CertificateItem and PaidCourseRegistration in an order used to break
     PaidCourseRegistration.contained_in_order
     """
     cart = Order.get_cart_for_user(self.user)
     CertificateItem.add_to_order(cart, self.course_key, self.cost, 'honor')
     PaidCourseRegistration.add_to_order(self.cart, self.course_key)
     self.assertTrue(PaidCourseRegistration.contained_in_order(cart, self.course_key))
开发者ID:alexmerser,项目名称:lms,代码行数:11,代码来源:test_models.py

示例5: test_report_csv

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
 def test_report_csv(self):
     PaidCourseRegistration.add_to_order(self.cart, self.course_id)
     self.cart.purchase()
     self.login_user()
     self.add_to_download_group(self.user)
     response = self.client.post(reverse('payment_csv_report'), {'start_date': '1970-01-01',
                                                                 'end_date': '2100-01-01'})
     self.assertEqual(response['Content-Type'], 'text/csv')
     self.assertIn(",".join(OrderItem.csv_report_header_row()), response.content)
     self.assertIn(self.CORRECT_CSV_NO_DATE, response.content)
开发者ID:dais,项目名称:edx-platform,代码行数:12,代码来源:test_views.py

示例6: change_enrollment

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
def change_enrollment(strategy, user=None, *args, **kwargs):
    """Enroll a user in a course.

    If a user entered the authentication flow when trying to enroll
    in a course, then attempt to enroll the user.
    We will try to do this if the pipeline was started with the
    querystring param `enroll_course_id`.

    In the following cases, we can't enroll the user:
        * The course does not have an honor mode.
        * The course has an honor mode with a minimum price.
        * The course is not yet open for enrollment.
        * The course does not exist.

    If we can't enroll the user now, then skip this step.
    For paid courses, users will be redirected to the payment flow
    upon completion of the authentication pipeline
    (configured using the ?next parameter to the third party auth login url).

    """
    enroll_course_id = strategy.session_get('enroll_course_id')
    if enroll_course_id:
        course_id = CourseKey.from_string(enroll_course_id)
        modes = CourseMode.modes_for_course_dict(course_id)
        # If the email opt in parameter is found, set the preference.
        email_opt_in = strategy.session_get(AUTH_EMAIL_OPT_IN_KEY)
        if email_opt_in:
            opt_in = email_opt_in.lower() == 'true'
            profile.update_email_opt_in(user.username, course_id.org, opt_in)
        if CourseMode.can_auto_enroll(course_id, modes_dict=modes):
            try:
                CourseEnrollment.enroll(user, course_id, check_access=True)
            except CourseEnrollmentException:
                pass
            except Exception as ex:
                logger.exception(ex)

        # Handle white-label courses as a special case
        # If a course is white-label, we should add it to the shopping cart.
        elif CourseMode.is_white_label(course_id, modes_dict=modes):
            try:
                cart = Order.get_cart_for_user(user)
                PaidCourseRegistration.add_to_order(cart, course_id)
            except (
                CourseDoesNotExistException,
                ItemAlreadyInCartException,
                AlreadyEnrolledInCourseException
            ):
                pass
            # It's more important to complete login than to
            # ensure that the course was added to the shopping cart.
            # Log errors, but don't stop the authentication pipeline.
            except Exception as ex:
                logger.exception(ex)
开发者ID:JacobWay,项目名称:edx-platform,代码行数:56,代码来源:pipeline.py

示例7: test_report_csv_too_long

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
    def test_report_csv_too_long(self):
        PaidCourseRegistration.add_to_order(self.cart, self.course_id)
        self.cart.purchase()
        self.login_user()
        self.add_to_download_group(self.user)
        response = self.client.post(reverse('payment_csv_report'), {'start_date': '1970-01-01',
                                                                    'end_date': '2100-01-01'})

        ((template, context), unused_kwargs) = render_mock.call_args
        self.assertEqual(template, 'shoppingcart/download_report.html')
        self.assertTrue(context['total_count_error'])
        self.assertFalse(context['date_fmt_error'])
        self.assertIn(_("There are too many results in your report.") + " (>0)", response.content)
开发者ID:dais,项目名称:edx-platform,代码行数:15,代码来源:test_views.py

示例8: test_already_in_cart

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
    def test_already_in_cart(self):
        """
        This makes sure if a user has this course in the cart, that the expected message
        appears
        """
        self.setup_user()
        cart = Order.get_cart_for_user(self.user)
        PaidCourseRegistration.add_to_order(cart, self.course.id)

        url = reverse('about_course', args=[self.course.id.to_deprecated_string()])
        resp = self.client.get(url)
        self.assertEqual(resp.status_code, 200)
        self.assertIn("This course is in your", resp.content)
        self.assertNotIn("Add buyme to Cart ($10)", resp.content)
开发者ID:Cgruppo,项目名称:edx-platform,代码行数:16,代码来源:test_about.py

示例9: test_report_csv_itemized

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
 def test_report_csv_itemized(self):
     report_type = 'itemized_purchase_report'
     start_date = '1970-01-01'
     end_date = '2100-01-01'
     PaidCourseRegistration.add_to_order(self.cart, self.course_key)
     self.cart.purchase()
     self.login_user()
     self.add_to_download_group(self.user)
     response = self.client.post(reverse('payment_csv_report'), {'start_date': start_date,
                                                                 'end_date': end_date,
                                                                 'requested_report': report_type})
     self.assertEqual(response['Content-Type'], 'text/csv')
     report = initialize_report(report_type, start_date, end_date)
     self.assertIn(",".join(report.header()), response.content)
     self.assertIn(self.CORRECT_CSV_NO_DATE_ITEMIZED_PURCHASE, response.content)
开发者ID:Appius,项目名称:edx-platform,代码行数:17,代码来源:test_views.py

示例10: add_course_to_user_cart

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
 def add_course_to_user_cart(self):
     """
     adding course to user cart
     """
     self.login_user()
     reg_item = PaidCourseRegistration.add_to_order(self.cart, self.course_key)
     return reg_item
开发者ID:Appius,项目名称:edx-platform,代码行数:9,代码来源:test_views.py

示例11: test_show_receipt_404s

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
    def test_show_receipt_404s(self):
        PaidCourseRegistration.add_to_order(self.cart, self.course_key)
        CertificateItem.add_to_order(self.cart, self.verified_course_key, self.cost, 'honor')
        self.cart.purchase()

        user2 = UserFactory.create()
        cart2 = Order.get_cart_for_user(user2)
        PaidCourseRegistration.add_to_order(cart2, self.course_key)
        cart2.purchase()

        self.login_user()
        resp = self.client.get(reverse('shoppingcart.views.show_receipt', args=[cart2.id]))
        self.assertEqual(resp.status_code, 404)

        resp2 = self.client.get(reverse('shoppingcart.views.show_receipt', args=[1000]))
        self.assertEqual(resp2.status_code, 404)
开发者ID:Appius,项目名称:edx-platform,代码行数:18,代码来源:test_views.py

示例12: test_student_paid_course_enrollment_report

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
    def test_student_paid_course_enrollment_report(self):
        """
        test to check the paid user enrollment csv report status
        and enrollment source.
        """
        student = UserFactory()
        student_cart = Order.get_cart_for_user(student)
        PaidCourseRegistration.add_to_order(student_cart, self.course.id)
        student_cart.purchase()

        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')
        self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
        self._verify_cell_data_in_csv(student.username, 'Enrollment Source', 'Credit Card - Individual')
        self._verify_cell_data_in_csv(student.username, 'Payment Status', 'purchased')
开发者ID:ISCLC,项目名称:edx-platform-for-isc,代码行数:18,代码来源:test_tasks_helper.py

示例13: test_student_used_enrollment_code_for_course_enrollment

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
    def test_student_used_enrollment_code_for_course_enrollment(self):
        """
        test to check the user enrollment source and payment status in the
        enrollment detailed report
        """
        student = UserFactory()
        self.client.login(username=student.username, password='test')
        student_cart = Order.get_cart_for_user(student)
        paid_course_reg_item = PaidCourseRegistration.add_to_order(student_cart, self.course.id)
        # update the quantity of the cart item paid_course_reg_item
        resp = self.client.post(reverse('shoppingcart.views.update_user_cart'),
                                {'ItemId': paid_course_reg_item.id, 'qty': '4'})
        self.assertEqual(resp.status_code, 200)
        student_cart.purchase()

        course_reg_codes = CourseRegistrationCode.objects.filter(order=student_cart)
        redeem_url = reverse('register_code_redemption', args=[course_reg_codes[0].code])
        response = self.client.get(redeem_url)
        self.assertEquals(response.status_code, 200)
        # check button text
        self.assertTrue('Activate Course Enrollment' in response.content)

        response = self.client.post(redeem_url)
        self.assertEquals(response.status_code, 200)

        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')
        self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
        self._verify_cell_data_in_csv(student.username, 'Enrollment Source', 'Used Registration Code')
        self._verify_cell_data_in_csv(student.username, 'Payment Status', 'purchased')
开发者ID:ISCLC,项目名称:edx-platform-for-isc,代码行数:33,代码来源:test_tasks_helper.py

示例14: test_report_csv_itemized

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
 def test_report_csv_itemized(self):
     report_type = "itemized_purchase_report"
     start_date = "1970-01-01"
     end_date = "2100-01-01"
     PaidCourseRegistration.add_to_order(self.cart, self.course_id)
     self.cart.purchase()
     self.login_user()
     self.add_to_download_group(self.user)
     response = self.client.post(
         reverse("payment_csv_report"),
         {"start_date": start_date, "end_date": end_date, "requested_report": report_type},
     )
     self.assertEqual(response["Content-Type"], "text/csv")
     report = initialize_report(report_type, start_date, end_date)
     self.assertIn(",".join(report.header()), response.content)
     self.assertIn(self.CORRECT_CSV_NO_DATE_ITEMIZED_PURCHASE, response.content)
开发者ID:jlblancom,项目名称:edx-platform,代码行数:18,代码来源:test_views.py

示例15: test_purchased_callback

# 需要导入模块: from shoppingcart.models import PaidCourseRegistration [as 别名]
# 或者: from shoppingcart.models.PaidCourseRegistration import add_to_order [as 别名]
 def test_purchased_callback(self):
     reg1 = PaidCourseRegistration.add_to_order(self.cart, self.course_key)
     self.cart.purchase()
     self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course_key))
     reg1 = PaidCourseRegistration.objects.get(id=reg1.id)  # reload from DB to get side-effect
     self.assertEqual(reg1.status, "purchased")
     self.assertIsNotNone(reg1.course_enrollment)
     self.assertEqual(reg1.course_enrollment.id, CourseEnrollment.objects.get(user=self.user, course_id=self.course_key).id)
开发者ID:alexmerser,项目名称:lms,代码行数:10,代码来源:test_models.py


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