This commit is contained in:
Tobias Brunner 2025-01-27 15:14:58 +01:00
parent 4c6732f9d0
commit 79a8c6f280
No known key found for this signature in database
13 changed files with 169 additions and 47 deletions

View file

@ -1,12 +1,20 @@
from django.contrib import admin
from django.utils.html import format_html
from .models import CloudProvider, Country, ServiceLevel, Service
@admin.register(CloudProvider)
class CloudProviderAdmin(admin.ModelAdmin):
list_display = ("name",)
list_display = ("name", "logo_preview")
search_fields = ("name",)
def logo_preview(self, obj):
if obj.logo:
return format_html(
'<img src="{}" style="max-height: 50px;"/>', obj.logo.url
)
return "No logo"
@admin.register(Country)
class CountryAdmin(admin.ModelAdmin):
@ -22,7 +30,14 @@ class ServiceLevelAdmin(admin.ModelAdmin):
@admin.register(Service)
class ServiceAdmin(admin.ModelAdmin):
list_display = ("name", "cloud_provider", "service_level", "price")
list_display = ("name", "cloud_provider", "service_level", "price", "logo_preview")
list_filter = ("cloud_provider", "service_level", "countries")
search_fields = ("name", "description")
filter_horizontal = ("countries",)
def logo_preview(self, obj):
if obj.logo:
return format_html(
'<img src="{}" style="max-height: 50px;"/>', obj.logo.url
)
return "No logo"