Add product migrate data
This commit is contained in:
parent
f6151c0a14
commit
c1c9f99fb5
|
|
@ -0,0 +1,54 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from product.models import ProductType, ProductSubType
|
||||
|
||||
|
||||
def add_type():
|
||||
product_type = ProductType.objects.create(
|
||||
name={'"en-GB"': "Wine"},
|
||||
index_name=ProductType.WINE
|
||||
)
|
||||
return product_type.save()
|
||||
|
||||
|
||||
def add_subtype(id_type):
|
||||
subtypes = ProductSubType.objects.bulk_create([
|
||||
ProductSubType(product_type=id_type,
|
||||
name={"en-GB", ProductSubType.EXTRA_BRUT},
|
||||
index_name=ProductSubType.EXTRA_BRUT),
|
||||
ProductSubType(product_type=id_type,
|
||||
name={"en-GB", ProductSubType.BRUT},
|
||||
index_name=ProductSubType.BRUT),
|
||||
ProductSubType(product_type=id_type,
|
||||
name={"en-GB", ProductSubType.BRUT_NATURE},
|
||||
index_name=ProductSubType.BRUT_NATURE),
|
||||
ProductSubType(product_type=id_type,
|
||||
name={"en-GB", ProductSubType.DEMI_SEC},
|
||||
index_name=ProductSubType.DEMI_SEC),
|
||||
ProductSubType(product_type=id_type,
|
||||
name={"en-GB", ProductSubType.EXTRA_DRY},
|
||||
index_name=ProductSubType.EXTRA_DRY),
|
||||
ProductSubType(product_type=id_type,
|
||||
name={"en-GB", ProductSubType.DOSAGE_ZERO},
|
||||
index_name=ProductSubType.DOSAGE_ZERO),
|
||||
ProductSubType(product_type=id_type,
|
||||
name={"en-GB", ProductSubType.SEC},
|
||||
index_name=ProductSubType.SEC),
|
||||
ProductSubType(product_type=id_type,
|
||||
name={"en-GB", ProductSubType.SEC},
|
||||
index_name=ProductSubType.SEC),
|
||||
ProductSubType(product_type=id_type,
|
||||
name={"en-GB", ProductSubType.MOELLEUX},
|
||||
index_name=ProductSubType.MOELLEUX),
|
||||
])
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Add product data'
|
||||
|
||||
def handle(self, *args, **kwarg):
|
||||
product_type = add_type()
|
||||
add_subtype(product_type.id)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -46,10 +46,28 @@ class ProductSubType(TranslatedFieldsMixin, ProjectBaseMixin):
|
|||
# INDEX NAME CHOICES
|
||||
RUM = 'rum'
|
||||
OTHER = 'other'
|
||||
EXTRA_BRUT = 'extra brut'
|
||||
BRUT = 'brut'
|
||||
BRUT_NATURE = 'brut nature'
|
||||
DEMI_SEC = 'demi-sec'
|
||||
EXTRA_DRY = 'Extra Dry'
|
||||
DOSAGE_ZERO = 'dosage zero'
|
||||
SEC = 'sec'
|
||||
DOUX = 'doux'
|
||||
MOELLEUX= 'moelleux'
|
||||
|
||||
INDEX_NAME_TYPES = (
|
||||
(RUM, _('Rum')),
|
||||
(OTHER, _('Other')),
|
||||
(EXTRA_BRUT, _('extra brut')),
|
||||
(BRUT, _('brut')),
|
||||
(BRUT_NATURE, _('brut nature')),
|
||||
(DEMI_SEC, _('demi-sec')),
|
||||
(EXTRA_DRY, _('Extra Dry')),
|
||||
(DOSAGE_ZERO, _('dosage zero')),
|
||||
(SEC, _('sec')),
|
||||
(DOUX, _('doux')),
|
||||
(MOELLEUX, _('moelleux'))
|
||||
)
|
||||
|
||||
product_type = models.ForeignKey(ProductType, on_delete=models.CASCADE,
|
||||
|
|
|
|||
|
|
@ -842,6 +842,7 @@ class Ads(MigrateMixin):
|
|||
managed = False
|
||||
db_table = 'ads'
|
||||
|
||||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user