From 4cf4acba459c41b8b41fc731149b3b03657fe7d4 Mon Sep 17 00:00:00 2001 From: Brian Rosner Date: Sat, 8 May 2010 21:38:14 +0000 Subject: [PATCH] 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 --- .../contrib/admin/templatetags/admin_list.py | 21 +++++++++++++++++++ .../admin/templatetags/admin_modify.py | 3 +++ 2 files changed, 24 insertions(+) diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index 3f0b9c6360..565db32251 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -21,6 +21,9 @@ register = Library() DOT = '.' def paginator_number(cl,i): + """ + Generates an individual page index link in a paginated list. + """ if i == DOT: return u'... ' elif i == cl.page_num: @@ -30,6 +33,9 @@ def paginator_number(cl,i): paginator_number = register.simple_tag(paginator_number) def pagination(cl): + """ + Generates the series of links to the pages in a paginated list. + """ paginator, page_num = cl.paginator, cl.page_num pagination_required = (not cl.show_all or not cl.can_show_all) and cl.multi_page @@ -73,6 +79,9 @@ def pagination(cl): pagination = register.inclusion_tag('admin/pagination.html')(pagination) def result_headers(cl): + """ + Generates the list column headers. + """ lookup_opts = cl.lookup_opts for i, field_name in enumerate(cl.list_display): @@ -118,6 +127,9 @@ def _boolean_icon(field_val): return mark_safe(u'%s' % (settings.ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val)) def items_for_result(cl, result, form): + """ + Generates the actual list of data. + """ first = True pk = cl.lookup_opts.pk.attname for field_name in cl.list_display: @@ -189,12 +201,18 @@ def results(cl): yield list(items_for_result(cl, res, None)) def result_list(cl): + """ + Displays the headers and data list together + """ return {'cl': cl, 'result_headers': list(result_headers(cl)), 'results': list(results(cl))} result_list = register.inclusion_tag("admin/change_list_results.html")(result_list) def date_hierarchy(cl): + """ + Displays the date hierarchy for date drill-down functionality. + """ if cl.date_hierarchy: field_name = cl.date_hierarchy year_field = '%s__year' % field_name @@ -255,6 +273,9 @@ def date_hierarchy(cl): date_hierarchy = register.inclusion_tag('admin/date_hierarchy.html')(date_hierarchy) def search_form(cl): + """ + Displays a search form for searching the list. + """ return { 'cl': cl, 'show_result_count': cl.result_count != cl.full_result_count, diff --git a/django/contrib/admin/templatetags/admin_modify.py b/django/contrib/admin/templatetags/admin_modify.py index 19042faf94..fe88043c9f 100644 --- a/django/contrib/admin/templatetags/admin_modify.py +++ b/django/contrib/admin/templatetags/admin_modify.py @@ -20,6 +20,9 @@ def prepopulated_fields_js(context): prepopulated_fields_js = register.inclusion_tag('admin/prepopulated_fields_js.html', takes_context=True)(prepopulated_fields_js) def submit_row(context): + """ + Displays the row of buttons for delete and save. + """ opts = context['opts'] change = context['change'] is_popup = context['is_popup']