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

File app-name-in-admin-breadcrumbs2.diff, 10.5 KB (added by eXt, 8 years ago)

Updated patch against 6930

  • 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

     
    526526            'show_delete': False,
    527527            'media': mark_safe(media),
    528528            'inline_admin_formsets': inline_admin_formsets,
     529            'app_label': app_label,
    529530        })
    530531        return self.render_change_form(request, model, c, add=True)
    531532
     
    601602            'is_popup': request.REQUEST.has_key('_popup'),
    602603            'media': mark_safe(media),
    603604            'inline_admin_formsets': inline_admin_formsets,
     605            'app_label': app_label,
    604606        })
    605607        return self.render_change_form(request, model, c, change=True, obj=obj)
    606608
     
    627629            'title': cl.title,
    628630            'is_popup': cl.is_popup,
    629631            'cl': cl,
     632            'app_label': app_label,
    630633        })
    631634        c.update({'has_add_permission': self.has_add_permission(request)}),
    632635        return render_to_response(['admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()),
     
    669672            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)})
    670673            return HttpResponseRedirect("../../")
    671674        extra_context = {
    672             "title": _("Are you sure?"),
    673             "object_name": opts.verbose_name,
    674             "object": obj,
    675             "deleted_objects": deleted_objects,
    676             "perms_lacking": perms_needed,
    677             "opts": opts,
     675            'title': _('Are you sure?'),
     676            'object_name': opts.verbose_name,
     677            'object': obj,
     678            'deleted_objects': deleted_objects,
     679            'perms_lacking': perms_needed,
     680            'opts': opts,
     681            'app_label': app_label,
    678682        }
    679         return render_to_response(["admin/%s/%s/delete_confirmation.html" % (app_label, opts.object_name.lower() ),
    680                                 "admin/%s/delete_confirmation.html" % app_label ,
    681                                 "admin/delete_confirmation.html"], extra_context, context_instance=template.RequestContext(request))
     683        return render_to_response(['admin/%s/%s/delete_confirmation.html' % (app_label, opts.object_name.lower() ),
     684                                'admin/%s/delete_confirmation.html' % app_label ,
     685                                'admin/delete_confirmation.html'], extra_context, context_instance=template.RequestContext(request))
    682686
    683687    def history_view(self, request, object_id):
    684688        "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 }}</a> &rsaquo;
    2122     {% if add %}{% trans "Add" %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% 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 }}</a> &rsaquo;
    1011     <a href="../">{{ object|escape|truncatewords:"18" }}</a> &rsaquo;
    1112     {% trans 'Delete' %}
  • django/contrib/admin/sites.py

     
    115115        if not self.has_permission(request):
    116116            return self.login(request)
    117117
    118 
    119118        if url == '':
    120119            return self.index(request)
    121120        elif url == 'password_change':
     
    132131            match = USER_CHANGE_PASSWORD_URL_RE.match(url)
    133132            if match:
    134133                return self.user_change_password(request, match.group(1))
    135                
     134
    136135            if '/' in url:
    137136                return self.model_page(request, *url.split('/', 2))
     137            else:
     138                return self.app_index(request, url)
    138139
    139140        raise http.Http404('The requested admin page does not exist.')
    140141
     
    281282                    else:
    282283                        app_dict[app_label] = {
    283284                            'name': app_label.title(),
     285                            'app_url': app_label,
    284286                            'has_module_perms': has_module_perms,
    285287                            'models': [model_dict],
    286288                        }
     
    298300            'app_list': app_list,
    299301        }, context_instance=template.RequestContext(request))
    300302
     303    def app_index(self, request, app_label):
     304        """
     305        Displays the application's index page, which lists all of
     306        the application's models
     307        """
     308       
     309        user = request.user
     310        has_module_perms = user.has_module_perms(app_label)
     311        app_dict = {}
     312        for model, model_admin in self._registry.items():
     313            if app_label == model._meta.app_label:
     314                if has_module_perms:
     315                    perms = {
     316                        'add': user.has_perm("%s.%s" % (app_label, model._meta.get_add_permission())),
     317                        'change': user.has_perm("%s.%s" % (app_label, model._meta.get_change_permission())),
     318                        'delete': user.has_perm("%s.%s" % (app_label, model._meta.get_delete_permission())),
     319                    }
     320       
     321                    # Check whether user has any perm for this module.
     322                    # If so, add the module to the model_list.
     323                    if True in perms.values():
     324                        model_dict = {
     325                            'name': capfirst(model._meta.verbose_name_plural),
     326                            'admin_url': '%s/' % model.__name__.lower(),
     327                            'perms': perms,
     328                        }
     329                        if app_dict:
     330                            app_dict['models'].append(model_dict)
     331                        else:
     332                            app_dict = {
     333                                'name': app_label.title(),
     334                                'app_url':'',
     335                                'has_module_perms': has_module_perms,
     336                                'models': [model_dict],
     337                            }
     338        if not app_dict:
     339            raise http.Http404('The requested admin page does not exist.')
     340        # Sort the models alphabetically within each app.
     341        app_dict['models'].sort(lambda x, y: cmp(x['name'], y['name']))
     342
     343        return render_to_response('admin/app_index.html', {
     344            'title': _('%s administration' % capfirst(app_label)),
     345            'app_list': [app_dict,],
     346        }, context_instance=template.RequestContext(request))
     347
    301348# This global object represents the default admin site, for the common case.
    302349# You can instantiate AdminSite in your own code to create a custom admin site.
    303350site = AdminSite()
Back to Top