From 44f53429a7d27f45a6d19236b13493718273fe3a Mon Sep 17 00:00:00 2001 From: luxagraf Date: Fri, 29 Sep 2017 13:05:20 -0500 Subject: made location list editable --- app/photos/admin.py | 1 + app/photos/models.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/photos/admin.py b/app/photos/admin.py index fbedc73..3211a06 100644 --- a/app/photos/admin.py +++ b/app/photos/admin.py @@ -29,6 +29,7 @@ class LuxImageAdmin(OSMGeoAdmin): list_display = ('pk', 'admin_thumbnail', 'pub_date', 'location') list_filter = ('pub_date', 'location') search_fields = ['title', 'caption'] + list_editable = ('location',) # Options for OSM map Using custom ESRI topo map default_lon = -9285175 default_lat = 4025046 diff --git a/app/photos/models.py b/app/photos/models.py index 0d123c3..039ce47 100644 --- a/app/photos/models.py +++ b/app/photos/models.py @@ -172,7 +172,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) -- cgit v1.2.3-70-g09d2 From 8b1987da496bde09a66e32c44a296621fe779f5b Mon Sep 17 00:00:00 2001 From: luxagraf Date: Fri, 29 Sep 2017 14:25:22 -0500 Subject: added auto-location to photo uploads --- app/photos/models.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app') diff --git a/app/photos/models.py b/app/photos/models.py index 039ce47..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 == '': -- cgit v1.2.3-70-g09d2