Opened 18 years ago

Closed 18 years ago

#3128 closed enhancement (fixed)

[patch] add an object_tools block to admin templates

Reported by: Gary Wilson <gary.wilson@…> Owned by: Adrian Holovaty
Component: contrib.admin Version: dev
Severity: normal Keywords:
Cc: gary.wilson@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently, if I want to add object tools I have you have to override all of block content:

{% block content %}
<div id="content-main">
<ul class="object-tools">
{% if has_add_permission %}
    <li><a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans %}</a></li>
    <li><a href="myaction">Myaction</a></li>
{% endif %}
</ul>
<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
{% block search %}{% search_form cl %}{% endblock %}
{% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
{% block filters %}{% filters cl %}{% endblock %}
{% block result_list %}{% result_list cl %}{% endblock %}
{% block pagination %}{% pagination cl %}{% endblock %}
</div>
</div>
{% endblock %}

With a {% block object_tools %}, it could just be:

{% block object_tools %}
<ul class="object-tools">
{% if has_add_permission %}
    <li><a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans %}</a></li>
    <li><a href="myaction">Myaction</a></li>
{% endif %}
</ul>
{% endblock %}

The object tools area seems to be one of the only places that doesn't already have a block.

Attachments (2)

change_list.diff (865 bytes ) - added by Gary Wilson <gary.wilson@…> 18 years ago.
object-tools-block.diff (2.5 KB ) - added by Gary Wilson <gary.wilson@…> 18 years ago.
block in admin/base.html with overrides in change_list and change_form

Download all attachments as: .zip

Change History (6)

by Gary Wilson <gary.wilson@…>, 18 years ago

Attachment: change_list.diff added

comment:2 by anonymous, 18 years ago

Summary: [patch] add an object_tools block to change_list.html template[patch] add an object_tools block to admin templates

not just change_list.html

by Gary Wilson <gary.wilson@…>, 18 years ago

Attachment: object-tools-block.diff added

block in admin/base.html with overrides in change_list and change_form

comment:3 by Gary Wilson <gary.wilson@…>, 18 years ago

Cc: gary.wilson@… added

comment:4 by Jacob, 18 years ago

Resolution: fixed
Status: newclosed

(In [4230]) Fixed #3128: Added explicit object-tools block so custom admin templates can override it where needed. Thanks, Gary Wilson.

Note: See TracTickets for help on using tickets.
Back to Top