diff options
author | lxf <sng@luxagraf.net> | 2019-05-25 15:10:38 +0000 |
---|---|---|
committer | lxf <sng@luxagraf.net> | 2019-05-25 15:10:38 +0000 |
commit | dd09ca3810ea0798899870930c3efb388b776a7c (patch) | |
tree | 0cf0f8ba6c44b774a0867f48fce9cafb96620974 /app/sightings | |
parent | fc037fa9bf0eee9920ae1da14ce80d594f39cba4 (diff) |
made some changes to use new checkin model
Diffstat (limited to 'app/sightings')
-rw-r--r-- | app/sightings/models.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/sightings/models.py b/app/sightings/models.py index 3852b1c..7527615 100644 --- a/app/sightings/models.py +++ b/app/sightings/models.py @@ -198,9 +198,12 @@ class Sighting(models.Model): if not self.point: self.point = Sighting.objects.latest().point try: - self.location = Location.objects.filter( - geometry__contains=self.point - ).get() + self.location = Location.objects.filter(geometry__contains=self.point).get() + except Location.MultipleObjectsReturned: + for l in Location.objects.filter(geometry__contains=self.point): + if l.parent: + self.location = l + break except Location.DoesNotExist: raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL)) self.ap_common_name = self.ap.common_name |