Add
This commit is contained in:
parent
989e80ece6
commit
7b4837f4f3
|
|
@ -68,13 +68,13 @@ class Command(BaseCommand):
|
|||
objects = []
|
||||
queryset = [vars(query) for query in raw_qs]
|
||||
for obj in queryset:
|
||||
establishment = Establishment.objects.filter(old_id=obj['establishment_id']).first()
|
||||
# establishment = Establishment.objects.filter(old_id=obj['establishment_id']).first()
|
||||
country = Country.objects.filter(code=obj['country_code']).first()
|
||||
objects.append(
|
||||
Collection(name={"en-GB":obj['title']}, collection_type = Collection.ORDINARY,
|
||||
Collection(name={"en-GB":obj['title']}, collection_type=Collection.ORDINARY,
|
||||
is_publish=obj['is_publish'], country=country,
|
||||
description=obj['description'],
|
||||
slug=obj['slug']
|
||||
slug=obj['slug'], old_id=obj['old_id']
|
||||
)
|
||||
)
|
||||
# self.stdout.write(self.style.WARNING(f'Deleted {count} objects.'))
|
||||
Collection.objects.bulk_create(objects)
|
||||
|
|
|
|||
18
apps/collection/migrations/0017_collection_old_id.py
Normal file
18
apps/collection/migrations/0017_collection_old_id.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-31 13:58
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('collection', '0016_auto_20191024_1334'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='old_id',
|
||||
field=models.IntegerField(blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -76,6 +76,7 @@ class Collection(ProjectBaseMixin, CollectionDateMixin,
|
|||
slug = models.SlugField(max_length=50, unique=True,
|
||||
verbose_name=_('Collection slug'), editable=True, null=True)
|
||||
|
||||
old_id=models.IntegerField(null=True, blank=True)
|
||||
objects = CollectionQuerySet.as_manager()
|
||||
|
||||
class Meta:
|
||||
|
|
|
|||
29
apps/product/migrations/0003_auto_20191030_1315.py
Normal file
29
apps/product/migrations/0003_auto_20191030_1315.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-30 13:15
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0002_product_slug'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='product',
|
||||
name='old_id',
|
||||
field=models.IntegerField(blank=True, null=True, verbose_name='Product old id'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='product',
|
||||
name='old_id_establishment',
|
||||
field=models.IntegerField(blank=True, null=True, verbose_name='Establishment old id'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='establishment',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='products', to='establishment.Establishment', verbose_name='establishment'),
|
||||
),
|
||||
]
|
||||
33
apps/product/migrations/0004_auto_20191031_0923.py
Normal file
33
apps/product/migrations/0004_auto_20191031_0923.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-31 09:23
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0003_auto_20191030_1315'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='product',
|
||||
name='old_id_establishment',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='establishment',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='products', to='establishment.Establishment', verbose_name='establishment'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='old_id',
|
||||
field=models.IntegerField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='productsubtype',
|
||||
name='index_name',
|
||||
field=models.CharField(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')], db_index=True, max_length=50, unique=True, verbose_name='Index name'),
|
||||
),
|
||||
]
|
||||
19
apps/product/migrations/0005_auto_20191031_0929.py
Normal file
19
apps/product/migrations/0005_auto_20191031_0929.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-31 09:29
|
||||
|
||||
import django.contrib.postgres.fields.jsonb
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0004_auto_20191031_0923'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='characteristics',
|
||||
field=django.contrib.postgres.fields.jsonb.JSONField(null=True, verbose_name='Characteristics'),
|
||||
),
|
||||
]
|
||||
19
apps/product/migrations/0006_auto_20191031_0930.py
Normal file
19
apps/product/migrations/0006_auto_20191031_0930.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-31 09:30
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0005_auto_20191031_0929'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='establishment',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='products', to='establishment.Establishment', verbose_name='establishment'),
|
||||
),
|
||||
]
|
||||
Loading…
Reference in New Issue
Block a user