You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

repository.py 908B

123456789101112131415161718192021222324252627282930
  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. for method in methods:
  17. method.set_basket(basket)
  18. return methods
  19. def find_by_code(self, code):
  20. """
  21. Return the appropriate Method object for the given code
  22. """
  23. if code == Free.code:
  24. return Free()
  25. return None