當前位置: 首頁>>代碼示例>>Python>>正文


Python Donation.add_to_order方法代碼示例

本文整理匯總了Python中shoppingcart.models.Donation.add_to_order方法的典型用法代碼示例。如果您正苦於以下問題:Python Donation.add_to_order方法的具體用法?Python Donation.add_to_order怎麽用?Python Donation.add_to_order使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在shoppingcart.models.Donation的用法示例。


在下文中一共展示了Donation.add_to_order方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_confirmation_email

# 需要導入模塊: from shoppingcart.models import Donation [as 別名]
# 或者: from shoppingcart.models.Donation import add_to_order [as 別名]
    def test_confirmation_email(self):
        # Pay for a donation
        Donation.add_to_order(self.cart, self.COST)
        self.cart.start_purchase()
        self.cart.purchase()

        # Check that the tax-deduction information appears in the confirmation email
        self.assertEqual(len(mail.outbox), 1)
        email = mail.outbox[0]
        self.assertEquals('Order Payment Confirmation', email.subject)
        self.assertIn("tax purposes", email.body)
開發者ID:alexmerser,項目名稱:lms,代碼行數:13,代碼來源:test_models.py

示例2: test_donate_to_org

# 需要導入模塊: from shoppingcart.models import Donation [as 別名]
# 或者: from shoppingcart.models.Donation import add_to_order [as 別名]
 def test_donate_to_org(self):
     # No course ID provided, so this is a donation to the entire organization
     donation = Donation.add_to_order(self.cart, self.COST)
     self._assert_donation(
         donation,
         donation_type="general",
         unit_cost=self.COST,
         line_desc="Donation for edX"
     )
開發者ID:alexmerser,項目名稱:lms,代碼行數:11,代碼來源:test_models.py

示例3: test_donate_to_course

# 需要導入模塊: from shoppingcart.models import Donation [as 別名]
# 或者: from shoppingcart.models.Donation import add_to_order [as 別名]
    def test_donate_to_course(self):
        # Create a test course
        course = CourseFactory.create(display_name="Test Course")

        # Donate to the course
        donation = Donation.add_to_order(self.cart, self.COST, course_id=course.id)
        self._assert_donation(
            donation,
            donation_type="course",
            course_id=course.id,
            unit_cost=self.COST,
            line_desc=u"Donation for Test Course"
        )
開發者ID:alexmerser,項目名稱:lms,代碼行數:15,代碼來源:test_models.py

示例4: test_donate_no_such_course

# 需要導入模塊: from shoppingcart.models import Donation [as 別名]
# 或者: from shoppingcart.models.Donation import add_to_order [as 別名]
 def test_donate_no_such_course(self):
     fake_course_id = CourseLocator(org="edx", course="fake", run="course")
     with self.assertRaises(CourseDoesNotExistException):
         Donation.add_to_order(self.cart, self.COST, course_id=fake_course_id)
開發者ID:alexmerser,項目名稱:lms,代碼行數:6,代碼來源:test_models.py

示例5: setUp

# 需要導入模塊: from shoppingcart.models import Donation [as 別名]
# 或者: from shoppingcart.models.Donation import add_to_order [as 別名]
    def setUp(self):
        super(TestOrderHistoryOnSiteDashboard, self).setUp()

        patcher = patch('student.models.tracker')
        self.mock_tracker = patcher.start()
        self.user = UserFactory.create()
        self.user.set_password('password')
        self.user.save()

        self.addCleanup(patcher.stop)

        # First Order with our (fakeX) site's course.
        course1 = CourseFactory.create(org='fakeX', number='999', display_name='fakeX Course')
        course1_key = course1.id
        course1_mode = CourseMode(course_id=course1_key,
                                  mode_slug="honor",
                                  mode_display_name="honor cert",
                                  min_price=20)
        course1_mode.save()

        cart = Order.get_cart_for_user(self.user)
        PaidCourseRegistration.add_to_order(cart, course1_key)
        cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
        self.fakex_site_order_id = cart.id

        # Second Order with another(fooX) site's course
        course2 = CourseFactory.create(org='fooX', number='888', display_name='fooX Course')
        course2_key = course2.id
        course2_mode = CourseMode(course_id=course2.id,
                                  mode_slug="honor",
                                  mode_display_name="honor cert",
                                  min_price=20)
        course2_mode.save()

        cart = Order.get_cart_for_user(self.user)
        PaidCourseRegistration.add_to_order(cart, course2_key)
        cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
        self.foox_site_order_id = cart.id

        # Third Order with course not attributed to any site.
        course3 = CourseFactory.create(org='fakeOtherX', number='777', display_name='fakeOtherX Course')
        course3_key = course3.id
        course3_mode = CourseMode(course_id=course3.id,
                                  mode_slug="honor",
                                  mode_display_name="honor cert",
                                  min_price=20)
        course3_mode.save()

        cart = Order.get_cart_for_user(self.user)
        PaidCourseRegistration.add_to_order(cart, course3_key)
        cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
        self.order_id = cart.id

        # Fourth Order with course not attributed to any site but with a CertificateItem
        course4 = CourseFactory.create(org='fakeOtherX', number='888')
        course4_key = course4.id
        course4_mode = CourseMode(course_id=course4.id,
                                  mode_slug="verified",
                                  mode_display_name="verified cert",
                                  min_price=20)
        course4_mode.save()

        cart = Order.get_cart_for_user(self.user)
        CertificateItem.add_to_order(cart, course4_key, 20.0, 'verified')
        cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
        self.certificate_order_id = cart.id

        # Fifth Order with course not attributed to any site but with a Donation
        course5 = CourseFactory.create(org='fakeOtherX', number='999')
        course5_key = course5.id

        cart = Order.get_cart_for_user(self.user)
        Donation.add_to_order(cart, 20.0, course5_key)
        cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
        self.donation_order_id = cart.id

        # also add a donation not associated with a course to make sure the None case works OK
        Donation.add_to_order(cart, 10.0, None)
        cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
        self.courseless_donation_order_id = cart.id
開發者ID:cmscom,項目名稱:edx-platform,代碼行數:82,代碼來源:test_configuration_overrides.py


注:本文中的shoppingcart.models.Donation.add_to_order方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。