summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/media/admin.py23
-rw-r--r--app/media/models.py6
-rw-r--r--design/templates/admin/insert_images.html2
3 files changed, 27 insertions, 4 deletions
diff --git a/app/media/admin.py b/app/media/admin.py
index 9278c56..305ebd7 100644
--- a/app/media/admin.py
+++ b/app/media/admin.py
@@ -38,13 +38,30 @@ class LuxImageAdmin(OSMGeoAdmin):
fieldsets = (
(None, {
- 'fields': ('title', ('image'), 'pub_date', 'sizes', 'alt', 'caption', 'point', ('is_public'), ('photo_credit_source', 'photo_credit_url'))
+ 'fields': (
+ 'image',
+ 'alt',
+ 'sizes',
+ 'caption',
+ 'pub_date',
+ 'title',
+ )
}),
- ('Exif Data', {
+ ('Exif and Other Data', {
'classes': ('collapse',),
- 'fields': ('exif_raw', 'exif_aperture', 'exif_make', 'exif_model', 'exif_exposure', 'exif_iso', 'exif_focal_length', 'exif_lens', 'exif_date', 'height', 'width'),
+ 'fields': (
+ 'point',
+ ('is_public'),
+ ('photo_credit_source', 'photo_credit_url'),
+ 'exif_raw', 'exif_aperture', 'exif_make', 'exif_model', 'exif_exposure', 'exif_iso', 'exif_focal_length', 'exif_lens', 'exif_date', 'height', 'width'),
}),
)
+ def save_related(self, request, form, formsets, change):
+ super(LuxImageAdmin, self).save_related(request, form, formsets, change)
+ if not form.instance.sizes.all():
+ print("there are no sizes")
+ form.instance.sizes.add(*LuxImageSize.objects.filter(slug__in=["picwide-sm", "picwide-med", "picwide"]))
+
class Media:
js = ('image-preview.js', 'next-prev-links.js')
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()
diff --git a/design/templates/admin/insert_images.html b/design/templates/admin/insert_images.html
index fd33f07..5b5e601 100644
--- a/design/templates/admin/insert_images.html
+++ b/design/templates/admin/insert_images.html
@@ -71,7 +71,7 @@ function openInNewTab(url) {
</head>
<body>
<input type="button" value="Refresh" onClick="window.location.reload()">
- <button id="add_id_image" onClick="window.parent.open('/admin/photos/luximage/add/?_to_field=id&amp;_popup=1')">Upload Image
+ <button id="add_id_image" onClick="window.parent.open('/admin/media/luximage/add/?_to_field=id&amp;_popup=1')">Upload Image
<img src="/static/admin/img/icon-addlink.svg" alt="Add">
</button>
<div class="up-wrapper">{% for object in object_list %}