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.

models.py 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from django.utils import six
  2. from django.db import models
  3. from oscar.models.fields import AutoSlugField
  4. from oscar.apps.offer.models import Benefit, Condition
  5. class SluggedTestModel(models.Model):
  6. title = models.CharField(max_length=42)
  7. slug = AutoSlugField(populate_from='title')
  8. class ChildSluggedTestModel(SluggedTestModel):
  9. pass
  10. class CustomSluggedTestModel(models.Model):
  11. title = models.CharField(max_length=42)
  12. slug = AutoSlugField(populate_from='title',
  13. separator=six.u("_"),
  14. uppercase=True)
  15. class BasketOwnerCalledBarry(Condition):
  16. class Meta:
  17. proxy = True
  18. app_label = 'tests'
  19. def is_satisfied(self, offer, basket):
  20. if not basket.owner:
  21. return False
  22. return basket.owner.first_name.lower() == 'barry'
  23. def can_apply_condition(self, product):
  24. return False
  25. class CustomBenefitModel(Benefit):
  26. name = 'Test benefit'
  27. class Meta:
  28. proxy = True
  29. app_label = 'tests'
  30. def __str__(self):
  31. return self.name
  32. @property
  33. def description(self):
  34. return self.name