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


Python models.PaidCourseRegistration类代码示例

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


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

示例1: test_reg_code_with_multiple_courses_and_checkout_scenario

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

示例2: add_to_cart

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

示例3: test_clear_cart

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

示例4: test_user_cart_has_both_items

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

示例5: test_report_csv

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

示例6: change_enrollment

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

示例7: test_add_to_order

    def test_add_to_order(self):
        reg1 = PaidCourseRegistration.add_to_order(self.cart, self.course_id)

        self.assertEqual(reg1.unit_cost, self.cost)
        self.assertEqual(reg1.line_cost, self.cost)
        self.assertEqual(reg1.unit_cost, self.course_mode.min_price)
        self.assertEqual(reg1.mode, "honor")
        self.assertEqual(reg1.user, self.user)
        self.assertEqual(reg1.status, "cart")
        self.assertTrue(PaidCourseRegistration.part_of_order(self.cart, self.course_id))
        self.assertFalse(PaidCourseRegistration.part_of_order(self.cart, self.course_id + "abcd"))
        self.assertEqual(self.cart.total_cost, self.cost)
开发者ID:obenseven,项目名称:edx-platform,代码行数:12,代码来源:test_models.py

示例8: test_report_csv_too_long

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

示例9: test_add_to_order

    def test_add_to_order(self):
        reg1 = PaidCourseRegistration.add_to_order(self.cart, self.course_key)

        self.assertEqual(reg1.unit_cost, self.cost)
        self.assertEqual(reg1.line_cost, self.cost)
        self.assertEqual(reg1.unit_cost, self.course_mode.min_price)
        self.assertEqual(reg1.mode, "honor")
        self.assertEqual(reg1.user, self.user)
        self.assertEqual(reg1.status, "cart")
        self.assertTrue(PaidCourseRegistration.contained_in_order(self.cart, self.course_key))
        self.assertFalse(PaidCourseRegistration.contained_in_order(self.cart, SlashSeparatedCourseKey("MITx", "999", "Robot_Super_Course_abcd")))

        self.assertEqual(self.cart.total_cost, self.cost)
开发者ID:DevCode1,项目名称:edx-platform,代码行数:13,代码来源:test_models.py

示例10: test_add_with_default_mode

    def test_add_with_default_mode(self):
        """
        Tests add_to_cart where the mode specified in the argument is NOT in the database
        and NOT the default "honor".  In this case it just adds the user in the CourseMode.DEFAULT_MODE, 0 price
        """
        reg1 = PaidCourseRegistration.add_to_order(self.cart, self.course_id, mode_slug="DNE")

        self.assertEqual(reg1.unit_cost, 0)
        self.assertEqual(reg1.line_cost, 0)
        self.assertEqual(reg1.mode, "honor")
        self.assertEqual(reg1.user, self.user)
        self.assertEqual(reg1.status, "cart")
        self.assertEqual(self.cart.total_cost, 0)
        self.assertTrue(PaidCourseRegistration.part_of_order(self.cart, self.course_id))
开发者ID:obenseven,项目名称:edx-platform,代码行数:14,代码来源:test_models.py

示例11: test_already_in_cart

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

示例12: test_report_csv_itemized

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

示例13: _section_e_commerce

def _section_e_commerce(course_key, access):
    """ Provide data for the corresponding dashboard section """
    coupons = Coupon.objects.filter(course_id=course_key).order_by('-is_active')
    total_amount = None
    course_price = None
    course_honor_mode = CourseMode.mode_for_course(course_key, 'honor')
    if course_honor_mode and course_honor_mode.min_price > 0:
        course_price = course_honor_mode.min_price
    if access['finance_admin']:
        total_amount = PaidCourseRegistration.get_total_amount_of_purchased_item(course_key)

    section_data = {
        'section_key': 'e-commerce',
        'section_display_name': _('E-Commerce'),
        'access': access,
        'course_id': course_key.to_deprecated_string(),
        'ajax_remove_coupon_url': reverse('remove_coupon', kwargs={'course_id': course_key.to_deprecated_string()}),
        'ajax_get_coupon_info': reverse('get_coupon_info', kwargs={'course_id': course_key.to_deprecated_string()}),
        'ajax_update_coupon': reverse('update_coupon', kwargs={'course_id': course_key.to_deprecated_string()}),
        'ajax_add_coupon': reverse('add_coupon', kwargs={'course_id': course_key.to_deprecated_string()}),
        'get_purchase_transaction_url': reverse('get_purchase_transaction', kwargs={'course_id': course_key.to_deprecated_string()}),
        'instructor_url': reverse('instructor_dashboard', kwargs={'course_id': course_key.to_deprecated_string()}),
        'get_registration_code_csv_url': reverse('get_registration_codes', kwargs={'course_id': course_key.to_deprecated_string()}),
        'generate_registration_code_csv_url': reverse('generate_registration_codes', kwargs={'course_id': course_key.to_deprecated_string()}),
        'active_registration_code_csv_url': reverse('active_registration_codes', kwargs={'course_id': course_key.to_deprecated_string()}),
        'spent_registration_code_csv_url': reverse('spent_registration_codes', kwargs={'course_id': course_key.to_deprecated_string()}),
        'set_course_mode_url': reverse('set_course_mode_price', kwargs={'course_id': course_key.to_deprecated_string()}),
        'coupons': coupons,
        'total_amount': total_amount,
        'course_price': course_price
    }
    return section_data
开发者ID:VeritasU,项目名称:edx-platform,代码行数:32,代码来源:instructor_dashboard.py

示例14: test_report_csv_itemized

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

示例15: test_user_has_finance_admin_rights_in_e_commerce_tab

    def test_user_has_finance_admin_rights_in_e_commerce_tab(self):
        response = self.client.get(self.url)
        self.assertTrue(self.e_commerce_link in response.content)

        # Total amount html should render in e-commerce page, total amount will be 0
        total_amount = PaidCourseRegistration.get_total_amount_of_purchased_item(self.course.id)
        self.assertTrue('<span>Total Amount: <span>$' + str(total_amount) + '</span></span>' in response.content)

        # removing the course finance_admin role of login user
        CourseFinanceAdminRole(self.course.id).remove_users(self.instructor)

        # total amount should not be visible in e-commerce page if the user is not finance admin
        url = reverse('instructor_dashboard', kwargs={'course_id': self.course.id.to_deprecated_string()})
        response = self.client.post(url)
        total_amount = PaidCourseRegistration.get_total_amount_of_purchased_item(self.course.id)
        self.assertFalse('<span>Total Amount: <span>$' + str(total_amount) + '</span></span>' in response.content)
开发者ID:AsylumCorp,项目名称:edx-platform,代码行数:16,代码来源:test_ecommerce.py


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