<s> """<STR_LIT>""" <EOL> from dal . widgets import WidgetMixin <EOL> from django import forms <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . utils import six <EOL> class QuerySetSequenceSelectMixin ( WidgetMixin ) : <EOL> """<STR_LIT>""" <EOL> def filter_choices_to_render ( self , selected_choices ) : <EOL> """<STR_LIT>""" <EOL> if len ( selected_choices ) == <NUM_LIT:1> and not selected_choices [ <NUM_LIT:0> ] : <EOL> selected_choices = [ ] <EOL> ctype_models = { } <EOL> for choice in selected_choices : <EOL> ctype_pk , model_pk = choice . split ( '<STR_LIT:->' ) <EOL> ctype_pk = int ( ctype_pk ) <EOL> ctype_models . setdefault ( ctype_pk , [ ] ) <EOL> ctype_models [ ctype_pk ] . append ( model_pk ) <EOL> self . choices = [ ] <EOL> ctype = ContentType . objects . get_for_id <EOL> for ctype_pk , ids in ctype_models . items ( ) : <EOL> results = ctype ( ctype_pk ) . model_class ( ) . objects . filter ( pk__in = ids ) <EOL> self . choices += [ <EOL> ( '<STR_LIT>' % ( ctype_pk , r . pk ) , six . text_type ( r ) ) <EOL> for r in results <EOL> ] <EOL> class QuerySetSequenceSelect ( QuerySetSequenceSelectMixin , <EOL> forms . Select ) : <EOL> """<STR_LIT>""" <EOL> class QuerySetSequenceSelectMultiple ( QuerySetSequenceSelectMixin , <EOL> forms . SelectMultiple ) : <EOL> """<STR_LIT>""" </s>
