From ad25adcd9311cb09421cec27d4f5a6e68b854ad7 Mon Sep 17 00:00:00 2001 From: Duda Dornelles Date: Fri, 10 Oct 2014 17:49:02 +0200 Subject: Sorting mails by date - again --- service/pixelated/adapter/pixelated_mail.py | 3 +++ service/pixelated/user_agent.py | 3 +++ 2 files changed, 6 insertions(+) (limited to 'service/pixelated') diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py index 95f417d2..4b207059 100644 --- a/service/pixelated/adapter/pixelated_mail.py +++ b/service/pixelated/adapter/pixelated_mail.py @@ -242,6 +242,9 @@ class PixelatedMail: def get_bcc(self): return self.headers['Bcc'] + def get_date(self): + return self.headers['Date'] + def remove_all_tags(self): self.update_tags(set([])) diff --git a/service/pixelated/user_agent.py b/service/pixelated/user_agent.py index 1bab0281..d97d5905 100644 --- a/service/pixelated/user_agent.py +++ b/service/pixelated/user_agent.py @@ -37,6 +37,7 @@ from pixelated.adapter.soledad_querier import SoledadQuerier from pixelated.adapter.search import SearchEngine from pixelated.adapter.tag_service import TagService from pixelated.adapter.draft_service import DraftService +import dateutil.parser as dateparser static_folder = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "web-ui", "app")) @@ -97,6 +98,8 @@ def mails(): mail_ids = search_engine.search(request.args.get('q')) mails = mail_service.mails(mail_ids) + mails = sorted(mails, key=lambda mail: dateparser.parse(mail.get_date()), reverse=True) + response = { "stats": { "total": len(mails), -- cgit v1.2.3