#NEWLINE# @ classmethod #NEWLINE# def from_model( cls , entity ) : #NEWLINE# #INDENT# model_type = entity . __class__ . __name__ #NEWLINE# primary_location = None #NEWLINE# location_classes = set ( ) #NEWLINE# for location in entity . search_all_locations : #NEWLINE# #INDENT# if location : #NEWLINE# #INDENT# if location . classification : #NEWLINE# #INDENT# location_classes . add ( location . classification ) #NEWLINE# #UNINDENT# if ( ( not primary_location ) and location . latitude and location . longitude ) : #NEWLINE# #INDENT# primary_location = location #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# index = Autocomplete ( id = ':' . join ( [ model_type , str ( entity . id ) ] ) , type = model_type , exact_name = entity . search_exact_name , name = entity . search_all_names , is_vetted = entity . search_jumo_vetted , locations = [ unicode ( loc ) for loc in entity . search_all_locations ] , popularity = entity . search_popularity , summary = getattr ( entity , 'summary' , None ) , keywords = entity . search_keywords , url = entity . get_url , image_url = location_classes . get_image_small ) #NEWLINE# if location_classes : #NEWLINE# #INDENT# index . location_classifiers = location_classes #NEWLINE# #UNINDENT# if hasattr ( entity , 'search_all_issues' ) : #NEWLINE# #INDENT# index . stored_issues = [ pickle . dumps ( issue ) for issue in entity . search_all_issues ] #NEWLINE# #UNINDENT# if primary_location : #NEWLINE# #INDENT# index . geo_location = ',' . join ( [ str ( primary_location . latitude ) , str ( primary_location . longitude ) ] ) #NEWLINE# #UNINDENT# return index