Skip to content

Commit

Permalink
Merge pull request #192 from pavelkalin/master
Browse files Browse the repository at this point in the history
add new properrty - plugin_data
  • Loading branch information
sarumont authored Apr 10, 2017
2 parents cc7d685 + 3040ab1 commit ca86d8f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ dist
.pydevproject
.idea/
.tox/
.DS_Store
.DS_Store
example
18 changes: 18 additions & 0 deletions trello/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ def checklists(self):
self._checklists = None
return self._checklists

@property
def plugin_data(self):
"""
Lazily loads and returns the plugin data
"""
try:
if self._plugin_data is None:
self._plugin_data = self.fetch_plugin_data()
except AttributeError:
self._plugin_data = None
return self._plugin_data

@property
def attachments(self):
"""
Expand Down Expand Up @@ -183,6 +195,7 @@ def fetch(self, eager=True):
self.checked = json_obj['checkItemStates']
self.dateLastActivity = dateparser.parse(json_obj['dateLastActivity'])

self._plugin_data = self.fetch_plugin_data() if eager else None
self._checklists = self.fetch_checklists() if eager else None
self._comments = self.fetch_comments() if eager else None
self._attachments = self.fetch_attachments() if eager else None
Expand Down Expand Up @@ -226,6 +239,11 @@ def fetch_checklists(self):
trello_card=self.id))
return checklists

def fetch_plugin_data(self):
items = self.client.fetch_json(
'/cards/' + self.id + '/pluginData')
return items

def fetch_attachments(self, force=False):
if (force is True) or (self.badges['attachments'] > 0):
items = self.client.fetch_json(
Expand Down

0 comments on commit ca86d8f

Please sign in to comment.