#NEWLINE# def handle_rename( sender , path = None , **kwargs ) : #NEWLINE# #INDENT# def isdir( filename ) : #NEWLINE# #INDENT# if filename . count ( '.' ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# #UNINDENT# old_url = os . path . join ( get_relative_media_url ( ) , DIRECTORY , path , kwargs [ 'filename' ] ) #NEWLINE# new_url = os . path . join ( get_relative_media_url ( ) , DIRECTORY , path , kwargs [ 'new_filename' ] ) #NEWLINE# old_url_qs = Url . objects . filter ( url = old_url ) . filter ( status = True ) #NEWLINE# if isdir ( kwargs [ 'filename' ] ) : #NEWLINE# #INDENT# old_url_qs = Url . objects . filter ( url__startswith = old_url ) . filter ( status = True ) #NEWLINE# #UNINDENT# old_count = old_url_qs . count ( ) #NEWLINE# if old_count : #NEWLINE# #INDENT# old_url_qs . update ( status = False , message = 'Missing Document' ) #NEWLINE# msg = ( 'Warning. Renaming %s has caused %s link%s to break. Please use the Link Manager to fix them' % ( old_url , old_count , ( ( ( old_count > 1 ) and 's' ) or '' ) ) ) #NEWLINE# messages . info ( sender , msg ) #NEWLINE# #UNINDENT# if isdir ( kwargs [ 'new_filename' ] ) : #NEWLINE# #INDENT# new_count = 0 #NEWLINE# new_url_qs = Url . objects . filter ( url__startswith = new_url ) . filter ( status = False ) #NEWLINE# for url in new_url_qs : #NEWLINE# #INDENT# if url . check_url ( ) : #NEWLINE# #INDENT# new_count += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# new_url_qs = Url . objects . filter ( url = new_url ) . filter ( status = False ) #NEWLINE# new_count = new_url_qs . count ( ) #NEWLINE# if new_count : #NEWLINE# #INDENT# new_url_qs . update ( status = True , message = 'Working document link' ) #NEWLINE# #UNINDENT# #UNINDENT# if new_count : #NEWLINE# #INDENT# msg = ( 'Please note. Renaming %s has corrected %s broken link%s. See the Link Manager for more details' % ( new_url , new_count , ( ( ( new_count > 1 ) and 's' ) or '' ) ) ) #NEWLINE# messages . info ( sender , msg )