Skip to content

Commit

Permalink
Merge pull request #190 from diegojromerolopez/master
Browse files Browse the repository at this point in the history
Get attachments if fetched with the card
  • Loading branch information
sarumont authored Mar 22, 2017
2 parents 49c4356 + ce2b291 commit cc7d685
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions trello/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ def from_json(cls, parent, json_obj):
card.idShort = json_obj['idShort']
card.labels = Label.from_json_list(card.board, json_obj['labels'])
card.dateLastActivity = dateparser.parse(json_obj['dateLastActivity'])
if "attachments" in json_obj:
card._attachments = []
for attachment_json in json_obj["attachments"]:
card._attachments.append(attachment_json)
return card

def __repr__(self):
Expand Down Expand Up @@ -583,7 +587,7 @@ def attach(self, name=None, mimeType=None, file=None, url=None):
kwargs['mimeType'] = mimeType
kwargs['url'] = url

self._post_remote_data('attachments', **kwargs)
return self._post_remote_data('attachments', **kwargs)

def remove_attachment(self, attachment_id):
"""
Expand Down Expand Up @@ -650,7 +654,7 @@ def _set_remote_attribute(self, attribute, value):
post_args={'value': value}, )

def _post_remote_data(self, attribute, files=None, **kwargs):
self.client.fetch_json(
return self.client.fetch_json(
'/cards/' + self.id + '/' + attribute,
http_method='POST',
files=files,
Expand Down

0 comments on commit cc7d685

Please sign in to comment.