Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #21324 -- Translate CSRF failure view
Thanks to Claude Paroz for the original patch.
- Loading branch information
Showing
5 changed files
with
89 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | ||
# This file is distributed under the same license as the PACKAGE package. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2007-09-15 19:15+0200\n" | ||
"PO-Revision-Date: 2010-05-12 12:41-0300\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <LL@li.org>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
|
||
#: views/csrf.py:98 | ||
msgid "Forbidden" | ||
msgstr "Verboden" | ||
|
||
#: views/csrf.py:99 | ||
msgid "CSRF verification failed. Request aborted." | ||
msgstr "CSRF-verificatie mislukt. Verzoek afgebroken." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.test import TestCase, override_settings, Client | ||
from django.utils.translation import override | ||
|
||
|
||
class CsrfViewTests(TestCase): | ||
urls = "view_tests.urls" | ||
|
||
@override_settings( | ||
USE_I18N=True, | ||
MIDDLEWARE_CLASSES=( | ||
'django.middleware.locale.LocaleMiddleware', | ||
'django.middleware.common.CommonMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
), | ||
) | ||
def test_translation(self): | ||
""" | ||
Test that an invalid request is rejected with a localized error message. | ||
""" | ||
self.client = Client(enforce_csrf_checks=True) | ||
|
||
response = self.client.post('/', HTTP_HOST='www.example.com') | ||
self.assertContains(response, "Forbidden", status_code=403) | ||
self.assertContains(response, | ||
"CSRF verification failed. Request aborted.", | ||
status_code=403) | ||
|
||
with self.settings(LANGUAGE_CODE='nl'), override('en-us'): | ||
response = self.client.post('/', HTTP_HOST='www.example.com') | ||
self.assertContains(response, "Verboden", status_code=403) | ||
self.assertContains(response, | ||
"CSRF-verificatie mislukt. Verzoek afgebroken.", | ||
status_code=403) |