More debug + create person and update fields if it does not exist in DB
This commit is contained in:
parent
27ecafa887
commit
401b554a1c
1 changed files with 18 additions and 1 deletions
|
@ -106,9 +106,26 @@ def refresh_data(filename, fmt=None, update_existing=False):
|
|||
person, source_id = get_by_id(row['ID'], Person)
|
||||
if not person:
|
||||
person = Person.objects.filter(first_name=row['First name'], last_name=row['Last name']).first()
|
||||
if person:
|
||||
print("Fetched from DB")
|
||||
else:
|
||||
print("Does not exist in DB")
|
||||
if not person:
|
||||
person = Person(first_name=row['First name'], last_name=row['Last name'], source_id=row['ID'])
|
||||
person.source_id = source_id
|
||||
person.title = row['Title']
|
||||
print(row)
|
||||
person.organisation = row['Organisation English']
|
||||
print("Country = %s" % row['country'] if 'country' in row else '')
|
||||
if 'country' not in row or 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']
|
||||
person.personal_url = fix_url(row['URL'])
|
||||
person.save()
|
||||
print("Created")
|
||||
|
||||
# Update data fields
|
||||
|
|
Loading…
Reference in a new issue