From 401b554a1c758824318d659552a8e5e620ad0f34 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 5 Mar 2022 01:05:23 +0530 Subject: [PATCH] More debug + create person and update fields if it does not exist in DB --- app/convert.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/convert.py b/app/convert.py index 5f0b48d..95a070d 100644 --- a/app/convert.py +++ b/app/convert.py @@ -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() - print("Fetched from DB") + 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