Django

Code

Changeset 1308

Show
Ignore:
Timestamp:
11/20/05 13:12:23 (3 years ago)
Author:
rjwittams
Message:

Fixed 858. Got rid of confusing query_string tag.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/new-admin/django/contrib/admin/templates/admin/change_list_results.html

    r1071 r1308  
    33<tr> 
    44{% for header in result_headers %}<th{{header.class_attrib}}> 
    5 {%if header.sortable%}<a href="{% query_string cl override ORDER_VAR:i ORDER_TYPE_VAR:header.order %}" %>{%endif%} 
     5{%if header.sortable%}<a href="{{header.url}}" %>{%endif%} 
    66{{header.text|capfirst}} 
    77{%if header.sortable %}</a>{% endif %}</th>{% endfor %} 
  • django/branches/new-admin/django/contrib/admin/templates/admin/pagination.html

    r1023 r1308  
    77{%endif%} 
    88{{cl.result_count}} {% ifequal cl.result_count 1 %}{{cl.opts.verbose_name}}{%else%}{{cl.opts.verbose_name_plural}}{%endifequal%} 
    9 {% if need_show_all_link %}&nbsp;&nbsp;<a href="{% query_string cl override ALL_VAR:'' %}" class="showall">Show all</a>{%endif%} 
     9{% if show_all_url %}&nbsp;&nbsp;<a href="{{show_all_url}}" class="showall">Show all</a>{%endif%} 
    1010 
    1111</p> 
  • django/branches/new-admin/django/contrib/admin/templatetags/admin_list.py

    r1282 r1308  
    1515from django.utils import dateformat 
    1616DOT = '.' 
    17  
    18 class QueryStringNode(template.Node): 
    19     def __init__(self, cl_var, override_vars, remove_vars): 
    20         self.cl_var, self.override_vars, self.remove_vars = cl_var, override_vars, remove_vars 
    21          
    22     def render(self, context): 
    23         def res(var): 
    24             return template.resolve_variable(var, context) 
    25          
    26         cl = res(self.cl_var) 
    27         overrides = dict([ (res(k), res(v)) for k,v in self.override_vars ]) 
    28         remove = [res(v) for v in self.remove_vars] 
    29         return cl.get_query_string(overrides, remove) 
    30  
    31 def do_query_string(parser, token): 
    32     bits = token.contents.split()[1:] 
    33     in_override = False 
    34     in_remove = False 
    35     override_vars = [] 
    36     remove_vars = [] 
    37     cl_var = bits.pop(0) 
    38      
    39     for word in bits: 
    40         if in_override: 
    41             if word == 'remove': 
    42                 in_remove = True 
    43                 in_override = False 
    44             else: 
    45                 override_vars.append(word.split(':')) 
    46         elif in_remove: 
    47             remove_vars.append(word) 
    48         else: 
    49             if word == 'override': 
    50                 in_override = True 
    51             elif word == 'remove': 
    52                 remove = True 
    53      
    54     return QueryStringNode(cl_var, override_vars, remove_vars) 
    55  
    56 template.register_tag('query_string', do_query_string)           
    57  
    5817 
    5918#@simple_tag 
     
    10059                page_range.extend(range(page_num + 1, paginator.pages)) 
    10160 
     61    need_show_all_link = cl.can_show_all and not cl.show_all and cl.multi_page 
     62 
    10263    return {'cl': cl, 
    10364             'pagination_required': pagination_required, 
    104              'need_show_all_link': cl.can_show_all and not cl.show_all and cl.multi_page
     65             'show_all_url': need_show_all_link and cl.get_query_string({ALL_VAR:''})
    10566             'page_range': page_range,  
    10667             'ALL_VAR': ALL_VAR, 
     
    142103                    yield {"text" : f.verbose_name,  
    143104                           "sortable": True, 
    144                            "order" : new_order_type
     105                           "url" : cl.get_query_string({ORDER_VAR: i, ORDER_TYPE_VAR: new_order_type})
    145106                           "class_attrib" : (th_classes and ' class="%s"' % ' '.join(th_classes) or '') } 
    146107