Remove domains from branding forms

We’re deprecating storing the domain as text on a branding in favour of
a database relationship between branding and organisation.

We need to do this now in order to remove the validation on these fields
(which depends on the data in `domains.yml`)
This commit is contained in:
Chris Hill-Scott
2019-04-04 11:09:09 +01:00
parent 9684e962ae
commit 470b8a2912
15 changed files with 48 additions and 298 deletions

View File

@@ -11,7 +11,7 @@ from wtforms.validators import Email
from app import formatted_list
from app.main._blacklisted_passwords import blacklisted_passwords
from app.utils import AgreementInfo, Spreadsheet, is_gov_user
from app.utils import Spreadsheet, is_gov_user
class Blacklist:
@@ -111,34 +111,3 @@ class DoesNotStartWithDoubleZero:
def __call__(self, form, field):
if field.data and field.data.startswith("00"):
raise ValidationError(self.message)
class KnownGovernmentDomain:
message = 'Not a known government domain (you might need to update domains.yml)'
def __call__(self, form, field):
if field.data and AgreementInfo(field.data).owner is None:
raise ValidationError(self.message)
class CanonicalGovernmentDomain:
message = 'Not {} domain (use {} if appropriate)'
def __call__(self, form, field):
if not field.data:
return
domain = AgreementInfo(field.data)
if not domain.is_canonical:
raise ValidationError(
self.message.format('a canonical', domain.canonical_domain)
)
if field.data != domain.canonical_domain:
raise ValidationError(
self.message.format('an organisation-level', domain.canonical_domain)
)