Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1834 -- added docstrings to admin templatetags

Thanks Rupe for work on a patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13139 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4cf4acba459c41b8b41fc731149b3b03657fe7d4 1 parent 0618cb2
Brian Rosner authored May 08, 2010
21  django/contrib/admin/templatetags/admin_list.py
@@ -21,6 +21,9 @@
21 21
 DOT = '.'
22 22
 
23 23
 def paginator_number(cl,i):
  24
+    """
  25
+    Generates an individual page index link in a paginated list.
  26
+    """
24 27
     if i == DOT:
25 28
         return u'... '
26 29
     elif i == cl.page_num:
@@ -30,6 +33,9 @@ def paginator_number(cl,i):
30 33
 paginator_number = register.simple_tag(paginator_number)
31 34
 
32 35
 def pagination(cl):
  36
+    """
  37
+    Generates the series of links to the pages in a paginated list.
  38
+    """
33 39
     paginator, page_num = cl.paginator, cl.page_num
34 40
 
35 41
     pagination_required = (not cl.show_all or not cl.can_show_all) and cl.multi_page
@@ -73,6 +79,9 @@ def pagination(cl):
73 79
 pagination = register.inclusion_tag('admin/pagination.html')(pagination)
74 80
 
75 81
 def result_headers(cl):
  82
+    """
  83
+    Generates the list column headers.
  84
+    """
76 85
     lookup_opts = cl.lookup_opts
77 86
 
78 87
     for i, field_name in enumerate(cl.list_display):
@@ -118,6 +127,9 @@ def _boolean_icon(field_val):
118 127
     return mark_safe(u'<img src="%simg/admin/icon-%s.gif" alt="%s" />' % (settings.ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val))
119 128
 
120 129
 def items_for_result(cl, result, form):
  130
+    """
  131
+    Generates the actual list of data.
  132
+    """
121 133
     first = True
122 134
     pk = cl.lookup_opts.pk.attname
123 135
     for field_name in cl.list_display:
@@ -189,12 +201,18 @@ def results(cl):
189 201
             yield list(items_for_result(cl, res, None))
190 202
 
191 203
 def result_list(cl):
  204
+    """
  205
+    Displays the headers and data list together
  206
+    """
192 207
     return {'cl': cl,
193 208
             'result_headers': list(result_headers(cl)),
194 209
             'results': list(results(cl))}
195 210
 result_list = register.inclusion_tag("admin/change_list_results.html")(result_list)
196 211
 
197 212
 def date_hierarchy(cl):
  213
+    """
  214
+    Displays the date hierarchy for date drill-down functionality.
  215
+    """
198 216
     if cl.date_hierarchy:
199 217
         field_name = cl.date_hierarchy
200 218
         year_field = '%s__year' % field_name
@@ -255,6 +273,9 @@ def date_hierarchy(cl):
255 273
 date_hierarchy = register.inclusion_tag('admin/date_hierarchy.html')(date_hierarchy)
256 274
 
257 275
 def search_form(cl):
  276
+    """
  277
+    Displays a search form for searching the list.
  278
+    """
258 279
     return {
259 280
         'cl': cl,
260 281
         'show_result_count': cl.result_count != cl.full_result_count,
3  django/contrib/admin/templatetags/admin_modify.py
@@ -20,6 +20,9 @@ def prepopulated_fields_js(context):
20 20
 prepopulated_fields_js = register.inclusion_tag('admin/prepopulated_fields_js.html', takes_context=True)(prepopulated_fields_js)
21 21
 
22 22
 def submit_row(context):
  23
+    """
  24
+    Displays the row of buttons for delete and save. 
  25
+    """
23 26
     opts = context['opts']
24 27
     change = context['change']
25 28
     is_popup = context['is_popup']

0 notes on commit 4cf4acb

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