diff --git a/apps/location/transfer_data.py b/apps/location/transfer_data.py index d631e3e5..5c090655 100644 --- a/apps/location/transfer_data.py +++ b/apps/location/transfer_data.py @@ -9,6 +9,7 @@ from django.core.exceptions import MultipleObjectsReturned from collection.models import Collection from requests import get from main.models import AwardType +from account.models import Role def transfer_countries(): @@ -410,6 +411,18 @@ def fix_award_type(): award_type.save() +def fix_role(): + roles_list = Role.objects.filter(country__isnull=False) + for role in roles_list: + try: + correct_country = Country.objects.get(code=role.country.code, mysql_ids__isnull=False) + except Country.DoesNotExist: + continue + + role.country = correct_country + role.save() + + def fix_location_models(): # try: @@ -422,7 +435,8 @@ def fix_location_models(): # # fix_location_address() # fix_location_collection() - fix_award_type() + # fix_award_type() + fix_role() data_types = {