@@ -107,27 +107,29 @@ def facility(self):
107
107
108
108
@property
109
109
def paperless_approval (self ):
110
+ """
111
+ This will return 'True' if both PI and User email addresses share the same host
112
+ We'll be using email spoofing from within VM, the MTA was set by IT.
113
+ This assumes that EMAIL_HOST config variable has the form of "mail.server.tld"
114
+ and the user and PI addresses are "@server.tld"...
115
+ """
116
+ email_host = "." .join (settings .EMAIL_HOST .split ("." )[1 :])
110
117
result_user = False
111
118
result_pi = False
112
119
if self .pi is not None and self .pi .email != "Unset" :
113
- if (
114
- not ('"' in self .pi .email )
115
- and self .pi .email .split ("@" )[1 ] == settings .EMAIL_HOST
116
- ):
120
+ if not ('"' in self .pi .email ) and self .pi .email .split ("@" )[1 ] == email_host :
117
121
result_pi = True
118
- if (
119
- not ('"' in self .email )
120
- and self .email .split ("@" )[1 ] == settings .EMAIL_HOST
121
- ):
122
+ if not ('"' in self .email ) and self .email .split ("@" )[1 ] == email_host :
122
123
result_user = True
123
124
return result_user and result_pi
124
125
125
126
def __str__ (self ):
127
+ email_host = "." .join (settings .EMAIL_HOST .split ("." )[1 :])
126
128
this_user_email = self .email
127
129
if not '"' in this_user_email :
128
130
# email addresses are valid with more than one 'at' symbol, only if enquoted,
129
131
# we avoid the following in such cases. See: https://stackoverflow.com/a/12355882
130
- if this_user_email .split ("@" )[1 ] == settings . EMAIL_HOST :
132
+ if this_user_email .split ("@" )[1 ] == email_host :
131
133
this_user_email = this_user_email .split ("@" )[0 ] + "@~"
132
134
if self .phone is not None :
133
135
this_user = (
0 commit comments