Phase 1 评审修复:M2M clean() 校验 + 正确页面树测试(20 tests) + AGENTS.md 同步

This commit is contained in:
ila
2026-07-06 21:00:09 +08:00
parent a2d2cd226d
commit 6ec28c8374
5 changed files with 352 additions and 46 deletions
+16
View File
@@ -1,4 +1,5 @@
from django.db import models
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator, MaxValueValidator
from modelcluster.fields import ParentalManyToManyField
from wagtail.models import Page
@@ -234,6 +235,21 @@ class SkeletonProjectPage(Page):
),
]
def clean(self):
super().clean()
if self.id is not None:
errors = {}
if not self.scenarios.exists():
errors["scenarios"] = ValidationError(
"At least one scenario is required."
)
if not self.languages.exists():
errors["languages"] = ValidationError(
"At least one language is required."
)
if errors:
raise ValidationError(errors)
class Meta:
verbose_name = "Skeleton Project"