diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2013-04-01 20:39:57 -0500 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2013-04-01 20:39:57 -0500 |
| commit | 62dce2424108b906c3dfafa748632338dd111ac5 (patch) | |
| tree | bfeaf9ee99ae8bf39fc6db03d6f587fb3334bb9c /contact | |
| parent | ec6949e878f3f518cd8270c2cb0e3be9454ecc2b (diff) | |
Fixed a unicode encoding bug in the contact form.
Also removed duplicated code.
Diffstat (limited to 'contact')
| -rw-r--r-- | contact/forms.py | 5 | ||||
| -rw-r--r-- | contact/tests.py | 9 |
2 files changed, 10 insertions, 4 deletions
diff --git a/contact/forms.py b/contact/forms.py index 0c0e4f20..b8ae31f9 100644 --- a/contact/forms.py +++ b/contact/forms.py @@ -10,7 +10,7 @@ class BaseContactForm(AkismetContactForm): return "[Contact form] " + self.cleaned_data["message_subject"] def message(self): - return "From: %(name)s <%(email)s>\n\n%(body)s" % self.cleaned_data + return u"From: {name} <{email}>\n\n{body}".format(**self.cleaned_data) class FoundationContactForm(BaseContactForm): recipient_list = ["dsf-board@googlegroups.com"] @@ -27,6 +27,3 @@ class CoCFeedbackForm(BaseContactForm): def subject(self): return "Django Code of Conduct feedback" - - def message(self): - return "From: {name} <{email}>\n\n{body}".format(**self.cleaned_data) diff --git a/contact/tests.py b/contact/tests.py index df18a68a..f0db8d72 100644 --- a/contact/tests.py +++ b/contact/tests.py @@ -24,3 +24,12 @@ class ContactFormTests(TestCase): resp = self.client.post('/contact/code-of-conduct/', data) self.assertRedirects(resp, '/conduct/') self.assertEqual(mail.outbox[-1].subject, 'Django Code of Conduct feedback') + + def test_coc_contact_unicode(self): + data = { + 'name': 'A. Random Hacker', + 'email': 'a.random@example.com', + 'body': u'Hello, \u2603!' + } + resp = self.client.post('/contact/code-of-conduct/', data) + self.assertRedirects(resp, '/conduct/') |
