From b0278c5649c4cabc34eaecc3e31822994356ef2e Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 8 Mar 2018 15:13:50 +0000 Subject: [PATCH] Refactor to put user logic inside class --- app/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/utils.py b/app/utils.py index 4d108fbb9..65e33ee57 100644 --- a/app/utils.py +++ b/app/utils.py @@ -462,6 +462,14 @@ class GovernmentDomain: self.agreement_signed ) = self._get_details_of_domain() + @classmethod + def from_user(cls, user): + return cls(user.email_address if user.is_authenticated else '') + + @classmethod + def from_current_user(cls): + return cls.from_user(current_user) + @staticmethod def get_matching_function(email_address_or_domain):