Ticket #4477: newforms-admin-5427-app_grouping.diff
File newforms-admin-5427-app_grouping.diff, 2.1 KB (added by , 17 years ago) |
---|
-
django/contrib/admin/sites.py
5 5 from django.shortcuts import render_to_response 6 6 from django.utils.text import capfirst 7 7 from django.utils.translation import gettext_lazy 8 from django.utils.datastructures import SortedDict 8 9 import base64 9 10 import cPickle as pickle 10 11 import datetime … … 234 235 Displays the main admin index page, which lists all of the installed 235 236 apps that have been registered in this site. 236 237 """ 237 app_ list = []238 app_dict = SortedDict() 238 239 user = request.user 239 240 for model, model_admin in self._registry.items(): 240 241 app_label = model._meta.app_label 241 242 has_module_perms = user.has_module_perms(app_label) 243 242 244 if has_module_perms: 243 245 perms = { 244 246 'add': user.has_perm("%s.%s" % (app_label, model._meta.get_add_permission())), … … 254 256 'admin_url': '%s/%s/' % (app_label, model.__name__.lower()), 255 257 'perms': perms, 256 258 } 257 app_list.append({ 258 'name': app_label.title(), 259 'has_module_perms': has_module_perms, 260 'models': [model_dict], 261 }) 259 if app_dict.has_key( app_label ): 260 app_dict[app_label]['models'].append( model_dict ) 261 else: 262 app_dict[app_label] = { 263 'name': app_label.title(), 264 'has_module_perms': has_module_perms, 265 'models': [model_dict], 266 } 262 267 return render_to_response('admin/index.html', { 263 268 'title': _('Site administration'), 264 'app_list': app_ list,269 'app_list': app_dict.values(), 265 270 }, context_instance=template.RequestContext(request)) 266 271 267 272 # This global object represents the default admin site, for the common case.