Skip to content

Commit

Permalink
Catch missing URL values in cost-error model method
Browse files Browse the repository at this point in the history
We've encountered a few disclosure URLs that were missing some fields.
This uses the dictionary get() method, which should have been used in
the first place, to avoid key errors when running reports.
  • Loading branch information
higs4281 committed Jun 1, 2017
1 parent 37e2c2b commit 906aa2e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions paying_for_college/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,10 @@ def total_fields(field_list):
def cost_error(self):
"""Return 1 or 0: Is total-cost less than tuition?"""
url_data = self.parsed_url
if url_data and url_data['totl'] != '' and url_data['tuit'] != '':
if int(url_data['totl']) < int(url_data['tuit']):
if (url_data
and url_data.get('totl') != ''
and url_data.get('tuit') != ''):
if int(url_data.get('totl', 0)) < int(url_data.get('tuit', 0)):
return 1
else:
return 0
Expand Down

0 comments on commit 906aa2e

Please sign in to comment.