Add canonical domain info to agreement class

Because we alias domains (eg `foo.gsi.gov.uk` to `foo.gov.uk`, or where
a local council has multiple domains) it could be hard to look up a
brand (which has one domain field).

Therefore we need a way of getting the canonical domain from a user’s
email address, which we can later use to look up their branding.
This commit is contained in:
Chris Hill-Scott
2018-09-03 10:46:52 +01:00
parent f72df546c8
commit 47c9b71fa8
2 changed files with 20 additions and 1 deletions

View File

@@ -445,7 +445,8 @@ class AgreementInfo:
(
self.owner,
self.crown_status,
self.agreement_signed
self.agreement_signed,
self.canonical_domain,
) = self._get_info()
@classmethod
@@ -584,13 +585,16 @@ class AgreementInfo:
details = self.domains.get(self._match) or {}
if isinstance(details, str):
self.is_canonical = False
return AgreementInfo(details)._get_info()
elif isinstance(details, dict):
self.is_canonical = bool(details)
return(
details.get("owner"),
details.get("crown"),
details.get("agreement_signed"),
self._match,
)