<s> """<STR_LIT>""" <EOL> from django import forms <EOL> from django . contrib import admin <EOL> from salmonella . widgets import SalmonellaIdWidget <EOL> class SalmonellaFilterForm ( forms . Form ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , rel , admin_site , field_name , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> super ( SalmonellaFilterForm , self ) . __init__ ( ** kwargs ) <EOL> self . fields [ '<STR_LIT:%s>' % field_name ] = forms . IntegerField ( <EOL> label = '<STR_LIT>' , widget = SalmonellaIdWidget ( <EOL> rel = rel , admin_site = admin_site ) , required = False ) <EOL> class SalmonellaFilter ( admin . filters . FieldListFilter ) : <EOL> """<STR_LIT>""" <EOL> template = '<STR_LIT>' <EOL> def __init__ ( self , field , request , params , model , model_admin , field_path ) : <EOL> """<STR_LIT>""" <EOL> self . lookup_kwarg = '<STR_LIT:%s>' % field_path <EOL> super ( SalmonellaFilter , self ) . __init__ ( <EOL> field , request , params , model , model_admin , field_path ) <EOL> self . form = self . get_form ( request , field . rel , model_admin . admin_site ) <EOL> def choices ( self , cl ) : <EOL> """<STR_LIT>""" <EOL> return [ ] <EOL> def expected_parameters ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ self . lookup_kwarg ] <EOL> def get_form ( self , request , rel , admin_site ) : <EOL> """<STR_LIT>""" <EOL> return SalmonellaFilterForm ( admin_site = admin_site , rel = rel , <EOL> field_name = self . field_path , <EOL> data = self . used_parameters ) <EOL> def queryset ( self , request , queryset ) : <EOL> """<STR_LIT>""" <EOL> if self . form . is_valid ( ) : <EOL> filter_params = dict ( filter ( lambda x : bool ( x [ <NUM_LIT:1> ] ) , <EOL> self . form . cleaned_data . items ( ) ) ) <EOL> return queryset . filter ( ** filter_params ) <EOL> else : <EOL> return queryset </s>
