allow manual ordering of cloud provider
This commit is contained in:
parent
7bd09ec6aa
commit
3f6fc4a86e
4 changed files with 37 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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")
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue