diff options
Diffstat (limited to 'app/media/models.py')
-rw-r--r-- | app/media/models.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/media/models.py b/app/media/models.py index d7b79c6..c266c4f 100644 --- a/app/media/models.py +++ b/app/media/models.py @@ -207,6 +207,12 @@ class LuxImage(models.Model): created = self.pk is None if not created: self.sizes_cache = ",".join(s.slug for s in self.sizes.all()) + if not self.point: + self.point = LuxImage.objects.latest().point + try: + self.location = Location.objects.filter(geometry__contains=self.point).get() + except Location.DoesNotExist: + raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL)) super(LuxImage, self).save() |