fix --> edit addresses org bug
This commit is contained in:
@@ -337,7 +337,9 @@ class OrganizationViewSet(BaseViewSet, ModelViewSet, DynamicSearchMixin):
|
|||||||
if 'addresses' in request.data.keys():
|
if 'addresses' in request.data.keys():
|
||||||
# import multiple addresses with postal_code to orgs
|
# import multiple addresses with postal_code to orgs
|
||||||
|
|
||||||
organization.locations.delete() # remove ex locations
|
locations = organization.locations.all()
|
||||||
|
locations.delete() # remove ex locations
|
||||||
|
|
||||||
# create new locations
|
# create new locations
|
||||||
address_obj_list = []
|
address_obj_list = []
|
||||||
for addr in request.data['addresses']:
|
for addr in request.data['addresses']:
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class HerdRancherSyncService:
|
|||||||
seen_in_batch = set()
|
seen_in_batch = set()
|
||||||
|
|
||||||
for temp in queryset.iterator(chunk_size=batch_size):
|
for temp in queryset.iterator(chunk_size=batch_size):
|
||||||
|
|
||||||
rancher = rancher_map.get(temp.rancher_national_code)
|
rancher = rancher_map.get(temp.rancher_national_code)
|
||||||
|
|
||||||
if not rancher:
|
if not rancher:
|
||||||
@@ -52,7 +51,7 @@ class HerdRancherSyncService:
|
|||||||
national_code=temp.rancher_national_code,
|
national_code=temp.rancher_national_code,
|
||||||
rancher_type='N',
|
rancher_type='N',
|
||||||
city_id=city_map.get(temp.city.strip()),
|
city_id=city_map.get(temp.city.strip()),
|
||||||
province_id=30
|
province_id=28
|
||||||
)
|
)
|
||||||
new_ranchers.append(rancher)
|
new_ranchers.append(rancher)
|
||||||
rancher_map[temp.rancher_national_code] = rancher
|
rancher_map[temp.rancher_national_code] = rancher
|
||||||
@@ -78,7 +77,7 @@ class HerdRancherSyncService:
|
|||||||
postal=temp.postal_code,
|
postal=temp.postal_code,
|
||||||
unit_unique_id=temp.unit_unique_id,
|
unit_unique_id=temp.unit_unique_id,
|
||||||
city_id=city_map.get(temp.city.strip()),
|
city_id=city_map.get(temp.city.strip()),
|
||||||
province_id=30
|
province_id=28
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user