Compare commits
1 Commits
master
...
assignee-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
2e178da9e3
|
@@ -5,7 +5,7 @@ A curses CLI for Asana, using the Asana API.
|
|||||||
* python 3
|
* python 3
|
||||||
* [python-asana](https://github.com/Asana/python-asana)
|
* [python-asana](https://github.com/Asana/python-asana)
|
||||||
* [urwid](http://urwid.org)
|
* [urwid](http://urwid.org)
|
||||||
* [python-dateutil](https://github.com/dateutil/dateutil/)
|
* [pyhon-dateutil](https://github.com/dateutil/dateutil/)
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
### Create an Asana OAuth app
|
### Create an Asana OAuth app
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ class AsanaService(object):
|
|||||||
]
|
]
|
||||||
|
|
||||||
STORY_FIELDS = [
|
STORY_FIELDS = [
|
||||||
'created_at',
|
|
||||||
'created_by.name',
|
'created_by.name',
|
||||||
'html_text',
|
'html_text',
|
||||||
'text',
|
'text',
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class Task(AsanaObject):
|
|||||||
return super(Task, self).name()
|
return super(Task, self).name()
|
||||||
|
|
||||||
def assignee(self):
|
def assignee(self):
|
||||||
if 'assignee' in self.object_dict and self.object_dict['assignee']:
|
if 'assignee' in self.object_dict:
|
||||||
return User(self.object_dict['assignee'])
|
return User(self.object_dict['assignee'])
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
@@ -57,7 +57,7 @@ class Task(AsanaObject):
|
|||||||
return datetime.strftime('%b %d, %Y %H:%M')
|
return datetime.strftime('%b %d, %Y %H:%M')
|
||||||
elif 'due_on' in self.object_dict and self.object_dict['due_on']:
|
elif 'due_on' in self.object_dict and self.object_dict['due_on']:
|
||||||
date = dateutil.parser.parse(self.object_dict['due_on'])
|
date = dateutil.parser.parse(self.object_dict['due_on'])
|
||||||
return date.strftime('%b %d, %Y')
|
date.strftime('%b %d, %Y')
|
||||||
else:
|
else:
|
||||||
return 'no due date'
|
return 'no due date'
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ class HTMLTextParser(HTMLParser):
|
|||||||
self.text.append(Text(data))
|
self.text.append(Text(data))
|
||||||
|
|
||||||
def handle_endtag(self, tag):
|
def handle_endtag(self, tag):
|
||||||
data = self.text.pop() if len(self.text) > 0 else Text("")
|
data = self.text.pop()
|
||||||
Class = self.tag_stack.pop()
|
Class = self.tag_stack.pop()
|
||||||
|
|
||||||
if tag == 'ul' or tag =='ol':
|
if tag == 'ul' or tag =='ol':
|
||||||
@@ -211,13 +211,6 @@ class Story(AsanaObject):
|
|||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def created_at(self):
|
|
||||||
if 'created_at' in self.object_dict:
|
|
||||||
return dateutil.parser.parse(self.object_dict['created_at']) \
|
|
||||||
.replace(tzinfo=timezone.utc).astimezone(tz=None)
|
|
||||||
else:
|
|
||||||
return ''
|
|
||||||
|
|
||||||
def text(self):
|
def text(self):
|
||||||
if 'html_text' in self.object_dict:
|
if 'html_text' in self.object_dict:
|
||||||
parser = HTMLTextParser()
|
parser = HTMLTextParser()
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
asana==0.8.2
|
asana==0.7.0
|
||||||
python-dateutil==2.8.0
|
python-dateutil==2.6.1
|
||||||
urwid==2.0.1
|
urwid==2.0.1
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
palette = [
|
palette = [
|
||||||
('atm_section', 'white,bold', 'dark blue'),
|
('atm_section', 'white,bold', 'dark blue'),
|
||||||
('author', 'bold,dark blue', ''),
|
('author', 'bold,dark blue', ''),
|
||||||
('timestamp', 'underline', ''),
|
|
||||||
('custom_fields', 'dark red', ''),
|
('custom_fields', 'dark red', ''),
|
||||||
('header', 'bold,light green', ''),
|
('header', 'bold,light green', ''),
|
||||||
('project', 'yellow', ''),
|
('project', 'yellow', ''),
|
||||||
|
|||||||
@@ -13,15 +13,15 @@ class TaskDetails(object):
|
|||||||
|
|
||||||
body = [
|
body = [
|
||||||
urwid.Text(('task', task.name())),
|
urwid.Text(('task', task.name())),
|
||||||
urwid.Divider('⎼'),
|
urwid.Divider('-'),
|
||||||
Memberships(task, on_subtask_click, on_project_click).component(),
|
Memberships(task, on_subtask_click, on_project_click).component(),
|
||||||
urwid.Divider('⎼'),
|
urwid.Divider('-'),
|
||||||
Assignee(task, on_assignee_click).component(),
|
Assignee(task, on_assignee_click).component(),
|
||||||
DueDate(task, on_due_date_click).component(),
|
DueDate(task, on_due_date_click).component(),
|
||||||
CustomFields(task).component(),
|
CustomFields(task).component(),
|
||||||
urwid.Divider('⎼'),
|
urwid.Divider('='),
|
||||||
urwid.Text(task.description()),
|
urwid.Text(task.description()),
|
||||||
urwid.Divider('⎼'),
|
urwid.Divider('-'),
|
||||||
]
|
]
|
||||||
|
|
||||||
if task.subtasks():
|
if task.subtasks():
|
||||||
@@ -49,7 +49,7 @@ class Assignee(object):
|
|||||||
assignee = "unassigned"
|
assignee = "unassigned"
|
||||||
|
|
||||||
|
|
||||||
self.assignee = urwid.SelectableIcon([('strong', 'Assignee: '), ('', assignee)])
|
self.assignee = urwid.SelectableIcon([('bold', 'Assignee: '), ('', assignee)])
|
||||||
|
|
||||||
self.on_click = on_click
|
self.on_click = on_click
|
||||||
#urwid.connect_signal(self.assignee, 'keypress', self.on_keypress)
|
#urwid.connect_signal(self.assignee, 'keypress', self.on_keypress)
|
||||||
@@ -65,8 +65,7 @@ class Assignee(object):
|
|||||||
|
|
||||||
class DueDate(object):
|
class DueDate(object):
|
||||||
def __init__(self, task, on_click):
|
def __init__(self, task, on_click):
|
||||||
due_date = task.due_date()
|
self.due_date = urwid.SelectableIcon([('bold', 'Due: '), ('', task.due_date())])
|
||||||
self.due_date = urwid.SelectableIcon([('strong', 'Due: '), ('', str(task.due_date()))])
|
|
||||||
|
|
||||||
self.on_click = on_click
|
self.on_click = on_click
|
||||||
#urwid.connect_signal(self.due_date, 'keypress', self.on_keypress)
|
#urwid.connect_signal(self.due_date, 'keypress', self.on_keypress)
|
||||||
@@ -117,11 +116,7 @@ class CustomFields(object):
|
|||||||
class Stories(object):
|
class Stories(object):
|
||||||
def __init__(self, stories):
|
def __init__(self, stories):
|
||||||
components = [
|
components = [
|
||||||
urwid.Text([
|
urwid.Text([('author', s.creator())] + s.text())
|
||||||
('timestamp', s.created_at().strftime('%Y-%m-%d %H:%M')),
|
|
||||||
' ',
|
|
||||||
('author', s.creator()),
|
|
||||||
] + s.text())
|
|
||||||
for s in stories]
|
for s in stories]
|
||||||
|
|
||||||
self.stories = urwid.Pile(components)
|
self.stories = urwid.Pile(components)
|
||||||
|
|||||||
Reference in New Issue
Block a user