Add establishment address transfer
This commit is contained in:
parent
a67df32086
commit
b146e6cd24
|
|
@ -4,6 +4,8 @@ from django.db.models import Q
|
|||
|
||||
from transfer.models import Establishments
|
||||
from transfer.serializers.establishment import EstablishmentSerializer
|
||||
from establishment.models import Establishment
|
||||
from location.models import Address
|
||||
|
||||
|
||||
def transfer_establishment():
|
||||
|
|
@ -77,6 +79,30 @@ def transfer_establishment():
|
|||
pprint(f"Establishment serializer errors: {serialized_data.errors}")
|
||||
|
||||
|
||||
def transfer_establishment_addresses():
|
||||
old_establishments = Establishments.objects.only("id", "location_id").exclude(
|
||||
Q(type='Wineyard') |
|
||||
Q(location__timezone__isnull=True)
|
||||
)
|
||||
|
||||
for old_establishment in old_establishments:
|
||||
try:
|
||||
establishment = Establishment.objects.get(old_id=old_establishment.id)
|
||||
except Establishment.DoesNotExist:
|
||||
continue
|
||||
|
||||
try:
|
||||
location = Address.objects.get(old_id=old_establishment.location_id)
|
||||
except Establishment.DoesNotExist:
|
||||
continue
|
||||
|
||||
establishment.address = location
|
||||
establishment.save()
|
||||
|
||||
|
||||
data_types = {
|
||||
"establishment": [transfer_establishment]
|
||||
"establishment": [
|
||||
transfer_establishment,
|
||||
transfer_establishment_addresses
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user