From aa6d88772df0a97e0cb184efd43e81d091c9e266 Mon Sep 17 00:00:00 2001 From: littlewolf Date: Wed, 20 Nov 2019 19:40:04 +0300 Subject: [PATCH] Add news transfer --- apps/location/transfer_data.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/location/transfer_data.py b/apps/location/transfer_data.py index 5c090655..0ba58c2c 100644 --- a/apps/location/transfer_data.py +++ b/apps/location/transfer_data.py @@ -10,6 +10,7 @@ from collection.models import Collection from requests import get from main.models import AwardType from account.models import Role +from news.models import News def transfer_countries(): @@ -423,6 +424,18 @@ def fix_role(): role.save() +def fix_news(): + news = News.objects.filter(country__isnull=False) + for news_item in news: + try: + correct_country = Country.objects.get(code=news_item.country.code, mysql_ids__isnull=False) + except Country.DoesNotExist: + continue + + news.country = correct_country + news.save() + + def fix_location_models(): # try: @@ -436,8 +449,8 @@ def fix_location_models(): # fix_location_address() # fix_location_collection() # fix_award_type() - fix_role() - + # fix_role() + pass data_types = { "dictionaries": [