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

@ -47,12 +47,30 @@ class CloudProviderAdmin(SortableAdminMixin, admin.ModelAdmin):
inlines = [OfferingInline]
ordering = ("order",)
fieldsets = (
(None, {"fields": ("name", "slug", "description", "order")}),
(
"Images",
{
"fields": (
"image_library",
"logo",
), # New image library field and legacy field
"description": "Use the Image Library field for new images. Legacy field will be removed after migration.",
},
),
(
"Contact Information",
{"fields": ("website", "linkedin", "phone", "email", "address")},
),
("Settings", {"fields": ("is_featured", "disable_listing")}),
)
def logo_preview(self, obj):
"""Display logo preview in admin list view"""
if obj.logo:
return format_html(
'<img src="{}" style="max-height: 50px;"/>', obj.logo.url
)
logo = obj.get_logo
if logo:
return format_html('<img src="{}" style="max-height: 50px;"/>', logo.url)
return "No logo"
logo_preview.short_description = "Logo"
@ -75,12 +93,34 @@ class ConsultingPartnerAdmin(SortableAdminMixin, admin.ModelAdmin):
filter_horizontal = ("services", "cloud_providers")
ordering = ("order",)
fieldsets = (
(None, {"fields": ("name", "slug", "description", "order")}),
(
"Images",
{
"fields": (
"image_library",
"logo",
), # New image library field and legacy field
"description": "Use the Image Library field for new images. Legacy field will be removed after migration.",
},
),
(
"Contact Information",
{"fields": ("website", "linkedin", "phone", "email", "address")},
),
(
"Relations",
{"fields": ("services", "cloud_providers"), "classes": ("collapse",)},
),
("Settings", {"fields": ("is_featured", "disable_listing")}),
)
def logo_preview(self, obj):
"""Display logo preview in admin list view"""
if obj.logo:
return format_html(
'<img src="{}" style="max-height: 50px;"/>', obj.logo.url
)
logo = obj.get_logo
if logo:
return format_html('<img src="{}" style="max-height: 50px;"/>', logo.url)
return "No logo"
logo_preview.short_description = "Logo"