From 43996a75d310170c57391483d420de3a0f95a96b Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 15 Dec 2021 16:40:09 +0530 Subject: [PATCH] Fix error refreshing Person --- app/convert.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/convert.py b/app/convert.py index 235dde8..22ea790 100644 --- a/app/convert.py +++ b/app/convert.py @@ -111,7 +111,11 @@ def refresh_data(filename, fmt=None): person.source_id = source_id person.title = row['Title'] person.organisation = row['Organisation English'] - person.country = row['Country'] + print("Country = %s" % row['country']) + if row['country'] is None or row['country'].strip() == '': + row['country'] = 0 + c = Country.objects.get(id=row['country']) + person.country = c person.position = row['Position'] person.biography = row['Biography'] person.contact_email = row['e-mail 1'] @@ -141,8 +145,8 @@ def refresh_data(filename, fmt=None): count = count + 1 elif fmt['dataformat'] is DataFormat.RANGE_DETAIL: - rng, source_id = get_by_id(row['Range_ID'], Range) - if not rng: rng = Range(source_id=source_id) + rng, source_id = get_by_id(row['Range_ID'], MountainRange) + if not rng: rng = MountainRange(source_id=source_id) rng.gmba_id = row['GMBA_ID'] rng.name = row['RangeName'] rng.countries = row['Countries'] @@ -162,7 +166,7 @@ def refresh_data(filename, fmt=None): count = count + 1 elif fmt['dataformat'] is DataFormat.PERSON_RANGE: - rzs, source_id = get_by_id(row['MountainRange'], Range, first=False) + rzs, source_id = get_by_id(row['MountainRange'], MountainRange, first=False) if not rzs or not rzs.first(): continue ppl, source_id = get_by_id(row['Person'], Person, first=False) @@ -185,7 +189,7 @@ def refresh_data(filename, fmt=None): count = count + 1 p = f['properties'] - rge = Range.objects.filter(gmba_id=p['GMBA_ID']).first() + rge = MountainRange.objects.filter(gmba_id=p['GMBA_ID']).first() if not rge: ranges_missing.append(p['GMBA_ID']) continue