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.

abstract_models.py 877B

1234567891011121314151617181920212223242526272829
  1. """
  2. Abstract models for product images
  3. """
  4. from django.db import models
  5. from django.utils.translation import ugettext as _
  6. class AbstractImage(models.Model):
  7. """
  8. An image of a product
  9. """
  10. product = models.ForeignKey('product.Item', related_name='images')
  11. # Namespacing path with app name to avoid clashes with other apps
  12. path_to_original = models.ImageField(upload_to='oscar/product-images/%Y/%m/')
  13. path_to_thumbnail = models.ImageField(upload_to='oscar/product-images/%Y/%m/')
  14. # Use display_order to determine which is the "primary" image
  15. display_order = models.PositiveIntegerField()
  16. date_created = models.DateTimeField(auto_now_add=True)
  17. def is_primary(self):
  18. return self.display_order == 0
  19. class Meta:
  20. abstract = True
  21. def __unicode__(self):
  22. return u"Image of '%s'" % self.product