From 652160f352eed852ce2873f36e857a75d73348f4 Mon Sep 17 00:00:00 2001 From: ACM Date: Fri, 8 Jan 2021 16:19:08 -0500 Subject: [PATCH] don't explode when hacker doesn't specify schoolD --- flask_app.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/flask_app.py b/flask_app.py index 9ec05bb..e59da57 100644 --- a/flask_app.py +++ b/flask_app.py @@ -273,11 +273,14 @@ def admin(): female_count += 1 total_count += 1 - - if hacker['school']['name'] not in schools: - schools[hacker['school']['name']] = 1 + if not 'school' in hacker: + print("Hacker has no school:") + print(hacker) else: - schools[hacker['school']['name']] += 1 + if hacker['school']['name'] not in schools: + schools[hacker['school']['name']] = 1 + else: + schools[hacker['school']['name']] += 1 if hacker['major'] not in majors: majors[hacker['major']] = 1 @@ -299,7 +302,7 @@ def admin(): 'phone_number': hacker['phone_number'], 'shirt_size': (obj.shirt_size or '').upper(), 'special_needs': obj.special_needs, - 'school': hacker['school'] + 'school': hacker['school'] if 'school' in hacker else 'NULL' }) return render_template('admin.html', hackers=hackers, total_count=total_count, waitlist_count=waitlist_count,