Skip to content

Commit

Permalink
Modifies Cards.from_json to not require customFieldItems
Browse files Browse the repository at this point in the history
The Cards.from_json method expects that each time you query for
a card, the 'customFieldItems' key will be present in the json
returned from the API.  This causes an error if custom fields is
not enabled for the board or in the case where you're adding a
new card.

This patch changes the way the dictionary is accessed so that
when the customFieldItems key is not present it will return a
json collection with 0 length instead of raising a keyError.
  • Loading branch information
Ryan Brady committed May 25, 2018
1 parent 7dce815 commit 6135d52
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion trello/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def from_json(cls, parent, json_obj):
card.idBoard = json_obj['idBoard']
card.idList = json_obj['idList']
card.idShort = json_obj['idShort']
card.customFields = CustomField.from_json_list(card, json_obj['customFieldItems'])
card.customFields = CustomField.from_json_list(
card, json_obj.get('customFieldItems', {}))
card.labels = Label.from_json_list(card.board, json_obj['labels'])
card.dateLastActivity = dateparser.parse(json_obj['dateLastActivity'])
if "attachments" in json_obj:
Expand Down

0 comments on commit 6135d52

Please sign in to comment.