2026-07-06 17:30:34 +08:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
|
from wagtail.models import Page
|
|
|
|
|
|
2026-07-06 22:57:08 +08:00
|
|
|
from core.models import ScenarioPage, SkeletonProjectPage, ArticlePage
|
|
|
|
|
|
2026-07-06 17:30:34 +08:00
|
|
|
|
|
|
|
|
class HomePage(Page):
|
2026-07-06 22:57:08 +08:00
|
|
|
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
|