Skip to content

Commit

Permalink
A few things I added for a project of mine:
Browse files Browse the repository at this point in the history
1. all_boards can now filter, for example open (https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username-boards)
2. Cards and boards parse dateLastActivity without needing another fetch (as it is returned in the original json).
  • Loading branch information
Sveder committed Nov 27, 2015
1 parent 083c7bf commit 8a6aa7a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions trello/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from trello.card import Card
from trello.trellolist import List
from trello.label import Label
from dateutil import parser as dateparser


class Board(object):
Expand Down Expand Up @@ -55,6 +56,12 @@ def from_json(cls, trello_client=None, organization=None, json_obj=None):
board.description = json_obj.get('desc', '').encode('utf-8')
board.closed = json_obj['closed']
board.url = json_obj['url']

try:
board.date_last_activity = dateparser.parse(json_obj['dateLastActivity'])
except:
pass

return board

def __repr__(self):
Expand Down
1 change: 1 addition & 0 deletions trello/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def from_json(cls, parent, json_obj):
card.idLabels = json_obj['idLabels']
card.idList = json_obj['idList']
card.labels = Label.from_json_list(card.board, json_obj['labels'])
card.dateLastActivity = dateparser.parse(json_obj['dateLastActivity'])
return card

def __repr__(self):
Expand Down
4 changes: 2 additions & 2 deletions trello/trelloclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def logout(self):
# TODO: This function.
raise NotImplementedError()

def list_boards(self):
def list_boards(self, board_filter="all"):
"""
Returns all boards for your Trello user
Expand All @@ -81,7 +81,7 @@ def list_boards(self):
- closed: Boolean representing whether this board is closed or not
- url: URL to the board
"""
json_obj = self.fetch_json('/members/me/boards')
json_obj = self.fetch_json('/members/me/boards/?filter=%s' % board_filter)
return [Board.from_json(self, json_obj=obj) for obj in json_obj]

def list_organizations(self):
Expand Down

0 comments on commit 8a6aa7a

Please sign in to comment.