Phase 1 评审修复:M2M clean() 校验 + 正确页面树测试(20 tests) + AGENTS.md 同步
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user