Fix location address transfer
This commit is contained in:
parent
f542403b96
commit
4c27ad5d5a
|
|
@ -125,19 +125,14 @@ def transfer_cities():
|
|||
pprint(f"City serializer errors: {serialized_data.errors}")
|
||||
|
||||
|
||||
@atomic
|
||||
def transfer_addresses():
|
||||
queryset = transfer_models.Locations.objects.raw("""SELECT locations.id, locations.zip_code, locations.longitude,
|
||||
locations.latitude, locations.address, locations.city_id
|
||||
FROM locations WHERE
|
||||
locations.address != "" AND
|
||||
locations.address IS NOT NULL AND
|
||||
locations.city_id IS NOT NULL AND
|
||||
locations.city_id IN (SELECT cities.id
|
||||
FROM cities WHERE
|
||||
region_code IS NOT NULL AND
|
||||
region_code != "" AND
|
||||
country_code_2 IS NOT NULL AND
|
||||
country_code_2 != "")""")
|
||||
locations.city_id IS NOT NULL""")
|
||||
|
||||
queryset = [vars(query) for query in queryset]
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ class AddressSerializer(serializers.ModelSerializer):
|
|||
|
||||
def set_city(self, data):
|
||||
try:
|
||||
city = models.City.objects.filter(old_id=data['city_id']).first()
|
||||
city = models.City.objects.filter(mysql_id=data['city_id']).first()
|
||||
except models.City.DoesNotExist as e:
|
||||
raise ValueError(f"City not found with {data}: {e}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user