Skip to content

Commit

Permalink
Added the ability to archive all cards, and add a due date on a card.…
Browse files Browse the repository at this point in the history
… Additionally, I updated creating a new card to use the Card path instead of the List path, since it allows for adding Labels by ID instead of by color
  • Loading branch information
larssorenson committed May 4, 2015
1 parent b080626 commit 6665de3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions trello/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,23 +549,28 @@ def list_cards(self):
json_obj = self.client.fetch_json('/lists/' + self.id + '/cards')
return [Card.from_json(self, c) for c in json_obj]

def add_card(self, name, desc=None, labels=None):
def add_card(self, name, desc=None, labels=[], due="null"):
"""Add a card to this list
:name: name for the card
:desc: the description of the card
:labels: a list of label IDs to be added
:return: the card
"""
labels_str = None
if labels:
labels_str = ",".join(labels)
labels_str = ""
for label in labels:
labels_str += label.id + ","
json_obj = self.client.fetch_json(
'/lists/' + self.id + '/cards',
'/cards',
http_method='POST',
post_args={'name': name, 'idList': self.id, 'desc': desc, 'idLabels': labels_str}, )
post_args={'name': name, 'idList': self.id, 'desc': desc, 'idLabels': labels_str[:-1], 'due': due})
return Card.from_json(self, json_obj)

def archive_all_cards(self):
self.client.fetch_json(
'/lists/' + self.id + '/archiveAllCards',
http_method='POST')

def fetch_actions(self, action_filter):
"""
Fetch actions for this list can give more argv to action_filter,
Expand Down

0 comments on commit 6665de3

Please sign in to comment.