Author: russellm
Date: 2010-08-14 08:43:13 -0500 (Sat, 14 Aug 2010)
New Revision: 13589
Modified:
django/branches/releases/1.2.X/django/contrib/admindocs/views.py
django/branches/releases/1.2.X/tests/regressiontests/admin_views/tests.py
django/branches/releases/1.2.X/tests/runtests.py
Log:
[1.2.X] Fixed #13796 -- Ensure that builtin tags and filters are included in
admin documentation views.
Backport of r13588 from trunk.
Modified: django/branches/releases/1.2.X/django/contrib/admindocs/views.py
===================================================================
--- django/branches/releases/1.2.X/django/contrib/admindocs/views.py
2010-08-14 13:41:56 UTC (rev 13588)
+++ django/branches/releases/1.2.X/django/contrib/admindocs/views.py
2010-08-14 13:43:13 UTC (rev 13589)
@@ -54,7 +54,9 @@
load_all_installed_template_libraries()
tags = []
- for module_name, library in template.libraries.items():
+ app_libs = template.libraries.items()
+ builtin_libs = [(None, lib) for lib in template.builtins]
+ for module_name, library in builtin_libs + app_libs:
for tag_name, tag_func in library.tags.items():
title, body, metadata = utils.parse_docstring(tag_func.__doc__)
if title:
@@ -87,7 +89,9 @@
load_all_installed_template_libraries()
filters = []
- for module_name, library in template.libraries.items():
+ app_libs = template.libraries.items()
+ builtin_libs = [(None, lib) for lib in template.builtins]
+ for module_name, library in builtin_libs + app_libs:
for filter_name, filter_func in library.filters.items():
title, body, metadata = utils.parse_docstring(filter_func.__doc__)
if title:
Modified:
django/branches/releases/1.2.X/tests/regressiontests/admin_views/tests.py
===================================================================
--- django/branches/releases/1.2.X/tests/regressiontests/admin_views/tests.py
2010-08-14 13:41:56 UTC (rev 13588)
+++ django/branches/releases/1.2.X/tests/regressiontests/admin_views/tests.py
2010-08-14 13:43:13 UTC (rev 13589)
@@ -2170,3 +2170,40 @@
self.assertRedirects(response, '/test_admin/admin/auth/user/add/')
self.assertEquals(User.objects.count(), user_count + 1)
self.assertNotEquals(new_user.password, UNUSABLE_PASSWORD)
+
+class AdminDocsTest(TestCase):
+ fixtures = ['admin-views-users.xml']
+
+ def setUp(self):
+ self.client.login(username='super', password='secret')
+
+ def tearDown(self):
+ self.client.logout()
+
+ def test_tags(self):
+ response = self.client.get('/test_admin/admin/doc/tags/')
+
+ # The builtin tag group exists
+ self.assertContains(response, "<h2>Built-in tags</h2>", count=2)
+
+ # A builtin tag exists in both the index and detail
+ self.assertContains(response, '<h3 id="autoescape">autoescape</h3>')
+ self.assertContains(response, '<li><a
href="#autoescape">autoescape</a></li>')
+
+ # An app tag exists in both the index and detail
+ # The builtin tag group exists
+ self.assertContains(response, "<h2>admin_list</h2>", count=2)
+
+ # A builtin tag exists in both the index and detail
+ self.assertContains(response, '<h3 id="autoescape">autoescape</h3>')
+ self.assertContains(response, '<li><a
href="#admin_actions">admin_actions</a></li>')
+
+ def test_filters(self):
+ response = self.client.get('/test_admin/admin/doc/filters/')
+
+ # The builtin filter group exists
+ self.assertContains(response, "<h2>Built-in filters</h2>", count=2)
+
+ # A builtin filter exists in both the index and detail
+ self.assertContains(response, '<h3 id="add">add</h3>')
+ self.assertContains(response, '<li><a href="#add">add</a></li>')
Modified: django/branches/releases/1.2.X/tests/runtests.py
===================================================================
--- django/branches/releases/1.2.X/tests/runtests.py 2010-08-14 13:41:56 UTC
(rev 13588)
+++ django/branches/releases/1.2.X/tests/runtests.py 2010-08-14 13:43:13 UTC
(rev 13589)
@@ -27,6 +27,7 @@
'django.contrib.messages',
'django.contrib.comments',
'django.contrib.admin',
+ 'django.contrib.admindocs',
]
def get_test_models():
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.