<s> import datetime <EOL> from haystack import indexes <EOL> from haystack . sites import site <EOL> from brubeck . podcasts . models import Channel , Episode <EOL> class ChannelIndex ( indexes . SearchIndex ) : <EOL> text = indexes . CharField ( document = True , use_template = True ) <EOL> section = indexes . MultiValueField ( ) <EOL> section_exact = indexes . MultiValueField ( indexed = False ) <EOL> publication = indexes . MultiValueField ( ) <EOL> publication_exact = indexes . MultiValueField ( indexed = False ) <EOL> rendered = indexes . CharField ( use_template = True , indexed = False , ) <EOL> def prepare_section ( self , object ) : <EOL> sections = [ ] <EOL> for section in object . section . all ( ) : <EOL> sections . append ( section ) <EOL> return sections <EOL> def prepare_section_exact ( self , object ) : <EOL> sections = [ ] <EOL> for section in object . section . all ( ) : <EOL> sections . append ( section ) <EOL> return sections <EOL> def prepare_publication ( self , object ) : <EOL> publications = [ ] <EOL> for section in object . section . all ( ) : <EOL> publications . append ( section . publication . name ) <EOL> return publications <EOL> def prepare_publication_exact ( self , object ) : <EOL> publications = [ ] <EOL> for section in object . section . all ( ) : <EOL> publications . append ( section . publication . name ) <EOL> return publications <EOL> def get_updated_field ( self ) : <EOL> return '<STR_LIT>' <EOL> site . register ( Channel , ChannelIndex ) <EOL> class EpisodeIndex ( indexes . SearchIndex ) : <EOL> text = indexes . CharField ( document = True , use_template = True ) <EOL> channel = indexes . CharField ( model_attr = '<STR_LIT>' ) <EOL> channel_exact = indexes . CharField ( model_attr = '<STR_LIT>' , indexed = False ) <EOL> pub_date = indexes . DateTimeField ( model_attr = '<STR_LIT>' ) <EOL> producers = indexes . MultiValueField ( ) <EOL> producers_exact = indexes . MultiValueField ( indexed = False ) <EOL> writers = indexes . MultiValueField ( ) <EOL> writers_exact = indexes . MultiValueField ( indexed = False ) <EOL> reporters = indexes . MultiValueField ( ) <EOL> reporters_exact = indexes . MultiValueField ( indexed = False ) <EOL> publication = indexes . MultiValueField ( ) <EOL> publication_exact = indexes . MultiValueField ( indexed = False ) <EOL> rendered = indexes . CharField ( use_template = True , indexed = False , ) <EOL> def prepare_producers ( self , object ) : <EOL> return [ byline . get_full_name ( ) for byline in object . producers . all ( ) ] <EOL> def prepare_producers_exact ( self , object ) : <EOL> return [ byline . get_full_name ( ) for byline in object . producers . all ( ) ] <EOL> def prepare_writers ( self , object ) : <EOL> return [ byline . get_full_name ( ) for byline in object . writers . all ( ) ] <EOL> def prepare_writers_exact ( self , object ) : <EOL> return [ byline . get_full_name ( ) for byline in object . writers . all ( ) ] <EOL> def prepare_reporters ( self , object ) : <EOL> return [ byline . get_full_name ( ) for byline in object . reporters . all ( ) ] <EOL> def prepare_reporters_exact ( self , object ) : <EOL> return [ byline . get_full_name ( ) for byline in object . reporters . all ( ) ] <EOL> def prepare_publication ( self , object ) : <EOL> publications = [ ] <EOL> for section in object . channel . section . all ( ) : <EOL> publications . append ( section . publication . name ) <EOL> return publications <EOL> def prepare_publication_exact ( self , object ) : <EOL> publications = [ ] <EOL> for section in object . channel . section . all ( ) : <EOL> publications . append ( section . publication . name ) <EOL> return publications <EOL> def get_updated_field ( self ) : <EOL> return '<STR_LIT>' <EOL> def get_displayed_name ( self ) : <EOL> return '<STR_LIT>' <EOL> def get_plural_name ( self ) : <EOL> return '<STR_LIT>' <EOL> def get_main_result_limit ( self ) : <EOL> return <NUM_LIT:3> <EOL> def get_queryset ( self ) : <EOL> return Episode . objects . filter ( pub_date__lte = datetime . datetime . now ( ) ) <EOL> site . register ( Episode , EpisodeIndex ) </s>
