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.

offers.py 665B

12345678910111213141516171819202122232425
  1. from oscar.apps.offer import models
  2. class ChangesOwnerName(models.Benefit):
  3. class Meta:
  4. proxy = True
  5. app_label = 'sandbox'
  6. def apply(self, basket, condition, offer=None):
  7. condition.consume_items(offer, basket, ())
  8. return models.PostOrderAction(
  9. "You will have your name changed to Barry!")
  10. def apply_deferred(self, basket, order, application):
  11. if basket.owner:
  12. basket.owner.first_name = "Barry"
  13. basket.owner.save()
  14. return "Your name has been changed to Barry!"
  15. @property
  16. def description(self):
  17. return "Changes owners name"
  18. name = description