Phase 2: T-201 至 T-206 前台 MVP 全部实现(11 templates + CSS + 31 tests)
This commit is contained in:
+18
-1
@@ -2,6 +2,23 @@ from django.db import models
|
||||
|
||||
from wagtail.models import Page
|
||||
|
||||
from core.models import ScenarioPage, SkeletonProjectPage, ArticlePage
|
||||
|
||||
|
||||
class HomePage(Page):
|
||||
pass
|
||||
parent_page_types = ["wagtailcore.Page"]
|
||||
max_count = 1
|
||||
|
||||
def get_context(self, request, *args, **kwargs):
|
||||
context = super().get_context(request, *args, **kwargs)
|
||||
context["scenarios"] = ScenarioPage.objects.live()
|
||||
context["featured_projects"] = (
|
||||
SkeletonProjectPage.objects.live().filter(is_featured=True)
|
||||
.prefetch_related("scenarios", "languages")
|
||||
.order_by("-first_published_at")[:6]
|
||||
)
|
||||
context["latest_articles"] = (
|
||||
ArticlePage.objects.live()
|
||||
.order_by("-first_published_at")[:4]
|
||||
)
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user