Skip to content

Commit

Permalink
chore: opt admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Jan 11, 2024
1 parent f53e675 commit 5df53e1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion apps/sspanel/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from typing import Any

from django.contrib import admin
from django.contrib.auth.models import Group
from django.db.models.query import QuerySet
from django.http.request import HttpRequest

from . import models

Expand Down Expand Up @@ -124,10 +128,19 @@ class TicketMessageInline(admin.TabularInline):

class TicketAdmin(admin.ModelAdmin):
inlines = [TicketMessageInline]
list_display = ["user", "title", "status_with_message_count", "updated_at"]
list_display = ["user", "title", "status_info", "updated_at"]
list_filter = ["status"]
search_fields = ["title", "user"]
readonly_fields = ["updated_at"]
list_per_page = 10

@admin.display(description="状态")
def status_info(self, instance):
return instance.status_with_message_count

def get_queryset(self, request: HttpRequest) -> QuerySet[Any]:
qs = super().get_queryset(request).prefetch_related("messages")
return qs


# Register your models here.
Expand Down

0 comments on commit 5df53e1

Please sign in to comment.