diff options
| author | Simon Willison <simon@simonwillison.net> | 2008-06-13 17:26:30 +0000 |
|---|---|---|
| committer | Simon Willison <simon@simonwillison.net> | 2008-06-13 17:26:30 +0000 |
| commit | faae7c0faf859edb9b60a1a45669b9127efa3f37 (patch) | |
| tree | 9b8ef43cfb2c21758fc1ee5105e28883b265a20e /tests | |
| parent | 725293d51ad6f5dbefb59fa9adfd76d09e1526c6 (diff) | |
newforms-admin: AdminSite index and display_login_form method can now take an optional extra_context argument, allowing you to inject extra template variables in to them from an over-ridden method on a subclass
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7631 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/admin_views/tests.py | 11 | ||||
| -rw-r--r-- | tests/templates/custom_admin/index.html | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index 1e3b334221..a70016d540 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -236,8 +236,19 @@ class AdminViewPermissionsTest(TestCase): request = self.client.get('/test_admin/admin/') self.assertTemplateUsed(request, 'custom_admin/index.html') self.assert_('Hello from a custom index template' in request.content) + + # Finally, using monkey patching check we can inject custom_context arguments in to index + original_index = admin.site.index + def index(*args, **kwargs): + kwargs['extra_context'] = {'foo': '*bar*'} + return original_index(*args, **kwargs) + admin.site.index = index + request = self.client.get('/test_admin/admin/') + self.assertTemplateUsed(request, 'custom_admin/index.html') + self.assert_('Hello from a custom index template *bar*' in request.content) self.client.get('/test_admin/admin/logout/') + del admin.site.index # Resets to using the original admin.site.login_template = None admin.site.index_template = None diff --git a/tests/templates/custom_admin/index.html b/tests/templates/custom_admin/index.html index d52033ee2d..75b6ca3d18 100644 --- a/tests/templates/custom_admin/index.html +++ b/tests/templates/custom_admin/index.html @@ -1,6 +1,6 @@ {% extends "admin/index.html" %} {% block content %} -Hello from a custom index template +Hello from a custom index template {{ foo }} {{ block.super }} {% endblock %} |
