本文整理汇总了Python中shoppingcart.models.Order.save方法的典型用法代码示例。如果您正苦于以下问题:Python Order.save方法的具体用法?Python Order.save怎么用?Python Order.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shoppingcart.models.Order
的用法示例。
在下文中一共展示了Order.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_course_registration_features
# 需要导入模块: from shoppingcart.models import Order [as 别名]
# 或者: from shoppingcart.models.Order import save [as 别名]
def test_course_registration_features(self):
query_features = ['code', 'course_id', 'transaction_group_name', 'created_by', 'redeemed_by']
for i in range(5):
course_code = CourseRegistrationCode(
code="test_code{}".format(i), course_id=self.course_key.to_deprecated_string(),
transaction_group_name='TestName', created_by=self.users[0]
)
course_code.save()
order = Order(user=self.users[0], status='purchased')
order.save()
registration_code_redemption = RegistrationCodeRedemption(
order=order, registration_code_id=1, redeemed_by=self.users[0]
)
registration_code_redemption.save()
registration_codes = CourseRegistrationCode.objects.all()
course_registration_list = course_registration_features(query_features, registration_codes, csv_type='download')
self.assertEqual(len(course_registration_list), len(registration_codes))
for course_registration in course_registration_list:
self.assertEqual(set(course_registration.keys()), set(query_features))
self.assertIn(course_registration['code'], [registration_code.code for registration_code in registration_codes])
self.assertIn(
course_registration['course_id'],
[registration_code.course_id.to_deprecated_string() for registration_code in registration_codes]
)
self.assertIn(
course_registration['transaction_group_name'],
[registration_code.transaction_group_name for registration_code in registration_codes]
)
示例2: test_course_registration_features
# 需要导入模块: from shoppingcart.models import Order [as 别名]
# 或者: from shoppingcart.models.Order import save [as 别名]
def test_course_registration_features(self):
query_features = [
'code', 'redeem_code_url', 'course_id', 'company_name', 'created_by',
'redeemed_by', 'invoice_id', 'purchaser', 'customer_reference_number', 'internal_reference'
]
order = Order(user=self.instructor, status='purchased')
order.save()
registration_code_redemption = RegistrationCodeRedemption(
registration_code_id=1, redeemed_by=self.instructor
)
registration_code_redemption.save()
registration_codes = CourseRegistrationCode.objects.all()
course_registration_list = course_registration_features(query_features, registration_codes, csv_type='download')
self.assertEqual(len(course_registration_list), len(registration_codes))
for course_registration in course_registration_list:
self.assertEqual(set(course_registration.keys()), set(query_features))
self.assertIn(course_registration['code'], [registration_code.code for registration_code in registration_codes])
self.assertIn(
course_registration['course_id'],
[registration_code.course_id.to_deprecated_string() for registration_code in registration_codes]
)
self.assertIn(
course_registration['company_name'],
[getattr(registration_code.invoice, 'company_name') for registration_code in registration_codes]
)
self.assertIn(
course_registration['invoice_id'],
[registration_code.invoice_id for registration_code in registration_codes]
)
示例3: checkout
# 需要导入模块: from shoppingcart.models import Order [as 别名]
# 或者: from shoppingcart.models.Order import save [as 别名]
def checkout(request):
store = Store.objects.get(subdomain=request.subdomain)
cart = get_cart(request)
if cart == {}:
return redirect("/products/")
try:
order = Order(user=request.session["user"], store=store)
order.save()
except KeyError:
return redirect("/home/", {"error_message": "Please sign in"}) #!!!
for product, key in cart.iteritems():
i = Item(product=product, quantity=key, order=order)
i.save()
request.session["cart"] = cart = {}
return render_to_response("checkout.html", {"store_name": store.name})