allow manual ordering of cloud provider
All checks were successful
Build and Deploy / build (push) Successful in 50s
Build and Deploy / deploy (push) Successful in 4s

This commit is contained in:
Tobias Brunner 2025-03-12 06:41:33 +01:00
parent 7bd09ec6aa
commit 3f6fc4a86e
No known key found for this signature in database
4 changed files with 37 additions and 3 deletions

View file

@ -68,11 +68,19 @@ class CategoryAdmin(admin.ModelAdmin):
@admin.register(CloudProvider)
class CloudProviderAdmin(admin.ModelAdmin):
list_display = ("name", "slug", "logo_preview", "disable_listing", "is_featured")
class CloudProviderAdmin(SortableAdminMixin, admin.ModelAdmin):
list_display = (
"name",
"slug",
"logo_preview",
"disable_listing",
"is_featured",
"order",
)
search_fields = ("name", "description")
prepopulated_fields = {"slug": ("name",)}
inlines = [OfferingInline]
ordering = ("order",)
def logo_preview(self, obj):
if obj.logo:

View file

@ -0,0 +1,22 @@
# Generated by Django 5.1.5 on 2025-03-12 05:37
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("services", "0019_alter_websitefaq_options_websitefaq_order"),
]
operations = [
migrations.AlterModelOptions(
name="cloudprovider",
options={"ordering": ["order"]},
),
migrations.AddField(
model_name="cloudprovider",
name="order",
field=models.IntegerField(default=0),
),
]

View file

@ -97,9 +97,13 @@ class CloudProvider(models.Model):
null=True,
blank=True,
)
order = models.IntegerField(default=0)
is_featured = models.BooleanField(default=False)
disable_listing = models.BooleanField(default=False)
class Meta:
ordering = ["order"]
def __str__(self):
return self.name

View file

@ -9,7 +9,7 @@ from hub.services.models import (
def provider_list(request):
providers = (
CloudProvider.objects.filter(disable_listing=False)
.order_by("name")
.order_by("order")
.prefetch_related("offerings", "consulting_partners")
)