Sapan Bhatia | f369948 | 2017-05-02 21:20:31 +0200 | [diff] [blame^] | 1 | def __unicode__(self): return u'%s' % (self.name) |
| 2 | |
| 3 | def save(self, *args, **kwargs): |
| 4 | |
| 5 | if self.latlng: |
| 6 | try: |
| 7 | latlng_value = getattr(self, 'latlng').strip() |
| 8 | if (latlng_value.startswith('[') and latlng_value.endswith(']') and latlng_value.index(',') > 0): |
| 9 | lat = latlng_value[1: latlng_value.index(',')].strip() |
| 10 | lng = latlng_value[latlng_value.index(',') + 1: len(latlng_value) - 1].strip() |
| 11 | |
| 12 | # If lat and lng are not floats, the code below should result in an error. |
| 13 | lat_validation = float(lat) |
| 14 | lng_validation = float(lng) |
| 15 | else: |
| 16 | raise ValueError("The lat/lng value is not formatted correctly.") |
| 17 | except: |
| 18 | raise ValueError("The lat/lng value is not formatted correctly.") |
| 19 | |
| 20 | super(UserNetworkInterface, self).save(*args, **kwargs) |