intermediate commit
This commit is contained in:
parent
6f8361cb83
commit
78a8a5d699
|
|
@ -123,8 +123,6 @@ class ProductQuerySet(models.QuerySet):
|
|||
class Product(TranslatedFieldsMixin, BaseAttributes):
|
||||
"""Product models."""
|
||||
|
||||
STR_FIELD_NAME = 'name'
|
||||
|
||||
COMMON = 0
|
||||
ONLINE = 1
|
||||
|
||||
|
|
@ -135,8 +133,9 @@ class Product(TranslatedFieldsMixin, BaseAttributes):
|
|||
|
||||
category = models.PositiveIntegerField(choices=CATEGORY_CHOICES,
|
||||
default=COMMON)
|
||||
name = TJSONField(_('Name'), null=True, blank=True, default=None,
|
||||
help_text='{"en-GB":"some text"}')
|
||||
name = models.CharField(max_length=255,
|
||||
default=None, null=True,
|
||||
verbose_name=_('name'))
|
||||
description = TJSONField(_('Description'), null=True, blank=True,
|
||||
default=None, help_text='{"en-GB":"some text"}')
|
||||
characteristics = JSONField(_('Characteristics'))
|
||||
|
|
@ -178,6 +177,10 @@ class Product(TranslatedFieldsMixin, BaseAttributes):
|
|||
verbose_name = _('Product')
|
||||
verbose_name_plural = _('Products')
|
||||
|
||||
def __str__(self):
|
||||
"""Override str dunder method."""
|
||||
return self.name
|
||||
|
||||
def clean_fields(self, exclude=None):
|
||||
super().clean_fields(exclude=exclude)
|
||||
if self.product_type.index_name == ProductType.WINE and not self.wine_region:
|
||||
|
|
@ -210,6 +213,25 @@ class OnlineProduct(Product):
|
|||
verbose_name_plural = _('Online products')
|
||||
|
||||
|
||||
class Characteristic(TranslatedFieldsMixin, models.Model):
|
||||
"""Characteristic model."""
|
||||
|
||||
STR_FIELD_NAME = 'name'
|
||||
|
||||
name = TJSONField(_('name'),
|
||||
help_text='{"en-GB":"some text"}')
|
||||
value = models.CharField(max_length=255,
|
||||
verbose_name=_('value'))
|
||||
unit = models.ForeignKey('Unit', on_delete=models.PROTECT,
|
||||
)
|
||||
priority = models.IntegerField(unique=True, null=True, default=None)
|
||||
|
||||
class Meta:
|
||||
"""Meta model."""
|
||||
verbose_name = _('characteristic')
|
||||
verbose_name_plural = _('characteristics')
|
||||
|
||||
|
||||
class WineStandardQuerySet(models.QuerySet):
|
||||
"""Wine appellation queryset."""
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
from pprint import pprint
|
||||
|
||||
from transfer.models import EstablishmentBacklinks
|
||||
from transfer.serializers.partner import PartnerSerializer
|
||||
|
||||
|
||||
def transfer_partner():
|
||||
queryset = EstablishmentBacklinks.objects.filter(type="Partner")
|
||||
|
||||
serialized_data = PartnerSerializer(data=list(queryset.values()), many=True)
|
||||
if serialized_data.is_valid():
|
||||
serialized_data.save()
|
||||
else:
|
||||
pprint(f"News serializer errors: {serialized_data.errors}")
|
||||
|
||||
|
||||
data_types = {
|
||||
"partner": [transfer_partner]
|
||||
}
|
||||
|
|
@ -897,6 +897,46 @@ class KeyValueMetadatumKeyValueMetadatumEstablishments(MigrateMixin):
|
|||
db_table = 'key_value_metadatum_key_value_metadatum_establishments'
|
||||
|
||||
|
||||
class WineColor(MigrateMixin):
|
||||
using = 'legacy'
|
||||
|
||||
id = models.IntegerField()
|
||||
name = models.CharField(max_length=255)
|
||||
fra_encima_id = models.IntegerField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'wine_colors'
|
||||
|
||||
|
||||
class WineClassification(MigrateMixin):
|
||||
using = 'legacy'
|
||||
|
||||
id = models.IntegerField()
|
||||
name = models.CharField(max_length=255)
|
||||
desc = models.TextField()
|
||||
latitude = models.FloatField(blank=True, null=True)
|
||||
longitude = models.FloatField(blank=True, null=True)
|
||||
type = models.CharField(max_length=255)
|
||||
parent_id = models.IntegerField()
|
||||
possible_type_id = models.IntegerField(null=True, blank=True)
|
||||
possible_color_id = models.IntegerField(null=True, blank=True)
|
||||
fra_encima_id = models.IntegerField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'wine_classifications'
|
||||
|
||||
|
||||
class WineTypes(models.Model):
|
||||
name = models.CharField(max_length=255, blank=True, null=True)
|
||||
fra_encima_id = models.IntegerField(blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'wine_types'
|
||||
|
||||
|
||||
# class Products(models.Model):
|
||||
# establishment = models.ForeignKey('Establishments', models.DO_NOTHING, blank=True, null=True)
|
||||
# brand = models.CharField(max_length=255, blank=True, null=True)
|
||||
|
|
@ -927,14 +967,3 @@ class KeyValueMetadatumKeyValueMetadatumEstablishments(MigrateMixin):
|
|||
# class Meta:
|
||||
# managed = False
|
||||
# db_table = 'products'
|
||||
#
|
||||
#
|
||||
# class WineTypes(models.Model):
|
||||
# name = models.CharField(max_length=255, blank=True, null=True)
|
||||
# fra_encima_id = models.IntegerField(blank=True, null=True)
|
||||
# created_at = models.DateTimeField()
|
||||
# updated_at = models.DateTimeField()
|
||||
#
|
||||
# class Meta:
|
||||
# managed = False
|
||||
# db_table = 'wine_types'
|
||||
|
|
|
|||
0
apps/transfer/serializers/product.py
Normal file
0
apps/transfer/serializers/product.py
Normal file
Loading…
Reference in New Issue
Block a user