From 9f3d56470e83ef1e94b51c429f8f75d165a5a399 Mon Sep 17 00:00:00 2001 From: derfenix Date: Wed, 29 Oct 2014 14:41:25 +0300 Subject: [PATCH] force locations to be a float numbers --- passbook/models.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/passbook/models.py b/passbook/models.py index c25cec9..ccec631 100644 --- a/passbook/models.py +++ b/passbook/models.py @@ -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