Add reviews transfer fix

This commit is contained in:
littlewolf 2019-11-20 23:20:28 +03:00
parent bcf52804a8
commit cd0a14a123

View File

@ -11,6 +11,7 @@ from requests import get
from main.models import AwardType from main.models import AwardType
from account.models import Role from account.models import Role
from news.models import News from news.models import News
from review.models import Review
def transfer_countries(): def transfer_countries():
@ -436,6 +437,18 @@ def fix_news():
news_item.save() news_item.save()
def fix_reviews():
reviews = Review.objects.filter(country__isnull=False)
for review in reviews:
try:
correct_country = Country.objects.get(code=review.country.code, mysql_ids__isnull=False)
except Country.DoesNotExist:
continue
review.country = correct_country
review.save()
def fix_location_models(): def fix_location_models():
# try: # try:
@ -450,7 +463,8 @@ def fix_location_models():
# fix_location_collection() # fix_location_collection()
# fix_award_type() # fix_award_type()
# fix_role() # fix_role()
fix_news() # fix_news()
fix_reviews()
data_types = { data_types = {
"dictionaries": [ "dictionaries": [