Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

repository.py 971B

123456789101112131415161718192021222324252627282930
  1. from oscar.apps.shipping.methods import FreeShipping, OrderAndItemLevelChargeMethod
  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 = [FreeShipping()]
  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 == FreeShipping.code:
  24. return FreeShipping()
  25. return None