#NEWLINE# @ property #NEWLINE# def rows( self ) : #NEWLINE# #INDENT# data = SMS . by_domain ( self . domain , start_date = self . datespan . startdate_utc , end_date = self . datespan . enddate_utc ) . exclude ( direction = OUTGOING , processed = False ) . order_by ( 'date' ) #NEWLINE# if self . show_only_survey_traffic ( ) : #NEWLINE# #INDENT# data = data . filter ( xforms_session_couch_id__isnull = False ) #NEWLINE# #UNINDENT# result = [ ] #NEWLINE# direction_map = { #NEWLINE# #INDENT# INCOMING : _ ( 'Incoming' ) , #NEWLINE# OUTGOING : _ ( 'Outgoing' ) , #NEWLINE# #UNINDENT# } #NEWLINE# message_bank_messages = get_message_bank ( self . domain , for_comparing = True ) #NEWLINE# FormProcessorInterface ( self . domain ) . casedb_cache ( domain = self . domain , strip_history = False , deleted_ok = True ) #NEWLINE# user_cache = UserCache ( ) #NEWLINE# for message in data : #NEWLINE# #INDENT# if ( ( message . direction == OUTGOING ) and ( not message . fri_message_bank_lookup_completed ) ) : #NEWLINE# #INDENT# add_metadata ( message , message_bank_messages ) #NEWLINE# #UNINDENT# if ( message . couch_recipient_doc_type == 'CommCareCase' ) : #NEWLINE# #INDENT# recipient = case_cache . get ( message . couch_recipient ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# recipient = user_cache . get ( message . couch_recipient ) #NEWLINE# #UNINDENT# if message . chat_user_id : #NEWLINE# #INDENT# sender = user_cache . get ( message . chat_user_id ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sender = None #NEWLINE# #UNINDENT# study_arm = None #NEWLINE# if ( message . couch_recipient_doc_type == 'CommCareCase' ) : #NEWLINE# #INDENT# study_arm = case_cache . get ( message . couch_recipient ) . get_case_property ( 'study_arm' ) #NEWLINE# #UNINDENT# timestamp = ServerTime ( message . date ) . user_time ( self . timezone ) . done ( ) #NEWLINE# result . append ( [ self . _fmt ( self . _participant_id ( recipient ) ) , self . _fmt ( ( study_arm or '-' ) ) , self . _fmt ( self . _originator ( message , recipient , sender ) ) , self . _fmt_timestamp ( timestamp ) , self . _fmt ( message . text ) , self . _fmt ( ( message . fri_id or '-' ) ) , self . _fmt ( direction_map . get ( message . direction , '-' ) ) ] ) #NEWLINE# #UNINDENT# return result