#NEWLINE# def clean( self ) : #NEWLINE# #INDENT# 'Validate the state of the entire form.\n\n        Returns:\n            The cleaned form data.\n        ' #NEWLINE# super ( WebHookTargetForm , self ) . clean ( ) #NEWLINE# custom_content = self . cleaned_data . get ( 'custom_content' , '' ) #NEWLINE# self . cleaned_data [ 'use_custom_content' ] = ( len ( custom_content ) > 0 ) #NEWLINE# apply_to = self . cleaned_data . get ( 'apply_to' ) #NEWLINE# if ( ( apply_to != WebHookTarget . APPLY_TO_SELECTED_REPOS ) or ( 'repositories' not in self . cleaned_data ) ) : #NEWLINE# #INDENT# self . cleaned_data [ 'repositories' ] = Repository . objects . none ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# queryset = self . cleaned_data [ 'repositories' ] #NEWLINE# local_site = self . cleaned_data . get ( 'local_site' ) #NEWLINE# errors = [ ] #NEWLINE# for repository in queryset : #NEWLINE# #INDENT# if ( repository . local_site != local_site ) : #NEWLINE# #INDENT# errors . append ( ( _ ( 'Repository with ID %(id)s is invalid.' ) % { #NEWLINE# #INDENT# 'id' : repository . pk , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# #UNINDENT# if errors : #NEWLINE# #INDENT# del self . cleaned_data [ 'repositories' ] #NEWLINE# self . _errors [ 'repositories' ] = self . error_class ( errors ) #NEWLINE# #UNINDENT# #UNINDENT# return self . cleaned_data