feat: add products/cases page models and forms lead-capture app

- apps/products: ProductIndexPage/ProductPage
- apps/cases: CaseStudyIndexPage/CaseStudyPage
- apps/forms: FormDefinition/FormDefinitionField/Lead + submit API
- core/blocks: CaseStudyBlock, FormBlock (with API representation)
- register new apps, custom leads API route, migrations
This commit is contained in:
2026-08-06 16:04:21 +08:00
parent 7f51a31150
commit 12f7caa158
25 changed files with 618 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
"""产品栏目与产品详情页。详见 documents/设计方案分析与完善版.md §2.5 页面树结构。"""
from django.db import models
from wagtail.admin.panels import FieldPanel
from wagtail.fields import StreamField
from wagtail.search import index
from apps.core.blocks import COMMON_BLOCKS
from apps.core.models import SEOablePage
class ProductIndexPage(SEOablePage):
"""产品栏目列表页,子页面为 ProductPage。"""
intro = models.TextField(blank=True, verbose_name="栏目简介")
content_panels = SEOablePage.content_panels + [
FieldPanel("intro"),
]
subpage_types = ["products.ProductPage"]
parent_page_types = ["home.HomePage"]
class Meta:
verbose_name = "产品栏目页"
def get_context(self, request, *args, **kwargs):
context = super().get_context(request, *args, **kwargs)
context["products"] = (
ProductPage.objects.live().descendant_of(self).order_by("path")
)
return context
class ProductPage(SEOablePage):
"""单个产品详情页。"""
summary = models.CharField(max_length=250, blank=True, verbose_name="产品简介")
cover_image = models.ForeignKey(
"wagtailimages.Image",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
verbose_name="产品图片",
)
body = StreamField(COMMON_BLOCKS, use_json_field=True, blank=True)
search_fields = SEOablePage.search_fields + [
index.SearchField("summary"),
index.SearchField("body"),
]
content_panels = SEOablePage.content_panels + [
FieldPanel("summary"),
FieldPanel("cover_image"),
FieldPanel("body"),
]
parent_page_types = ["products.ProductIndexPage"]
subpage_types = []
class Meta:
verbose_name = "产品页"