Skip to content

Commit

Permalink
better string representation for Location model
Browse files Browse the repository at this point in the history
  • Loading branch information
tomx4096 committed Aug 19, 2018
1 parent b8a6e42 commit d1ab8e3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions OpenOversight/app/models.py
Expand Up @@ -237,6 +237,20 @@ def validate_zip_code(self, key, zip_code):
def validate_state(self, key, state):
return state_validator(state)

def __repr__(self):
if self.street_name and self.cross_street2:
return 'Intersection of {} and {}, {} {}'.format(
self.street_name, self.cross_street2, self.city, self.state)
elif self.street_name and self.cross_street1:
return 'Intersection of {} and {}, {} {}'.format(
self.street_name, self.cross_street1, self.city, self.state)
elif self.street_name and self.cross_street1 and self.cross_street2:
return 'Intersection of {} between {} and {}, {} {}'.format(
self.street_name, self.cross_street1, self.cross_street2,
self.city, self.state)
else:
return '{} {}'.format(self.city, self.state)


class LicensePlate(db.Model):
__tablename__ = 'license_plates'
Expand Down

0 comments on commit d1ab8e3

Please sign in to comment.