Fixed #26779 -- Added extra_context parameter to admin's i18n_javascript view.

This commit is contained in:
Shabda Raaj 2016-06-19 16:21:58 +05:30 committed by Tim Graham
parent 2224a56631
commit b0acb1e73e
3 changed files with 10 additions and 1 deletions

View File

@ -314,9 +314,12 @@ class AdminSite(object):
request.current_app = self.name
return password_change_done(request, **defaults)
def i18n_javascript(self, request):
def i18n_javascript(self, request, extra_context=None):
"""
Displays the i18n JavaScript that the Django admin requires.
`extra_context` is unused but present for consistency with the other
admin views.
"""
return JavaScriptCatalog.as_view(packages=['django.contrib.admin'])(request)

View File

@ -691,6 +691,10 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
response = self.client.get(reverse('admin:jsi18n'))
self.assertContains(response, 'Choisir une heure')
def test_jsi18n_with_context(self):
response = self.client.get(reverse('admin-extra-context:jsi18n'))
self.assertEqual(response.status_code, 200)
def test_L10N_deactivated(self):
"""
Check if L10N is deactivated, the JavaScript i18n view doesn't

View File

@ -12,5 +12,7 @@ urlpatterns = [
url(r'^test_admin/admin4/', customadmin.simple_site.urls),
url(r'^test_admin/admin5/', admin.site2.urls),
url(r'^test_admin/admin7/', admin.site7.urls),
# All admin views accept `extra_context` to allow adding it like this:
url(r'^test_admin/admin8/', (admin.site.get_urls(), 'admin', 'admin-extra-context'), {'extra_context': {}}),
url(r'^test_admin/has_permission_admin/', custom_has_permission_admin.site.urls),
]