#NEWLINE# def clean( self ) : #NEWLINE# #INDENT# website = self . cleaned_data [ 'website' ] #NEWLINE# if ( 'slug' in self . cleaned_data ) : #NEWLINE# #INDENT# slug = self . cleaned_data [ 'slug' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return page . cleaned_data #NEWLINE# #UNINDENT# if self . instance . id : #NEWLINE# #INDENT# page = Page . objects . get ( id = self . instance . id ) #NEWLINE# if ( page . slug == slug ) : #NEWLINE# #INDENT# return self . cleaned_data #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if page . is_homepage : #NEWLINE# #INDENT# errors_append ( self , 'slug' , _ ( 'You cannot change the homepage slug.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( slug == '' ) and ( self . cleaned_data . get ( 'parent' , None ) is not None ) ) : #NEWLINE# #INDENT# errors_append ( self , 'slug' , _ ( 'A page without slug cannot have a parent' ) ) #NEWLINE# return self . cleaned_data #NEWLINE# #UNINDENT# if ( Page . objects . filter ( slug__exact = slug , website__exact = website , parent = self . cleaned_data . get ( 'parent' , None ) ) . count ( ) != 0 ) : #NEWLINE# #INDENT# errors_append ( self , 'slug' , _ ( 'This slug is already used by another page.' ) ) #NEWLINE# return self . cleaned_data #NEWLINE# #UNINDENT# if ( ( len ( slug ) > 0 ) and ( len ( slug ) < SLUG_MIN_SIZE ) ) : #NEWLINE# #INDENT# errors_append ( self , 'slug' , ( _ ( 'A slug should be at least %(min_size)d characters long.' ) % { #NEWLINE# #INDENT# 'min_size' : SLUG_MIN_SIZE , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# return self . cleaned_data #NEWLINE# #UNINDENT# if ( self . cleaned_data . get ( 'parent' , None ) is not None ) : #NEWLINE# #INDENT# if ( self . cleaned_data [ 'parent' ] . slug == '' ) : #NEWLINE# #INDENT# errors_append ( self , 'parent' , _ ( 'You cannot add a sub_page to the empty slug page.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# return self . cleaned_data