Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #13796 -- Ensure that builtin tags and filters are incl…

…uded in admin documentation views.

Backport of r13588 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13589 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 13953badb7dd784c07ec4617e6a28e5143462ed2 1 parent e4a8b6c
Russell Keith-Magee authored
8  django/contrib/admindocs/views.py
@@ -54,7 +54,9 @@ def template_tag_index(request):
54 54
     load_all_installed_template_libraries()
55 55
 
56 56
     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:
58 60
         for tag_name, tag_func in library.tags.items():
59 61
             title, body, metadata = utils.parse_docstring(tag_func.__doc__)
60 62
             if title:
@@ -87,7 +89,9 @@ def template_filter_index(request):
87 89
     load_all_installed_template_libraries()
88 90
 
89 91
     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:
91 95
         for filter_name, filter_func in library.filters.items():
92 96
             title, body, metadata = utils.parse_docstring(filter_func.__doc__)
93 97
             if title:
37  tests/regressiontests/admin_views/tests.py
@@ -2170,3 +2170,40 @@ def test_user_add_another(self):
2170 2170
         self.assertRedirects(response, '/test_admin/admin/auth/user/add/')
2171 2171
         self.assertEquals(User.objects.count(), user_count + 1)
2172 2172
         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>')
1  tests/runtests.py
@@ -27,6 +27,7 @@
27 27
     'django.contrib.messages',
28 28
     'django.contrib.comments',
29 29
     'django.contrib.admin',
  30
+    'django.contrib.admindocs',
30 31
 ]
31 32
 
32 33
 def get_test_models():

0 notes on commit 13953ba

Please sign in to comment.
Something went wrong with that request. Please try again.