Permalink
Browse files

Merge pull request #18 from agraf/add-checklist-and-comments

Add support for checklists and comments
  • Loading branch information...
sarumont committed Jan 9, 2013
2 parents 9315337 + 0f66450 commit 59be53e25af05af2139cf68dd0a1649f7a677a01
Showing with 32 additions and 0 deletions.
  1. +32 −0 trello/__init__.py
View
@@ -351,6 +351,20 @@ def fetch(self):
self.board_id = json_obj['idBoard']
self.labels = json_obj['labels']
self.badges = json_obj['badges']
+ self.checked = json_obj['checkItemStates']
+
+ self.checklists = []
+ if self.badges['checkItems'] > 0:
+ json_obj = self.client.fetch_json(
+ '/cards/'+self.id+'/checklists',)
+ for cl in json_obj:
+ self.checklists.append(Checklist(self.client, self.checked, cl))
+
+ self.comments = []
+ if self.badges['comments'] > 0:
+ self.comments = self.client.fetch_json(
+ '/cards/'+self.id+'/actions',
+ query_params = {'filter': 'commentCard'})
def fetch_actions(self, action_filter='createCard'):
"""
@@ -426,4 +440,22 @@ def fetch(self):
self.initials = json_obj['initials'].encode('utf-8')
return self
+class Checklist(object):
+ """
+ Class representing a Trello checklist.
+ """
+
+ def __init__(self, client, checked, obj):
+ self.client = client
+ self.id = obj['id']
+ self.items = obj['checkItems']
+ for i in self.items:
+ i['checked'] = False
+ for cis in checked:
+ if cis['idCheckItem'] == i['id'] and cis['state'] == 'complete':
+ i['checked'] = True
+
+ def __repr__(self):
+ return '<Checklist %s>' % self.id
+
# vim:noexpandtab

0 comments on commit 59be53e

Please sign in to comment.