Refactor MDList function

This commit is contained in:
shekhar-cis 2022-06-02 21:50:51 +05:30
parent 0becffb71f
commit df4071bac1
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7

View File

@ -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 = '...!'
for mail in queryreturn:
third_text = mail[3].replace('\n', ' ') third_text = mail[3].replace('\n', ' ')
data.append({
mail_details_data = {
'text': mail[1].strip(), 'text': mail[1].strip(),
'secondary_text': mail[2][:secondary_txt_len] + dot_str if len( 'secondary_text': mail[2][:secondary_txt_len] + dot_str if len(mail[2]) > secondary_txt_len
mail[2]) > secondary_txt_len else mail[2] + '\n' + " " + ( else mail[2] + '\n' + " " + (third_text[:third_txt_len] + dot_str2)
third_text[:third_txt_len] + dot_str2) if len( if len(third_text) > third_txt_len else third_text,
third_text) > third_txt_len else third_text, 'ackdata': mail[5], 'senttime': mail[6]
'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:
mdlist_data = set_mail_details(mail)
data.append(mdlist_data)