Ticket #11895: sites.diff
File sites.diff, 1.7 KB (added by , 15 years ago) |
---|
-
sites.py
49 49 self.app_name = app_name 50 50 self._actions = {'delete_selected': actions.delete_selected} 51 51 self._global_actions = self._actions.copy() 52 self.apps = [] 52 53 53 54 def register(self, model_or_iterable, admin_class=None, **options): 54 55 """ … … 349 350 app_dict[app_label]['models'].append(model_dict) 350 351 else: 351 352 app_dict[app_label] = { 353 'app_label': app_label, 352 354 'name': app_label.title(), 353 355 'app_url': app_label + '/', 354 356 'has_module_perms': has_module_perms, … … 362 364 # Sort the models alphabetically within each app. 363 365 for app in app_list: 364 366 app['models'].sort(lambda x, y: cmp(x['name'], y['name'])) 365 367 368 # Assign Apps to Groups 369 for group in self.apps: 370 application_list = [] 371 for app in group['apps']: 372 try: 373 application_list.append(app_dict[app]) 374 # remove assigned app from app_list 375 app_list = [d for d in app_list if d.get('app_label') != app] 376 except: 377 pass 378 group['applications'] = application_list 379 366 380 context = { 367 381 'title': _('Site administration'), 368 382 'app_list': app_list, 369 383 'root_path': self.root_path, 384 'group_list': self.apps, 370 385 } 371 386 context.update(extra_context or {}) 372 387 context_instance = template.RequestContext(request, current_app=self.name)