diff options
author | luxagraf <sng@luxagraf.net> | 2017-10-06 10:38:50 -0700 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2017-10-06 10:38:50 -0700 |
commit | 57eaedbddadef9e0a3a5651f57a9ad8a2049cc61 (patch) | |
tree | 16c6ad8a1858c16d7b079b8134358a46bfd0e592 /app/photos/models.py | |
parent | 54591c4c0f90cd221f30136c82039d25eab2eb8c (diff) | |
parent | 8b1987da496bde09a66e32c44a296621fe779f5b (diff) |
Merge branch 'master' of ssh://stats:/home/lxf/git/luxagraf
Diffstat (limited to 'app/photos/models.py')
-rw-r--r-- | app/photos/models.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/photos/models.py b/app/photos/models.py index 0d123c3..603e2d1 100644 --- a/app/photos/models.py +++ b/app/photos/models.py @@ -164,6 +164,18 @@ class LuxImage(models.Model): else: return False + def save(self): + 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() + + @receiver(post_save, sender=LuxImage) def post_save_events(sender, update_fields, created, instance, **kwargs): if instance.exif_raw == '': @@ -172,7 +184,7 @@ def post_save_events(sender, update_fields, created, instance, **kwargs): img = Image.open(instance.image.path) instance.height = img.height instance.width = img.width - instance = readexif(instance) + #instance = readexif(instance) post_save.disconnect(post_save_events, sender=LuxImage) instance.save() post_save.connect(post_save_events, sender=LuxImage) |