Skip to content

Commit

Permalink
force locations to be a float numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
derfenix committed Oct 29, 2014
1 parent 087b31b commit 9f3d564
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions passbook/models.py
Expand Up @@ -117,13 +117,22 @@ def json_dict(self):

class Location(object):

def __init__(self, latitude, longitude):
def __init__(self, latitude, longitude, altitude=0.0):
# Required. Latitude, in degrees, of the location.
self.latitude = latitude
try:
self.latitude = float(latitude)
except (ValueError, TypeError):
self.latitude = 0.0
# Required. Longitude, in degrees, of the location.
self.longitude = longitude
try:
self.longitude = float(longitude)
except (ValueError, TypeError):
self.longitude = 0.0
# Optional. Altitude, in meters, of the location.
self.altitude = 0
try:
self.altitude = float(altitude)
except (ValueError, TypeError):
self.altitude = 0.0
# Optional. Notification distance
self.distance = None
# Optional. Text displayed on the lock screen when
Expand Down

0 comments on commit 9f3d564

Please sign in to comment.