#NEWLINE# def lookup_allowed( self , lookup , value ) : #NEWLINE# #INDENT# model = self . model #NEWLINE# for l in model . _meta . related_fkey_lookups : #NEWLINE# #INDENT# for ( k , v ) in widgets . url_params_from_lookup_dict ( l ) . items ( ) : #NEWLINE# #INDENT# if ( ( k == lookup ) and ( v == value ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# parts = lookup . split ( LOOKUP_SEP ) #NEWLINE# if ( ( len ( parts ) > 1 ) and ( parts [ ( - 1 ) ] in QUERY_TERMS ) ) : #NEWLINE# #INDENT# parts . pop ( ) #NEWLINE# #UNINDENT# rel_name = None #NEWLINE# for part in parts [ : ( - 1 ) ] : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( field , _ , _ , _ ) = model . _meta . get_field_by_name ( part ) #NEWLINE# #UNINDENT# except FieldDoesNotExist : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# if hasattr ( field , 'rel' ) : #NEWLINE# #INDENT# if ( field . rel is None ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# model = field . rel . to #NEWLINE# rel_name = field . rel . get_related_field ( ) . name #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( field , RelatedObject ) : #NEWLINE# #INDENT# model = field . model #NEWLINE# rel_name = model . _meta . pk . name #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# rel_name = None #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( rel_name and ( len ( parts ) > 1 ) and ( parts [ ( - 1 ) ] == rel_name ) ) : #NEWLINE# #INDENT# parts . pop ( ) #NEWLINE# #UNINDENT# if ( len ( parts ) == 1 ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# clean_lookup = LOOKUP_SEP . join ( parts ) #NEWLINE# return ( ( clean_lookup in self . list_filter ) or ( clean_lookup == self . date_hierarchy ) )