|
|
|
|
@ -23,21 +23,6 @@ class ProductAttribute(AbstractStatusModel): |
|
|
|
|
verbose_name = _('Product attribute') |
|
|
|
|
verbose_name_plural = _('Product attributes') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProductAttributeChoiceValue(AbstractDateTimeModel): |
|
|
|
|
name = models.CharField(max_length=64, blank=True, null=True, default=None) |
|
|
|
|
slug = AutoSlugField(populate_from='name') |
|
|
|
|
attribute = models.ForeignKey(ProductAttribute, on_delete=models.CASCADE, related_name='values') |
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
|
return self.name |
|
|
|
|
|
|
|
|
|
class Meta: |
|
|
|
|
unique_together = ('name', 'attribute') |
|
|
|
|
verbose_name = 'Product attribute value' |
|
|
|
|
verbose_name_plural = 'Product attribute values' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Manufacturer(AbstractStatusModel): |
|
|
|
|
name = models.CharField(max_length=64, blank=True, null=True, default=None) |
|
|
|
|
slug = AutoSlugField(populate_from='name') |
|
|
|
|
@ -47,12 +32,12 @@ class Manufacturer(AbstractStatusModel): |
|
|
|
|
return self.name |
|
|
|
|
|
|
|
|
|
def get_absolute_url(self): |
|
|
|
|
# return reverse('products:CategoriesListByProducer', args=[self.slug]) |
|
|
|
|
return reverse_lazy('products:manufacturer', kwargs={'producer_slug': self.slug, 'path': ''}) |
|
|
|
|
|
|
|
|
|
#@TODO: tranlsate into english and use traslation |
|
|
|
|
class Meta: |
|
|
|
|
verbose_name = 'Producer' |
|
|
|
|
verbose_name_plural = 'Producers' |
|
|
|
|
verbose_name = _('Производитель') |
|
|
|
|
verbose_name_plural = _('Производители') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProductCategory(MPTTModel, AbstractDateTimeModel): |
|
|
|
|
@ -81,11 +66,10 @@ class Product(AbstractStatusModel): |
|
|
|
|
slug = AutoSlugField(populate_from='name') |
|
|
|
|
price = models.DecimalField(max_digits=10, decimal_places=2, default=0.00) |
|
|
|
|
description = models.TextField(db_index=True, blank=True, null=True, default=None) |
|
|
|
|
manufacturer = models.ForeignKey(Manufacturer, on_delete=models.PROTECT, related_name='products') |
|
|
|
|
manufacturer = models.ForeignKey(Manufacturer, on_delete=models.PROTECT) |
|
|
|
|
image = models.ImageField(upload_to='products', blank=True, verbose_name="image of products") |
|
|
|
|
category = models.ForeignKey(ProductCategory, on_delete=models.SET_NULL, related_name='products', blank=True, |
|
|
|
|
null=True, default=None) |
|
|
|
|
attributes = models.ManyToManyField(ProductAttribute, related_name='categories', blank=True) |
|
|
|
|
category = models.ForeignKey(ProductCategory, on_delete=models.SET_NULL, blank=True, null=True, default=None) |
|
|
|
|
attributes = models.ManyToManyField(ProductAttribute, blank=True) |
|
|
|
|
discount_policy = HStoreField(blank=True, null=True, default={}) |
|
|
|
|
is_active = models.BooleanField(default=True) |
|
|
|
|
|
|
|
|
|
@ -99,8 +83,8 @@ class Product(AbstractStatusModel): |
|
|
|
|
indexes = [ |
|
|
|
|
models.Index(fields=['id', 'slug']) |
|
|
|
|
] |
|
|
|
|
verbose_name = 'Product' |
|
|
|
|
verbose_name_plural = 'Products' |
|
|
|
|
verbose_name = _('Product') |
|
|
|
|
verbose_name_plural = _('Products') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -115,6 +99,21 @@ class Product(AbstractStatusModel): |
|
|
|
|
# pp = ProductProperty(category_property=cp, products=self, value="--") |
|
|
|
|
# pp.save() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProductAttributeValue(AbstractDateTimeModel): |
|
|
|
|
product = models.ForeignKey(Product, on_delete=models.PROTECT) |
|
|
|
|
name = models.CharField(max_length=64, blank=True, null=True, default=None) |
|
|
|
|
slug = AutoSlugField(populate_from='name') |
|
|
|
|
attribute = models.ForeignKey(ProductAttribute, on_delete=models.CASCADE, related_name='values') |
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
|
return self.name |
|
|
|
|
|
|
|
|
|
class Meta: |
|
|
|
|
unique_together = ('name', 'attribute') |
|
|
|
|
verbose_name = 'Product attribute value' |
|
|
|
|
verbose_name_plural = 'Product attribute values' |
|
|
|
|
|
|
|
|
|
# class Offer(models.Model): |
|
|
|
|
# name = models.CharField(max_length=64, blank=True, null=True, default=None) |
|
|
|
|
# slug = AutoSlugField(populate_from='name') |
|
|
|
|
|