Skip to content

Commit

Permalink
handling pos attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
biern committed May 3, 2015
1 parent 3ff2cd9 commit 8295665
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
15 changes: 15 additions & 0 deletions test/test_trello.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,21 @@ def test54_set(self):
self.assertEquals(card.name, name)
self.assertEquals(card.description, description)

def test55_set_pos(self):
card_names = lambda: [c.name for c in self._list.list_cards()]
self._list.add_card('card1')
card2 = self._list.add_card('card2')
names = card_names()
self.assertGreater(names.index('card2'), names.index('card1'))

card2.set_pos('top')
names = card_names()
self.assertGreater(names.index('card1'), names.index('card2'))

card2.set_pos('bottom')
names = card_names()
self.assertGreater(names.index('card2'), names.index('card1'))

def test60_delete_cards(self):
cards = self._board.get_cards()
for card in cards:
Expand Down
12 changes: 11 additions & 1 deletion trello/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ def fetch(self, eager=True):
self.idBoard = json_obj['idBoard']
self.labels = json_obj['labels']
self.badges = json_obj['badges']
self.pos = json_obj['pos']
# For consistency, due date is in YYYY-MM-DD format
if json_obj.get('due', ''):
self.due = json_obj.get('due', '')[:10]
Expand All @@ -695,7 +696,7 @@ def get_comments(self):
'/cards/' + self.id + '/actions',
query_params={'filter': 'commentCard'})
return comments

def fetch_checklists(self):
checklists = []
json_obj = self.client.fetch_json(
Expand Down Expand Up @@ -788,6 +789,15 @@ def set_due(self, due):
self._set_remote_attribute('due', datestr)
self.due = datestr

def set_pos(self, pos):
"""
Update card position in list
:pos: 'top', 'bottom' or int
"""
self._set_remote_attribute('pos', pos)
self.pos = pos

def set_closed(self, closed):
self._set_remote_attribute('closed', closed)
self.closed = closed
Expand Down

0 comments on commit 8295665

Please sign in to comment.