class ProductBrand(models.Model): seller = models.ForeignKey(Brand, related_name="sold_brands") name = models.CharField(max_length=50) picture = models.ImageField(upload_to="img/product_brands", default="NULL", storage=AssetsStorage()) def __unicode__(self): return self.name
class ProductPicture(models.Model): product = models.ForeignKey("Product", related_name="pictures", null=True, blank=True) is_brand_attribute = models.BooleanField(default=False) picture = ImageField(upload_to="img/product_pictures", storage=AssetsStorage()) sort_order = models.SmallIntegerField(null=True, blank=True) def __unicode__(self): return self.picture.url
class ProductPicture(models.Model): picture = ImageField(upload_to="img/product_pictures", storage=AssetsStorage()) content_type = models.ForeignKey(ContentType, null=True, blank=True) object_id = models.PositiveIntegerField(null=True, blank=True) content_object = generic.GenericForeignKey("content_type", "object_id") def __unicode__(self): return self.picture.url
class ProductCategory(models.Model): name = models.CharField(max_length=50) valid = models.BooleanField(default=True) thumbnail = models.ImageField(upload_to='img/category_images', null=True, blank=True, storage=AssetsStorage()) picture = models.ImageField(upload_to='img/category_images', null=True, blank=True, storage=AssetsStorage()) brand = models.ForeignKey(Brand, null=True, blank=True) is_default = models.BooleanField(default=False) def __unicode__(self): return self.name def delete(self, using=None): if self.products.all(): self.valid = False self.save() else: # Can't use 'super', why? from django.db import models models.Model.delete(self, using)
class Shop(models.Model): mother_brand = models.ForeignKey(Brand, related_name="shops") gestion_name = models.CharField(verbose_name=_("Internal name"), max_length=100, blank=True, null=True) upc = models.CharField(verbose_name=_("Barcode"), max_length=50, blank=True, null=True) phone = models.CharField(verbose_name=_("Phone number"), max_length=50, blank=True, null=True) name = models.CharField(verbose_name=_("Shop name"), max_length=50) catcher = models.CharField(verbose_name=_("Caption"), max_length=250, blank=True, null=True) image = ImageField(verbose_name=_("Shop picture"), upload_to="img/shop_images", blank=True, null=True, storage=AssetsStorage()) description = models.CharField(verbose_name=_("Description"), max_length=500, blank=True, null=True) opening_hours = models.CharField(max_length=1000, blank=True, null=True) latitude = models.FloatField() longitude = models.FloatField() address = models.ForeignKey(Address, unique=True) owner = models.ForeignKey(User, blank=True, null=True) business_reg_num = models.CharField(verbose_name="Business Reg Num", max_length=100, blank=True, null=True) tax_reg_num = models.CharField(verbose_name="Tax Reg Num", max_length=100, blank=True, null=True) default_currency = models.CharField(verbose_name="Default Currency", max_length=3, null=True) def __unicode__(self): return self.name
class BrandAttribute(models.Model): product = models.ManyToManyField(Product, through="BrandAttributePreview", related_name="brand_attributes") mother_brand = models.ForeignKey(Brand, related_name="brand_attributes") name = models.CharField(max_length=50, null=True, blank=True) texture = ImageField(upload_to="img/product_pictures", storage=AssetsStorage(), null=True) premium_type = models.CharField(choices=DISCOUNT_TYPE, verbose_name=_('type of premium price'), max_length=10, blank=True, null=True) premium_amount = models.FloatField(verbose_name=_('amount of premium'), null=True) def __unicode__(self): return self.name
class Brand(models.Model): name = models.CharField(max_length=50) logo = models.ImageField(upload_to="img/brand_logos", storage=AssetsStorage()) address = models.ForeignKey(Address, unique=True) business_reg_num = models.CharField( verbose_name="Business Registration Number", max_length=100, null=True, blank=True, default='') tax_reg_num = models.CharField(verbose_name="Tax Registration Number", max_length=100, null=True, blank=True, default='') def __str__(self): return self.name
class Branding(models.Model): name = models.CharField(max_length=50, verbose_name=_('Slide name')) sort_key = models.IntegerField(verbose_name=_('Sort key'), default=1) img = models.ImageField(verbose_name=_('Slide image'), upload_to="img/branding", storage=AssetsStorage()) landing_url = models.CharField(max_length=50, verbose_name=_('landing URL'), null=True, blank=True) show_from = models.DateTimeField(null=True, blank=True, verbose_name=_('Show from')) show_until = models.DateTimeField(null=True, blank=True, verbose_name=_('Show until')) for_brand = models.ForeignKey(Brand, null=True, blank=True) def __unicode__(self): return self.name
class NotifTemplateImage(models.Model): notif = models.ForeignKey(Notif, related_name="template_images", null=True, blank=True) image = ImageField(upload_to="img/notif_images", storage=AssetsStorage())