feat: add public homepage and downloads
This commit is contained in:
+62
-1
@@ -1,3 +1,64 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
from .models import DownloadRelease
|
||||
|
||||
|
||||
@admin.register(DownloadRelease)
|
||||
class DownloadReleaseAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"platform",
|
||||
"version",
|
||||
"is_current",
|
||||
"download_source",
|
||||
"sha256_short",
|
||||
"updated_at",
|
||||
)
|
||||
list_filter = ("platform", "is_current")
|
||||
search_fields = ("version", "sha256", "external_url", "file")
|
||||
readonly_fields = ("created_at", "updated_at")
|
||||
fieldsets = (
|
||||
(
|
||||
"版本信息",
|
||||
{
|
||||
"fields": (
|
||||
"platform",
|
||||
"version",
|
||||
"is_current",
|
||||
"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]}..."
|
||||
|
||||
Reference in New Issue
Block a user