#NEWLINE# @ never_cache #NEWLINE# def index( self , request , extra_context = None ) : #NEWLINE# #INDENT# '\n        Displays the main admin index page, which lists all of the installed\n        apps that have been registered in this site.\n        ' #NEWLINE# app_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# user = request . user #NEWLINE# for ( model , model_admin ) in self . _registry . items ( ) : #NEWLINE# #INDENT# app_label = model . _meta . app_label #NEWLINE# has_module_perms = user . has_module_perms ( app_label ) #NEWLINE# if has_module_perms : #NEWLINE# #INDENT# perms = model_admin . get_model_perms ( request ) #NEWLINE# if ( True in perms . values ( ) ) : #NEWLINE# #INDENT# model_dict = { #NEWLINE# #INDENT# 'name' : capfirst ( model . _meta . verbose_name_plural ) , #NEWLINE# 'admin_url' : mark_safe ( ( '%s/%s/' % ( app_label , model . __name__ . lower ( ) ) ) ) , #NEWLINE# 'perms' : perms , #NEWLINE# #UNINDENT# } #NEWLINE# if ( app_label in app_dict ) : #NEWLINE# #INDENT# app_dict [ app_label ] [ 'models' ] . append ( model_dict ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# app_dict [ app_label ] = { #NEWLINE# #INDENT# 'name' : app_label . title ( ) , #NEWLINE# 'app_url' : ( app_label + '/' ) , #NEWLINE# 'has_module_perms' : has_module_perms , #NEWLINE# 'models' : [ model_dict ] , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# app_list = app_dict . values ( ) #NEWLINE# app_list . sort ( key = ( lambda x : x [ 'name' ] ) ) #NEWLINE# for app in app_list : #NEWLINE# #INDENT# app [ 'models' ] . sort ( key = ( lambda x : x [ 'name' ] ) ) #NEWLINE# #UNINDENT# context = { #NEWLINE# #INDENT# 'title' : _ ( 'Site administration' ) , #NEWLINE# 'app_list' : app_list , #NEWLINE# 'root_path' : self . root_path , #NEWLINE# #UNINDENT# } #NEWLINE# context . update ( ( extra_context or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# context_instance = template . RequestContext ( request , current_app = self . name ) #NEWLINE# return render_to_response ( ( self . index_template or 'admin/index.html' ) , context , context_instance = context_instance )