Fix error refreshing Person

This commit is contained in:
PCoder 2021-12-15 16:40:09 +05:30
parent 03313e2ee1
commit 43996a75d3
1 changed files with 9 additions and 5 deletions

View File

@ -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