<s> from __future__ import absolute_import , unicode_literals <EOL> from rest_framework . fields import ( <EOL> BooleanField , CharField , DateField , DateTimeField , <EOL> DecimalField , FloatField , IntegerField <EOL> ) <EOL> class DRFHaystackFieldMixin ( object ) : <EOL> prefix_field_names = False <EOL> def __init__ ( self , ** kwargs ) : <EOL> self . prefix_field_names = kwargs . pop ( '<STR_LIT>' , False ) <EOL> super ( DRFHaystackFieldMixin , self ) . __init__ ( ** kwargs ) <EOL> def bind ( self , field_name , parent ) : <EOL> """<STR_LIT>""" <EOL> assert self . source != field_name , ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( field_name , self . __class__ . __name__ , parent . __class__ . __name__ ) <EOL> ) <EOL> self . field_name = field_name <EOL> self . parent = parent <EOL> if self . label is None : <EOL> self . label = field_name . replace ( '<STR_LIT:_>' , '<STR_LIT:U+0020>' ) . capitalize ( ) <EOL> if self . source is None : <EOL> self . source = self . convert_field_name ( field_name ) <EOL> if self . source == '<STR_LIT:*>' : <EOL> self . source_attrs = [ ] <EOL> else : <EOL> self . source_attrs = self . source . split ( '<STR_LIT:.>' ) <EOL> def convert_field_name ( self , field_name ) : <EOL> if not self . prefix_field_names : <EOL> return field_name <EOL> return field_name . split ( "<STR_LIT>" ) [ - <NUM_LIT:1> ] <EOL> class HaystackBooleanField ( DRFHaystackFieldMixin , BooleanField ) : <EOL> pass <EOL> class HaystackCharField ( DRFHaystackFieldMixin , CharField ) : <EOL> pass <EOL> class HaystackDateField ( DRFHaystackFieldMixin , DateField ) : <EOL> pass <EOL> class HaystackDateTimeField ( DRFHaystackFieldMixin , DateTimeField ) : <EOL> pass <EOL> class HaystackDecimalField ( DRFHaystackFieldMixin , DecimalField ) : <EOL> pass <EOL> class HaystackFloatField ( DRFHaystackFieldMixin , FloatField ) : <EOL> pass <EOL> class HaystackIntegerField ( DRFHaystackFieldMixin , IntegerField ) : <EOL> pass </s>
