Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed a unicode encoding bug in the contact form.

Also removed duplicated code.
  • Loading branch information...
commit 62dce2424108b906c3dfafa748632338dd111ac5 1 parent ec6949e
@jacobian jacobian authored
Showing with 10 additions and 4 deletions.
  1. +1 −4 contact/forms.py
  2. +9 −0 contact/tests.py
View
5 contact/forms.py
@@ -10,7 +10,7 @@ def subject(self):
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 @@ def __init__(self, *args, **kwargs):
def subject(self):
return "Django Code of Conduct feedback"
-
- def message(self):
- return "From: {name} <{email}>\n\n{body}".format(**self.cleaned_data)
View
9 contact/tests.py
@@ -24,3 +24,12 @@ def test_coc_contact(self):
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/')
Please sign in to comment.
Something went wrong with that request. Please try again.