Code

Opened 8 years ago

Closed 8 years ago

#3128 closed enhancement (fixed)

[patch] add an object_tools block to admin templates

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

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@…> 8 years ago.
object-tools-block.diff (2.5 KB) - added by Gary Wilson <gary.wilson@…> 8 years ago.
block in admin/base.html with overrides in change_list and change_form

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by Gary Wilson <gary.wilson@…>

comment:2 Changed 8 years ago by anonymous

  • Summary changed from [patch] add an object_tools block to change_list.html template to [patch] add an object_tools block to admin templates

not just change_list.html

Changed 8 years ago by Gary Wilson <gary.wilson@…>

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

comment:3 Changed 8 years ago by Gary Wilson <gary.wilson@…>

  • Cc gary.wilson@… added

comment:4 Changed 8 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.