2026-07-02 09:07:15 +08:00
|
|
|
from django.contrib import admin
|
|
|
|
|
|
2026-07-06 23:18:08 +08:00
|
|
|
from .models import DownloadRelease
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(DownloadRelease)
|
|
|
|
|
class DownloadReleaseAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = (
|
|
|
|
|
"platform",
|
|
|
|
|
"version",
|
|
|
|
|
"is_current",
|
2026-07-08 15:38:59 +08:00
|
|
|
"force_update",
|
2026-07-06 23:18:08 +08:00
|
|
|
"download_source",
|
|
|
|
|
"sha256_short",
|
|
|
|
|
"updated_at",
|
|
|
|
|
)
|
2026-07-08 15:38:59 +08:00
|
|
|
list_filter = ("platform", "is_current", "force_update")
|
2026-07-06 23:18:08 +08:00
|
|
|
search_fields = ("version", "sha256", "external_url", "file")
|
|
|
|
|
readonly_fields = ("created_at", "updated_at")
|
|
|
|
|
fieldsets = (
|
|
|
|
|
(
|
|
|
|
|
"版本信息",
|
|
|
|
|
{
|
|
|
|
|
"fields": (
|
|
|
|
|
"platform",
|
|
|
|
|
"version",
|
|
|
|
|
"is_current",
|
2026-07-08 15:38:59 +08:00
|
|
|
"force_update",
|
2026-07-06 23:18:08 +08:00
|
|
|
"release_notes",
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
"下载配置",
|
|
|
|
|
{
|
|
|
|
|
"fields": (
|
|
|
|
|
"file",
|
|
|
|
|
"external_url",
|
|
|
|
|
"sha256",
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
"时间",
|
|
|
|
|
{
|
|
|
|
|
"fields": (
|
|
|
|
|
"created_at",
|
|
|
|
|
"updated_at",
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@admin.display(description="下载来源")
|
|
|
|
|
def download_source(self, obj):
|
|
|
|
|
if obj.external_url:
|
|
|
|
|
return "外部链接"
|
|
|
|
|
if obj.file:
|
|
|
|
|
return "本地文件"
|
|
|
|
|
return "未配置"
|
|
|
|
|
|
|
|
|
|
@admin.display(description="SHA256")
|
|
|
|
|
def sha256_short(self, obj):
|
|
|
|
|
if not obj.sha256:
|
|
|
|
|
return "-"
|
|
|
|
|
return f"{obj.sha256[:12]}..."
|