Temp fiz
This commit is contained in:
parent
ffb7334f1f
commit
17ca27c751
|
|
@ -541,6 +541,77 @@ def transfer_city_gallery():
|
||||||
f'Already added: {gallery_obj_exists_counter}')
|
f'Already added: {gallery_obj_exists_counter}')
|
||||||
|
|
||||||
|
|
||||||
|
def add_fake_country():
|
||||||
|
# add country
|
||||||
|
country_data = {
|
||||||
|
"name": '{"en-GB": "Antilles Guyane West Indies"}',
|
||||||
|
"code": "aa"
|
||||||
|
}
|
||||||
|
country_mysql_ids = transfer_models.Cities.objects.filter(country_code_2="AA").only("id")
|
||||||
|
if len(country_mysql_ids) < 1:
|
||||||
|
raise ValueError("Incorrect country code")
|
||||||
|
|
||||||
|
country_data['mysql_ids'] = list(country_mysql_ids.values_list('id', flat=True))
|
||||||
|
|
||||||
|
country = Country.objects.create(**country_data)
|
||||||
|
|
||||||
|
regions_data = [
|
||||||
|
{
|
||||||
|
"name": "Guadeloupe",
|
||||||
|
"code": "GP",
|
||||||
|
"subregions": [
|
||||||
|
{
|
||||||
|
"name": "Basse Terre",
|
||||||
|
"code": "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Grande Terre",
|
||||||
|
"code": "",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Martinique",
|
||||||
|
"code": "MQ",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Guyane",
|
||||||
|
"code": "GY",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "St Barthelemy",
|
||||||
|
"code": "BL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "St Martin",
|
||||||
|
"code": "MF",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Sainte-Lucie",
|
||||||
|
"code": "LC",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
regions = {}
|
||||||
|
|
||||||
|
for region_data in regions_data:
|
||||||
|
subregions = region_data['subregions'] if "subregions" in region_data else False
|
||||||
|
|
||||||
|
region_name = region_data['name']
|
||||||
|
region_data['name'] = '{"en-GB": "' + region_name + '"}'
|
||||||
|
region_data['country'] = country
|
||||||
|
|
||||||
|
regions[region_name] = Region.objects.create(**region_data)
|
||||||
|
|
||||||
|
if subregions:
|
||||||
|
for subregion_data in subregions:
|
||||||
|
subregion_name = subregion_data['name']
|
||||||
|
subregion_data['name'] = '{"en-GB": "' + subregion_name + '"}'
|
||||||
|
subregion_data['country'] = country
|
||||||
|
subregion_data['parent_region'] = regions[region_name]
|
||||||
|
|
||||||
|
regions[subregion_name] = Region.objects.create(**subregion_data)
|
||||||
|
|
||||||
|
|
||||||
data_types = {
|
data_types = {
|
||||||
"dictionaries": [
|
"dictionaries": [
|
||||||
transfer_countries,
|
transfer_countries,
|
||||||
|
|
@ -565,6 +636,7 @@ data_types = {
|
||||||
],
|
],
|
||||||
"remove_old_locations":[remove_old_records],
|
"remove_old_locations":[remove_old_records],
|
||||||
|
|
||||||
"fill_city_gallery": [transfer_city_gallery]
|
"fill_city_gallery": [transfer_city_gallery],
|
||||||
|
"add_fake_country": [add_fake_country]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ class Command(BaseCommand):
|
||||||
'update_city_info',
|
'update_city_info',
|
||||||
'migrate_city_gallery',
|
'migrate_city_gallery',
|
||||||
'fix_location',
|
'fix_location',
|
||||||
'remove_old_locations'
|
'remove_old_locations',
|
||||||
|
'add_fake_country'
|
||||||
]
|
]
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user