summaryrefslogtreecommitdiff
path: root/app/media/admin.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2022-12-02 14:16:08 -0600
committerluxagraf <sng@luxagraf.net>2022-12-02 14:16:08 -0600
commit656505098a80e653319236ac302fd6dd9f485b33 (patch)
tree03fe2f552496e2a2b459f5227dc11273d1b94211 /app/media/admin.py
parentbf2fa131cba6430ba93f584f4693c3444e0c455f (diff)
reset migrations to zero out some changes (deleting the geodata for
example)
Diffstat (limited to 'app/media/admin.py')
-rw-r--r--app/media/admin.py49
1 files changed, 38 insertions, 11 deletions
diff --git a/app/media/admin.py b/app/media/admin.py
index 12d0509..50eb879 100644
--- a/app/media/admin.py
+++ b/app/media/admin.py
@@ -1,12 +1,15 @@
from django.contrib import admin
+from django import forms
from django.contrib.gis.admin import OSMGeoAdmin
-
-from .models import LuxImage, LuxGallery, LuxImageSize, LuxVideo, LuxAudio
+from .models import LuxImage, LuxGallery, LuxImageSize, LuxVideo
+from django.shortcuts import render
+from django.contrib.admin import helpers
+from django.http import HttpResponseRedirect
@admin.register(LuxImageSize)
class LuxImageSizeAdmin(OSMGeoAdmin):
- list_display = ('name', 'width', 'height', 'quality')
+ list_display = ('name','slug', 'width', 'height', 'quality')
@admin.register(LuxVideo)
@@ -18,20 +21,44 @@ class LuxVideoAdmin(OSMGeoAdmin):
class LuxImageAdmin(OSMGeoAdmin):
list_display = ('pk', 'admin_thumbnail', 'pub_date', 'caption')
list_filter = ('pub_date',)
- search_fields = ['title', 'caption']
+ search_fields = ['title', 'caption', 'alt']
# Options for OSM map Using custom ESRI topo map
+ default_lon = -9285175
+ default_lat = 4025046
+ default_zoom = 6
+ units = True
+ scrollable = False
+ map_width = 700
+ map_height = 425
+ map_template = 'gis/admin/osm.html'
+ openlayers_url = '/static/admin/js/OpenLayers.js'
fieldsets = (
(None, {
- 'fields': ('title', ('image'), 'pub_date', 'sizes', 'alt', 'caption', ('is_public'), ('photo_credit_source', 'photo_credit_url'))
+ 'fields': (
+ 'image',
+ 'alt',
+ 'sizes',
+ 'caption',
+ 'pub_date',
+ 'title',
+ )
+ }),
+ ('Exif and Other Data', {
+ 'classes': ('collapse',),
+ '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')
-
-
-@admin.register(LuxAudio)
-class LuxAudioAdmin(OSMGeoAdmin):
- list_display = ('pk', 'title', 'pub_date')
- list_filter = ('pub_date',)