From 47eff82d3f36e9b19408579e7971f10a34424a99 Mon Sep 17 00:00:00 2001 From: Aaron Gutierrez Date: Mon, 21 May 2018 17:58:30 -0700 Subject: [PATCH] show story creation time in details view --- asana_service.py | 1 + models/models.py | 8 +++++++- ui/constants.py | 1 + ui/task_details.py | 6 +++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/asana_service.py b/asana_service.py index 0911f67..a816160 100644 --- a/asana_service.py +++ b/asana_service.py @@ -25,6 +25,7 @@ class AsanaService(object): ] STORY_FIELDS = [ + 'created_at', 'created_by.name', 'html_text', 'text', diff --git a/models/models.py b/models/models.py index abef38c..cc20783 100644 --- a/models/models.py +++ b/models/models.py @@ -1,4 +1,4 @@ -import dateutil +import dateutil.parser from html.parser import HTMLParser import sys @@ -198,6 +198,12 @@ class Story(AsanaObject): else: return '' + def created_at(self): + if 'created_at' in self.object_dict: + return dateutil.parser.parse(self.object_dict['created_at']) + else: + return '' + def text(self): if 'html_text' in self.object_dict: parser = HTMLTextParser() diff --git a/ui/constants.py b/ui/constants.py index 8d793b5..6afe633 100644 --- a/ui/constants.py +++ b/ui/constants.py @@ -1,6 +1,7 @@ palette = [ ('atm_section', 'white,bold', 'dark blue'), ('author', 'bold,dark blue', ''), + ('timestamp', 'underline', ''), ('custom_fields', 'dark red', ''), ('header', 'bold,light green', ''), ('project', 'yellow', ''), diff --git a/ui/task_details.py b/ui/task_details.py index a7ad9e7..637a4ec 100644 --- a/ui/task_details.py +++ b/ui/task_details.py @@ -75,7 +75,11 @@ class CustomFields(object): class Stories(object): def __init__(self, stories): components = [ - urwid.Text([('author', s.creator())] + s.text()) + urwid.Text([ + ('timestamp', s.created_at().strftime('%Y-%m-%d %H:%M')), + ' ', + ('author', s.creator()), + ] + s.text()) for s in stories] self.stories = urwid.Pile(components)