Skip to content

Commit 7e52bb2

Browse files
committed
Fixed #13796 -- Ensure that builtin tags and filters are included in admin documentation views.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13588 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 05f5217 commit 7e52bb2

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

django/contrib/admindocs/views.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def template_tag_index(request):
5454
load_all_installed_template_libraries()
5555

5656
tags = []
57-
for module_name, library in template.libraries.items():
57+
app_libs = template.libraries.items()
58+
builtin_libs = [(None, lib) for lib in template.builtins]
59+
for module_name, library in builtin_libs + app_libs:
5860
for tag_name, tag_func in library.tags.items():
5961
title, body, metadata = utils.parse_docstring(tag_func.__doc__)
6062
if title:
@@ -87,7 +89,9 @@ def template_filter_index(request):
8789
load_all_installed_template_libraries()
8890

8991
filters = []
90-
for module_name, library in template.libraries.items():
92+
app_libs = template.libraries.items()
93+
builtin_libs = [(None, lib) for lib in template.builtins]
94+
for module_name, library in builtin_libs + app_libs:
9195
for filter_name, filter_func in library.filters.items():
9296
title, body, metadata = utils.parse_docstring(filter_func.__doc__)
9397
if title:

tests/regressiontests/admin_views/tests.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,3 +2170,40 @@ def test_user_add_another(self):
21702170
self.assertRedirects(response, '/test_admin/admin/auth/user/add/')
21712171
self.assertEquals(User.objects.count(), user_count + 1)
21722172
self.assertNotEquals(new_user.password, UNUSABLE_PASSWORD)
2173+
2174+
class AdminDocsTest(TestCase):
2175+
fixtures = ['admin-views-users.xml']
2176+
2177+
def setUp(self):
2178+
self.client.login(username='super', password='secret')
2179+
2180+
def tearDown(self):
2181+
self.client.logout()
2182+
2183+
def test_tags(self):
2184+
response = self.client.get('/test_admin/admin/doc/tags/')
2185+
2186+
# The builtin tag group exists
2187+
self.assertContains(response, "<h2>Built-in tags</h2>", count=2)
2188+
2189+
# A builtin tag exists in both the index and detail
2190+
self.assertContains(response, '<h3 id="autoescape">autoescape</h3>')
2191+
self.assertContains(response, '<li><a href="#autoescape">autoescape</a></li>')
2192+
2193+
# An app tag exists in both the index and detail
2194+
# The builtin tag group exists
2195+
self.assertContains(response, "<h2>admin_list</h2>", count=2)
2196+
2197+
# A builtin tag exists in both the index and detail
2198+
self.assertContains(response, '<h3 id="autoescape">autoescape</h3>')
2199+
self.assertContains(response, '<li><a href="#admin_actions">admin_actions</a></li>')
2200+
2201+
def test_filters(self):
2202+
response = self.client.get('/test_admin/admin/doc/filters/')
2203+
2204+
# The builtin filter group exists
2205+
self.assertContains(response, "<h2>Built-in filters</h2>", count=2)
2206+
2207+
# A builtin filter exists in both the index and detail
2208+
self.assertContains(response, '<h3 id="add">add</h3>')
2209+
self.assertContains(response, '<li><a href="#add">add</a></li>')

tests/runtests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
'django.contrib.messages',
2828
'django.contrib.comments',
2929
'django.contrib.admin',
30+
'django.contrib.admindocs',
3031
]
3132

3233
def get_test_models():

0 commit comments

Comments
 (0)