fix city transfer
This commit is contained in:
parent
2dc1674f81
commit
227b3746ca
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -29,3 +29,4 @@ celerybeat.pid
|
|||
/docker-compose.dump.yml
|
||||
/gm_production_20191029.sql
|
||||
/apps/transfer/log
|
||||
/gm_production_*.sql
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -275,8 +275,7 @@ def get_ruby_data():
|
|||
city_name = mysql_city.name.strip()
|
||||
ruby_data[mysql_city.id] = {
|
||||
"mysql_id": mysql_city.id,
|
||||
"name": city_name.strip(),
|
||||
"name_translated": {'en-GB': city_name.strip()},
|
||||
"name": {'en-GB': city_name.strip()},
|
||||
|
||||
"map1": mysql_city.map1,
|
||||
"map2": mysql_city.map2,
|
||||
|
|
@ -334,17 +333,17 @@ def get_unused_data():
|
|||
def add_correct_location_models(ruby_data):
|
||||
for mysql_id, city_object in tqdm(ruby_data.items()):
|
||||
country_data = city_object["country"]
|
||||
country_code = country_data['code'] # i.e. fr
|
||||
try:
|
||||
country_code = country_data['code'] # i.e. fr
|
||||
country = Country.objects.get(
|
||||
code=country_code,
|
||||
mysql_ids__isnull=False,
|
||||
calling_code=settings.COUNTRY_CALLING_CODES.get(country_code)
|
||||
)
|
||||
country.mysql_ids.append(mysql_id)
|
||||
country.save()
|
||||
except Country.DoesNotExist:
|
||||
country_data['mysql_ids'] = [mysql_id]
|
||||
country_data['calling_code'] = settings.COUNTRY_CALLING_CODES.get(country_code)
|
||||
country = Country.objects.create(**country_data)
|
||||
|
||||
city_object['country'] = country
|
||||
|
|
@ -691,7 +690,7 @@ def add_fake_country():
|
|||
|
||||
city_data['region'] = region
|
||||
|
||||
city_data['name_translated'] = '{"en-GB": "' + city_data['name'] + '"}'
|
||||
city_data['name'] = '{"en-GB": "' + city_data['name'] + '"}'
|
||||
|
||||
city_data['is_island'] = True if int(city_data['is_island']) > 0 else False
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user