Commit 067f11a2 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler Committed by Arkadiusz Hiler
Browse files

models.Person: Quote name in email_name() properly



If a person sends out emails with their name using 'Last, First'
notation, then when we compose email_name() it looks like:

'Last, First <address@email.tld>'

When test results are sent out, the above gets appended directly to the
recipient fields, resulting in emails being sent to 'Last@localhost' and
'First <address@email.tld>'.

Let's fix that by always putting the name in the quotes, just like that:

'"Last, First" <address@email.tld>'
Signed-off-by: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 1cb2039c
......@@ -56,7 +56,7 @@ class Person(models.Model):
def email_name(self):
if (self.name):
return "%s <%s>" % (self.name, self.email)
return "\"%s\" <%s>" % (self.name, self.email)
else:
return self.email
......
......@@ -57,3 +57,10 @@ class SubmitterCompletionTest(TestCase):
self.assertEqual(response.status_code, 200)
data = json.loads(response.content.decode())
self.assertEqual(len(data), 5)
class PersonModelTest(TestCase):
def testEmailNameQuoted(self):
p = Person(name="Name, Test", email="test@example.com")
self.assertEqual(p.email_name(), '"Name, Test" <test@example.com>')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment