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 921B

12345678910111213141516171819202122232425262728
  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. u"""An image of a product"""
  8. product = models.ForeignKey('product.Item', related_name='images')
  9. # Namespacing path with app name to avoid clashes with other apps
  10. path_to_original = models.ImageField(upload_to='oscar/product-images/%Y/%m/')
  11. path_to_thumbnail = models.ImageField(upload_to='oscar/product-images/%Y/%m/')
  12. # Use display_order to determine which is the "primary" image
  13. display_order = models.PositiveIntegerField()
  14. date_created = models.DateTimeField(auto_now_add=True)
  15. def is_primary(self):
  16. u"""Return bool if image display order is 0"""
  17. return self.display_order == 0
  18. class Meta:
  19. abstract = True
  20. def __unicode__(self):
  21. return u"Image of '%s'" % self.product