Skip to content

Commit 60c879a

Browse files
committed
Merge pull request #1697 from Eskimon/hotfix_1681
Hotfix réponse sur MP avec titre unicode
2 parents 323184a + 4563b07 commit 60c879a

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

zds/mp/tests/tests_views.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,50 @@ def test_fail_answer_with_no_right(self):
582582
self.assertEqual(403, response.status_code)
583583
self.assertEqual(2, PrivatePost.objects.all().count())
584584

585+
def test_unicode_title_answer(self):
586+
"""To test unicode title."""
587+
588+
unicodeTopic = PrivateTopicFactory(author=self.profile1.user,
589+
title=u'Title with accent àéè')
590+
unicodeTopic.participants.add(self.profile2.user)
591+
unicodePost = PrivatePostFactory(
592+
privatetopic=unicodeTopic,
593+
author=self.profile1.user,
594+
position_in_topic=1)
595+
596+
response = self.client.post(
597+
reverse('zds.mp.views.answer')
598+
+ '?sujet=' + str(unicodeTopic.pk),
599+
{
600+
'text': 'answer',
601+
'last_post': unicodePost.pk
602+
},
603+
follow=True
604+
)
605+
self.assertEqual(response.status_code, 200)
606+
607+
def test_unicode_subtitle_answer(self):
608+
"""To test unicode subtitle."""
609+
610+
unicodeTopic = PrivateTopicFactory(author=self.profile1.user,
611+
subtitle=u'Subtitle with accent àéè')
612+
unicodeTopic.participants.add(self.profile2.user)
613+
unicodePost = PrivatePostFactory(
614+
privatetopic=unicodeTopic,
615+
author=self.profile1.user,
616+
position_in_topic=1)
617+
618+
response = self.client.post(
619+
reverse('zds.mp.views.answer')
620+
+ '?sujet=' + str(unicodeTopic.pk),
621+
{
622+
'text': 'answer',
623+
'last_post': unicodePost.pk
624+
},
625+
follow=True
626+
)
627+
self.assertEqual(response.status_code, 200)
628+
585629

586630
class EditPostViewTest(TestCase):
587631

zds/mp/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ def answer(request):
308308
g_topic.save()
309309

310310
# send email
311-
subject = "{} - MP : {}".format(settings.ZDS_APP['site']['abbr'], g_topic.title)
312-
from_email = "{} <{}>".format(settings.ZDS_APP['site']['litteral_name'],
313-
settings.ZDS_APP['site']['email_noreply'])
311+
subject = u"{} - MP : {}".format(settings.ZDS_APP['site']['abbr'], g_topic.title)
312+
from_email = u"{} <{}>".format(settings.ZDS_APP['site']['litteral_name'],
313+
settings.ZDS_APP['site']['email_noreply'])
314314
parts = list(g_topic.participants.all())
315315
parts.append(g_topic.author)
316316
parts.remove(request.user)

0 commit comments

Comments
 (0)