| 354 | |
| 355 | |
| 356 | class ProjectDomainRemoveForm(StarletteForm): |
| 357 | domain_id = HiddenField(validators=[DataRequired()]) |
| 358 | confirm = StringField(_l("Confirmation"), validators=[DataRequired()]) |
| 359 | |
| 360 | def __init__(self, *args, project: Project, domains: list[Domain], **kwargs): |
| 361 | super().__init__(*args, **kwargs) |
| 362 | self.project = project |
| 363 | self.domains = domains |
| 364 | |
| 365 | def validate_domain_id(self, field): |
| 366 | domain = next( |
| 367 | (domain for domain in self.domains if domain.id == int(field.data)), None |
| 368 | ) |
| 369 | if not domain: |
| 370 | raise ValidationError(_("Domain not found.")) |
| 371 | |
| 372 | def validate_confirm(self, field): |
| 373 | domain = next( |
| 374 | ( |
| 375 | domain |
| 376 | for domain in self.domains |
| 377 | if domain.id == int(self.domain_id.data) |
| 378 | ), |
| 379 | None, |
| 380 | ) |
| 381 | if not domain: |
| 382 | raise ValidationError(_("Domain not found.")) |
| 383 | if field.data != domain.hostname: |
| 384 | raise ValidationError(_("Domain confirmation did not match.")) |
| 385 | |
| 386 | |
| 387 | class ProjectDomainVerifyForm(StarletteForm): |
nothing calls this directly
no outgoing calls
no test coverage detected