From 1b579349bf0219181f3594372f81316dec366260 Mon Sep 17 00:00:00 2001 From: littlewolf Date: Thu, 21 Nov 2019 00:13:31 +0300 Subject: [PATCH] Add tags transfer fix --- apps/location/transfer_data.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/apps/location/transfer_data.py b/apps/location/transfer_data.py index 2406075a..653afddd 100644 --- a/apps/location/transfer_data.py +++ b/apps/location/transfer_data.py @@ -12,6 +12,7 @@ from main.models import AwardType from account.models import Role from news.models import News from review.models import Review +from tag.models import TagCategory, ChosenTagSettings def transfer_countries(): @@ -449,6 +450,30 @@ def fix_reviews(): review.save() +def fix_tag_category(): + tags_categories = TagCategory.objects.filter(country__isnull=False) + for tag_category in tags_categories: + try: + correct_country = Country.objects.get(code=tag_category.country.code, mysql_ids__isnull=False) + except Country.DoesNotExist: + continue + + tag_category.country = correct_country + tag_category.save() + + +def fix_chosen_tag(): + chosen_tags = ChosenTagSettings.objects.filter(country__isnull=False) + for chosen_tag in chosen_tags: + try: + correct_country = Country.objects.get(code=chosen_tag.country.code, mysql_ids__isnull=False) + except Country.DoesNotExist: + continue + + chosen_tag.country = correct_country + chosen_tag.save() + + def fix_location_models(): # try: @@ -464,7 +489,10 @@ def fix_location_models(): # fix_award_type() # fix_role() # fix_news() - fix_reviews() + # fix_reviews() + fix_tag_category() +fix_chosen_tag() + data_types = { "dictionaries": [