Sort gallery media by capture date instead of file name
All checks were successful
Docker / build (release) Successful in 9s

This commit is contained in:
krek0 2026-09-24 12:52:50 +02:00
parent 2f0c426dc1
commit f7415fb5f6
11 changed files with 314 additions and 33 deletions

View file

@ -45,14 +45,20 @@ class MediaAdmin(admin.ModelAdmin):
def get_queryset(self, request):
return super().get_queryset(request).prefetch_related("owner", "galleries")
def get_date_source(self, obj):
return obj.get_date_source_display() or "-"
get_owner.admin_order_field = "owner"
get_owner.short_description = _("owner")
get_galleries.short_description = _("Gallery")
get_date_source.admin_order_field = "date_source"
get_date_source.short_description = _("date source")
class PhotoAdmin(MediaAdmin):
list_display = ("title", "date_taken", "date_added", "is_public", "view_count", "admin_thumbnail", "get_owner", "get_galleries")
readonly_fields = ("date_taken",)
list_display = ("title", "date_taken", "get_date_source", "date_added", "is_public", "view_count", "admin_thumbnail", "get_owner", "get_galleries")
# The capture date is editable so that a camera set to the wrong time can be
# corrected; an edited date is then marked as manual and never overwritten.
model = Photo
@ -64,7 +70,7 @@ class TagAdmin(admin.ModelAdmin):
class VideoAdmin(MediaAdmin):
list_display = ("title", "date_added", "is_public", "get_owner", "get_galleries")
list_display = ("title", "date_taken", "get_date_source", "date_added", "is_public", "get_owner", "get_galleries")
model = Video