MCPcopy Create free account
hub / github.com/hunvreus/devpush / ProjectDomainRemoveForm

Class ProjectDomainRemoveForm

app/forms/project.py:356–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354
355
356class 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
387class ProjectDomainVerifyForm(StarletteForm):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected