Issue #22 new

support django 1.3 in result header sorting

crass
created an issue

result_header properties only available in 1.4 are currently used in change_list_results.html, such as header.url_primary and header.url_remove.

Instead of this: {{{ {% if header.sortable %} {% if header.sort_priority > 0 %} <div class="btn-group pull-right sortoptions"> <a href="{{ header.url_toggle }}" class="btn" title="{% trans "Toggle sorting" %}"> <i class="{% if header.ascending %}icon-chevron-up{% else %}icon-chevron-down{% endif %}"></i> </a> <a class="btn btn-danger" href="{{ header.url_remove }}" title="{% trans "Remove from sorting" %}"><i class="icon-remove icon-white"></i></a> </div> {% endif %} {% endif %} <div class="text">{% if header.sortable %}<a href="{{ header.url_primary }}">{{ header.text|capfirst }}</a>{% else %}<span>{{ header.text|capfirst }}</span>{% endif %}</div> }}}

I use this to create compatibility for 1.3 and 1.4: {{{

{% if header.sortable and header.url_primary %}{# Django >= 1.4 #} {% if header.sortable %} {% if header.sort_priority > 0 %} <div class="btn-group pull-right sortoptions"> <a href="{{ header.url_toggle }}" class="btn" title="{% trans "Toggle sorting" %}"> <i class="{% if header.ascending %}icon-chevron-up{% else %}icon-chevron-down{% endif %}"></i> </a> <a class="btn btn-danger" href="{{ header.url_remove }}" title="{% trans "Remove from sorting" %}"><i class="icon-remove icon-white"></i></a> </div> {% endif %} {% endif %} <div class="text">{% if header.sortable %}<a href="{{ header.url_primary }}">{{ header.text|capfirst }}</a>{% else %}<span>{{ header.text|capfirst }}</span>{% endif %}</div> {% else %} {% if header.sortable %} <div class="btn-group pull-right sortoptions"> <a href="{{ header.url }}" class="btn" title="{% trans "Toggle sorting" %}"> {% if "sorted" in header.class_attrib %} <i class="{% if "ascending" in header.class_attrib %}icon-chevron-up{% else %}icon-chevron-down{% endif %}"></i> {% else %} <i class="icon-chevron-up"></i><i class="icon-chevron-down"></i> {% endif %} </a> </div> {% endif %} <div class="text">{% if header.sortable %}<a href="{{ header.url }}">{{ header.text|capfirst }}</a>{% else %}<span>{{ header.text|capfirst }}</span>{% endif %}</div> {% endif %} }}}

Comments (0)

  1. Log in to comment