Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

basket.py 764B

123456789101112131415161718192021222324252627
  1. from decimal import Decimal as D
  2. from oscar.test import factories
  3. def add_product(basket, price=None, quantity=1, product=None):
  4. """
  5. Helper to add a product to the basket.
  6. """
  7. if price is None:
  8. price = D('1')
  9. if product and product.has_stockrecords:
  10. record = product.stockrecords.all()[0]
  11. else:
  12. record = factories.create_stockrecord(
  13. product=product, price_excl_tax=price,
  14. num_in_stock=quantity + 1)
  15. info = factories.create_stockinfo(record)
  16. basket.add_product(record.product, info, quantity)
  17. def add_products(basket, args):
  18. """
  19. Helper to add a series of products to the passed basket
  20. """
  21. for price, quantity in args:
  22. add_product(basket, price, quantity)