<s> from haystack import indexes <EOL> from . models import InternationalOrganization <EOL> class OrgIndex ( indexes . SearchIndex , indexes . Indexable ) : <EOL> text = indexes . CharField ( document = True , use_template = True , <EOL> template_name = "<STR_LIT>" ) <EOL> name = indexes . CharField ( model_attr = '<STR_LIT:name>' ) <EOL> sort_name = indexes . CharField ( model_attr = '<STR_LIT:name>' , indexed = False , <EOL> stored = True ) <EOL> government = indexes . CharField ( faceted = True ) <EOL> url = indexes . CharField ( null = True , stored = True , indexed = False ) <EOL> population = indexes . IntegerField ( null = True ) <EOL> def get_model ( self ) : <EOL> return InternationalOrganization <EOL> def prepare ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> return super ( OrgIndex , self ) . prepare ( obj ) <EOL> def prepare_government ( self , obj ) : <EOL> return u"<STR_LIT>" <EOL> def prepare_population ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> members = obj . members . all ( ) <EOL> if not members : <EOL> return None <EOL> return sum ( [ member . population for member in members ] ) <EOL> def prepare_url ( self , obj ) : <EOL> return obj . get_absolute_url ( ) </s>
