Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

repository.py 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. from oscar.apps.shipping.methods import Free
  2. class Repository(object):
  3. """
  4. Repository class responsible for returning ShippingMethod
  5. objects for a given user, basket etc
  6. """
  7. def get_shipping_methods(self, user, basket, shipping_addr=None, **kwargs):
  8. """
  9. Return a list of all applicable shipping method objects
  10. for a given basket.
  11. We default to returning the Method models that have been defined but
  12. this behaviour can easily be overridden by subclassing this class
  13. and overriding this method.
  14. """
  15. methods = [Free()]
  16. return self.add_basket_to_methods(basket, methods)
  17. def get_default_shipping_method(self, user, basket, shipping_addr=None, **kwargs):
  18. return self.get_shipping_methods(user, basket, shipping_addr, **kwargs)[0]
  19. def add_basket_to_methods(self, basket, methods):
  20. for method in methods:
  21. method.set_basket(basket)
  22. return methods
  23. def find_by_code(self, code):
  24. """
  25. Return the appropriate Method object for the given code
  26. """
  27. if code == Free.code:
  28. return Free()
  29. return None