Ticket #1390: app-name-in-admin-breadcrumbs.diff

File app-name-in-admin-breadcrumbs.diff, 10.5 KB (added by Jakub Wiśniowski, 17 years ago)

Extended breadcrums in admin (newforms-admin branch)

  • django/contrib/admin/media/css/global.css

     
    55a:hover { color: #036; }
    66a img { border:none; }
    77
     8a.section:link, a.section:visited { color: white; text-decoration:none; }
     9
    810/* GLOBAL DEFAULTS */
    911p, ol, ul, dl { margin:.2em 0 .8em 0; }
    1012p { padding:0; line-height:140%; }
  • django/contrib/admin/options.py

     
    489489            'show_delete': False,
    490490            'media': media,
    491491            'inline_admin_formsets': inline_admin_formsets,
     492            'app_label': app_label,
    492493        })
    493494        return render_change_form(self, model, model.AddManipulator(), c, add=True)
    494495
     
    565566            'is_popup': request.REQUEST.has_key('_popup'),
    566567            'media': media,
    567568            'inline_admin_formsets': inline_admin_formsets,
     569            'app_label': app_label,
    568570        })
    569571        return render_change_form(self, model, model.ChangeManipulator(object_id), c, change=True)
    570572
     
    591593            'title': cl.title,
    592594            'is_popup': cl.is_popup,
    593595            'cl': cl,
     596            'app_label': app_label,
    594597        })
    595598        c.update({'has_add_permission': c['perms'][app_label][opts.get_add_permission()]}),
    596599        return render_to_response(['admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()),
     
    633636            request.user.message_set.create(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)})
    634637            return HttpResponseRedirect("../../")
    635638        extra_context = {
    636             "title": _("Are you sure?"),
    637             "object_name": opts.verbose_name,
    638             "object": obj,
    639             "deleted_objects": deleted_objects,
    640             "perms_lacking": perms_needed,
    641             "opts": opts,
     639            'title': _('Are you sure?'),
     640            'object_name': opts.verbose_name,
     641            'object': obj,
     642            'deleted_objects': deleted_objects,
     643            'perms_lacking': perms_needed,
     644            'opts': opts,
     645            'app_label': app_label,
    642646        }
    643         return render_to_response(["admin/%s/%s/delete_confirmation.html" % (app_label, opts.object_name.lower() ),
    644                                 "admin/%s/delete_confirmation.html" % app_label ,
    645                                 "admin/delete_confirmation.html"], extra_context, context_instance=template.RequestContext(request))
     647        return render_to_response(['admin/%s/%s/delete_confirmation.html' % (app_label, opts.object_name.lower() ),
     648                                'admin/%s/delete_confirmation.html' % app_label ,
     649                                'admin/delete_confirmation.html'], extra_context, context_instance=template.RequestContext(request))
    646650
    647651    def history_view(self, request, object_id):
    648652        "The 'history' admin view for this model."
  • django/contrib/admin/templates/admin/change_list.html

     
    77
    88{% block userlinks %}<a href="../../doc/">{% trans 'Documentation' %}</a> / <a href="../../password_change/">{% trans 'Change password' %}</a> / <a href="../../logout/">{% trans 'Log out' %}</a>{% endblock %}
    99
    10 {% if not is_popup %}{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">{% trans "Home" %}</a> &rsaquo; {{ cl.opts.verbose_name_plural|capfirst|escape }}</div>{% endblock %}{% endif %}
     10{% if not is_popup %}{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">{% trans "Home" %}</a> &rsaquo; <a href="../">{{ app_label|capfirst|escape }}</a> &rsaquo; {{ cl.opts.verbose_name_plural|capfirst|escape }}</div>{% endblock %}{% endif %}
    1111
    1212{% block coltype %}flex{% endblock %}
    1313
  • django/contrib/admin/templates/admin/index.html

     
    1616    {% for app in app_list %}
    1717        <div class="module">
    1818        <table summary="{% blocktrans with app.name as name %}Models available in the {{ name }} application.{% endblocktrans %}">
    19         <caption>{% blocktrans with app.name as name %}{{ name }}{% endblocktrans %}</caption>
     19        <caption><a href="{{ app.app_url }}" class="section">{% blocktrans with app.name as name %}{{ name }}{% endblocktrans %}</a></caption>
    2020        {% for model in app.models %}
    2121            <tr>
    2222            {% if model.perms.change %}
  • django/contrib/admin/templates/admin/app_index.html

     
     1{% extends "admin/index.html" %}
     2{% load i18n %}
     3
     4{% if not is_popup %}{% block breadcrumbs %}<div class="breadcrumbs"><a href="../">{% trans "Home" %}</a> &rsaquo; {% for app in app_list %}{% blocktrans with app.name as name %}{{ name }}{% endblocktrans %}{% endfor %}</div>{% endblock %}{% endif %}
     5{% block sidebar %}{% endblock %}
     6 No newline at end of file
  • django/contrib/admin/templates/admin/change_form.html

     
    1717{% block breadcrumbs %}{% if not is_popup %}
    1818<div class="breadcrumbs">
    1919     <a href="../../../">{% trans "Home" %}</a> &rsaquo;
     20     <a href="../../">{{ app_label|capfirst|escape }}</a> &rsaquo;
    2021     <a href="../">{{ opts.verbose_name_plural|capfirst|escape }}</a> &rsaquo;
    2122     {% if add %}{% trans "Add" %} {{ opts.verbose_name|escape }}{% else %}{{ original|truncatewords:"18"|escape }}{% endif %}
    2223</div>
  • django/contrib/admin/templates/admin/delete_confirmation.html

     
    66{% block breadcrumbs %}
    77<div class="breadcrumbs">
    88     <a href="../../../../">{% trans "Home" %}</a> &rsaquo;
     9     <a href="../../../">{{ app_label|capfirst|escape }}</a> &rsaquo;
    910     <a href="../../">{{ opts.verbose_name_plural|capfirst|escape }}</a> &rsaquo;
    1011     <a href="../">{{ object|escape|truncatewords:"18" }}</a> &rsaquo;
    1112     {% trans 'Delete' %}
  • django/contrib/admin/sites.py

     
    114114        if not self.has_permission(request):
    115115            return self.login(request)
    116116
    117 
    118117        if url == '':
    119118            return self.index(request)
    120119        elif url == 'password_change':
     
    127126            match = USER_CHANGE_PASSWORD_URL_RE.match(url)
    128127            if match:
    129128                return self.user_change_password(request, match.group(1))
    130                
     129
    131130            if '/' in url:
    132131                return self.model_page(request, *url.split('/', 2))
     132            else:
     133                return self.app_index(request, url)
    133134
    134135        raise http.Http404('The requested admin page does not exist.')
    135136
     
    276277                    else:
    277278                        app_dict[app_label] = {
    278279                            'name': app_label.title(),
     280                            'app_url': app_label,
    279281                            'has_module_perms': has_module_perms,
    280282                            'models': [model_dict],
    281283                        }
     
    293295            'app_list': app_list,
    294296        }, context_instance=template.RequestContext(request))
    295297
     298    def app_index(self, request, app_label):
     299        """
     300        Displays the application's index page, which lists all of
     301        the application's models
     302        """
     303       
     304        user = request.user
     305        has_module_perms = user.has_module_perms(app_label)
     306        app_dict = {}
     307        for model, model_admin in self._registry.items():
     308            if app_label == model._meta.app_label:
     309                if has_module_perms:
     310                    perms = {
     311                        'add': user.has_perm("%s.%s" % (app_label, model._meta.get_add_permission())),
     312                        'change': user.has_perm("%s.%s" % (app_label, model._meta.get_change_permission())),
     313                        'delete': user.has_perm("%s.%s" % (app_label, model._meta.get_delete_permission())),
     314                    }
     315       
     316                    # Check whether user has any perm for this module.
     317                    # If so, add the module to the model_list.
     318                    if True in perms.values():
     319                        model_dict = {
     320                            'name': capfirst(model._meta.verbose_name_plural),
     321                            'admin_url': '%s/' % model.__name__.lower(),
     322                            'perms': perms,
     323                        }
     324                        if app_dict:
     325                            app_dict['models'].append(model_dict)
     326                        else:
     327                            app_dict = {
     328                                'name': app_label.title(),
     329                                'app_url':'',
     330                                'has_module_perms': has_module_perms,
     331                                'models': [model_dict],
     332                            }
     333        if not app_dict:
     334            raise http.Http404('The requested admin page does not exist.')
     335        # Sort the models alphabetically within each app.
     336        app_dict['models'].sort(lambda x, y: cmp(x['name'], y['name']))
     337
     338        return render_to_response('admin/app_index.html', {
     339            'title': _('%s administration' % capfirst(app_label)),
     340            'app_list': [app_dict,],
     341        }, context_instance=template.RequestContext(request))
     342
    296343# This global object represents the default admin site, for the common case.
    297344# You can instantiate AdminSite in your own code to create a custom admin site.
    298345site = AdminSite()
Back to Top