Merge pull request #1069 from ostcar/reset_passwort_question
Make sure QuestionView.get_question_message is in a unicode context.
This commit is contained in:
commit
3fc531255f
@ -355,7 +355,7 @@ class QuestionView(RedirectView):
|
|||||||
"""
|
"""
|
||||||
Returns the question.
|
Returns the question.
|
||||||
"""
|
"""
|
||||||
return self.question_message
|
return unicode(self.question_message)
|
||||||
|
|
||||||
def get_answer_options(self):
|
def get_answer_options(self):
|
||||||
"""
|
"""
|
||||||
@ -376,13 +376,10 @@ class QuestionView(RedirectView):
|
|||||||
for option in self.get_answer_options()])
|
for option in self.get_answer_options()])
|
||||||
messages.warning(
|
messages.warning(
|
||||||
self.request,
|
self.request,
|
||||||
"""
|
'%(message)s<form action="%(url)s" method="post">'
|
||||||
%(message)s
|
'<input type="hidden" value="%(csrf)s" name="csrfmiddlewaretoken">'
|
||||||
<form action="%(url)s" method="post">
|
'%(option_fields)s</form>' % {
|
||||||
<input type="hidden" value="%(csrf)s" name="csrfmiddlewaretoken">
|
'message': self.get_question_message(),
|
||||||
%(option_fields)s
|
|
||||||
</form>
|
|
||||||
""" % {'message': self.get_question_message(),
|
|
||||||
'url': self.request.path,
|
'url': self.request.path,
|
||||||
'csrf': csrf(self.request)['csrf_token'],
|
'csrf': csrf(self.request)['csrf_token'],
|
||||||
'option_fields': option_fields})
|
'option_fields': option_fields})
|
||||||
|
@ -164,6 +164,9 @@ class QuestionViewTest(ViewTestCase):
|
|||||||
view.question_message = 'new_question'
|
view.question_message = 'new_question'
|
||||||
self.assertEqual(get_question_message(), 'new_question')
|
self.assertEqual(get_question_message(), 'new_question')
|
||||||
|
|
||||||
|
# Make sure it is unicode, so ugettext_lazy can work
|
||||||
|
self.assertIsInstance(get_question_message(), unicode)
|
||||||
|
|
||||||
def test_get_answer_options(self):
|
def test_get_answer_options(self):
|
||||||
view = views.QuestionView()
|
view = views.QuestionView()
|
||||||
get_answer_options = view.get_answer_options
|
get_answer_options = view.get_answer_options
|
||||||
@ -186,6 +189,9 @@ class QuestionViewTest(ViewTestCase):
|
|||||||
|
|
||||||
self.assertTrue(mock_messages.warning.called)
|
self.assertTrue(mock_messages.warning.called)
|
||||||
|
|
||||||
|
question = mock_messages.warning.call_args[0][1]
|
||||||
|
self.assertIn('the question', question)
|
||||||
|
|
||||||
|
|
||||||
def set_context(sender, request, context, **kwargs):
|
def set_context(sender, request, context, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user