image library migration step 1
All checks were successful
Build and Deploy / build (push) Successful in 1m7s
Django Tests / test (push) Successful in 1m10s
Build and Deploy / deploy (push) Successful in 6s

This commit is contained in:
Tobias Brunner 2025-07-04 17:26:09 +02:00
parent 07bea333bc
commit 1a2bbb1c35
No known key found for this signature in database
23 changed files with 413 additions and 57 deletions

View file

@ -61,12 +61,47 @@ class ArticleAdmin(admin.ModelAdmin):
readonly_fields = ("created_at", "updated_at")
ordering = ("-article_date",)
fieldsets = (
(None, {"fields": ("title", "slug", "excerpt", "content", "meta_keywords")}),
(
"Images",
{
"fields": (
"image_library",
"image",
), # New image library field and legacy field
"description": "Use the Image Library field for new images. Legacy field will be removed after migration.",
},
),
(
"Publishing",
{"fields": ("author", "article_date", "is_published", "is_featured")},
),
(
"Relations",
{
"fields": (
"related_service",
"related_consulting_partner",
"related_cloud_provider",
),
"classes": ("collapse",),
},
),
(
"Metadata",
{
"fields": ("created_at", "updated_at"),
"classes": ("collapse",),
},
),
)
def image_preview(self, obj):
"""Display image preview in admin list view"""
if obj.image:
return format_html(
'<img src="{}" style="max-height: 50px;"/>', obj.image.url
)
image = obj.get_image
if image:
return format_html('<img src="{}" style="max-height: 50px;"/>', image.url)
return "No image"
image_preview.short_description = "Image"