feat: add import template download link

This commit is contained in:
QiuSW
2026-07-08 16:29:48 +08:00
parent f1b34f8466
commit 5cdbd87ce2
13 changed files with 335 additions and 19 deletions
+23 -1
View File
@@ -19,7 +19,7 @@ from apps.billing.services import (
from apps.users.models import ApiKey
from .forms import ApiKeyCreateForm, RechargeCreateForm
from .models import DownloadRelease
from .models import DownloadRelease, ImportTemplate
NEW_API_KEY_SESSION_KEY = "portal_new_api_key"
@@ -98,6 +98,14 @@ def paginate_records(request, queryset):
}
def build_public_download_url(request, url: str) -> str:
if not url:
return ""
if url.startswith("/"):
return request.build_absolute_uri(url)
return url
class HomeView(TemplateView):
template_name = "portal/home.html"
@@ -111,6 +119,20 @@ class HomeView(TemplateView):
.order_by("-created_at", "-id")
.first()
)
current_import_template = (
ImportTemplate.objects.filter(is_current=True)
.order_by("-created_at", "-id")
.first()
)
context["current_import_template"] = current_import_template
context["current_import_template_download_url"] = (
build_public_download_url(
self.request,
current_import_template.download_url
if current_import_template is not None
else "",
)
)
return context