#NEWLINE# def clean( self ) : #NEWLINE# #INDENT# "Custom validation method\n\n        Depending on 'ldap_auth_method' value, we check for different\n        required parameters.\n        " #NEWLINE# super ( GeneralParametersForm , self ) . clean ( ) #NEWLINE# cleaned_data = self . cleaned_data #NEWLINE# if ( cleaned_data [ 'authentication_type' ] != 'ldap' ) : #NEWLINE# #INDENT# return cleaned_data #NEWLINE# #UNINDENT# if ( cleaned_data [ 'ldap_auth_method' ] == 'searchbind' ) : #NEWLINE# #INDENT# required_fields = [ 'ldap_search_base' , 'ldap_search_filter' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# required_fields = [ 'ldap_user_dn_template' ] #NEWLINE# #UNINDENT# for f in required_fields : #NEWLINE# #INDENT# if ( ( f not in cleaned_data ) or ( cleaned_data [ f ] == '' ) ) : #NEWLINE# #INDENT# self . add_error ( self , _ ( 'This field is required' ) ) #NEWLINE# #UNINDENT# #UNINDENT# return cleaned_data