#19536: in ModelAdmin disabling has_add_permission results in not showing any
object-tools
--------------------------------------+------------------------------------
     Reporter:  a.fazeli@…            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.admin         |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  1                     |      Needs documentation:  0
  Needs tests:  1                     |  Patch needs improvement:  1
Easy pickings:  1                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by arash77):

 How about this solution:
 {{{
 #!application/x-jinja
 {% block object-tools %}
     <ul class="object-tools">
         <li style="display: none;"></li>
         {% block object-tools-items %}
             {% if has_add_permission %}
             <li>
                 <a href="{% url cl.opts|admin_urlname:'add' %}{% if
 is_popup %}?_popup=1{% endif %}" class="addlink">
                     {% blocktrans with cl.opts.verbose_name as name %}Add
 {{ name }}{% endblocktrans %}
                 </a>
             </li>
             {% endif %}
         {% endblock %}
     </ul>
 {% endblock %}
 }}}

 This way an empty UL will not be created. Of-course the first LI can also
 be configured through relative CSS class.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19536#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/076.7702fb610083d9eaefd295b94e687684%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to