Skip to content

Commit

Permalink
Don't resolve address to location when address is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
elnappo committed Jul 18, 2019
1 parent 88d0a85 commit ace7dcd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions project_novis/accounts/models.py
Expand Up @@ -75,10 +75,11 @@ class User(AbstractUser):

def save(self, *args, **kwargs):
"""Set location field based on user provided address."""
address = self.address
if self.country:
address += ", " + self.country.name
self.location = address_to_grid_based_point(address)
if self.address:
address = self.address
if self.country:
address += ", " + self.country.name
self.location = address_to_grid_based_point(address)
super().save(*args, **kwargs)

@property
Expand Down
7 changes: 4 additions & 3 deletions project_novis/callsign/utils.py
Expand Up @@ -87,7 +87,7 @@ class WikidataObjectField(models.CharField):
def __init__(self, *args, **kwargs):
kwargs['max_length'] = 16
super().__init__(*args, **kwargs)

def deconstruct(self):
name, path, args, kwargs = super().deconstruct()
del kwargs['max_length']
Expand Down Expand Up @@ -123,8 +123,8 @@ def generate_aprs_passcode(callsign: str) -> int:
length = len(callsign)

while i < length:
hash_value ^= ord(callsign[i:i+1]) << 8
hash_value ^= ord(callsign[i+1:i+1+1])
hash_value ^= ord(callsign[i:i + 1]) << 8
hash_value ^= ord(callsign[i + 1:i + 1 + 1])
i += 2

return hash_value & 0x7fff
Expand Down Expand Up @@ -221,6 +221,7 @@ def address_to_point(address: str, provider: str = "arcgis", session=None, use_c
g = _geocoder(address, session=session)
else:
g = _geocoder(address)
# TODO handle no results returned
return Point(g.lng, g.lat)


Expand Down

0 comments on commit ace7dcd

Please sign in to comment.