Refactor MDList function
This commit is contained in:
parent
0becffb71f
commit
df4071bac1
|
@ -145,18 +145,26 @@ def empty_screen_label(label_str=None, no_search_res_found=None):
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
def mdlist_message_content(queryreturn, data):
|
def set_mail_details(mail):
|
||||||
"""Method to check the length of message content"""
|
"""Return mail details"""
|
||||||
secondary_txt_len = 10
|
secondary_txt_len = 10
|
||||||
third_txt_len = 25
|
third_txt_len = 25
|
||||||
dot_str = '...........'
|
dot_str = '...........'
|
||||||
dot_str2 = '...!'
|
dot_str2 = '...!'
|
||||||
|
third_text = mail[3].replace('\n', ' ')
|
||||||
|
|
||||||
|
mail_details_data = {
|
||||||
|
'text': mail[1].strip(),
|
||||||
|
'secondary_text': mail[2][:secondary_txt_len] + dot_str if len(mail[2]) > secondary_txt_len
|
||||||
|
else mail[2] + '\n' + " " + (third_text[:third_txt_len] + dot_str2)
|
||||||
|
if len(third_text) > third_txt_len else third_text,
|
||||||
|
'ackdata': mail[5], 'senttime': mail[6]
|
||||||
|
}
|
||||||
|
return mail_details_data
|
||||||
|
|
||||||
|
|
||||||
|
def mdlist_message_content(queryreturn, data):
|
||||||
|
"""Set Mails details in MD_list"""
|
||||||
for mail in queryreturn:
|
for mail in queryreturn:
|
||||||
third_text = mail[3].replace('\n', ' ')
|
mdlist_data = set_mail_details(mail)
|
||||||
data.append({
|
data.append(mdlist_data)
|
||||||
'text': mail[1].strip(),
|
|
||||||
'secondary_text': mail[2][:secondary_txt_len] + dot_str if len(
|
|
||||||
mail[2]) > secondary_txt_len else mail[2] + '\n' + " " + (
|
|
||||||
third_text[:third_txt_len] + dot_str2) if len(
|
|
||||||
third_text) > third_txt_len else third_text,
|
|
||||||
'ackdata': mail[5], 'senttime': mail[6]})
|
|
||||||
|
|
Reference in New Issue
Block a user