Skip to content

Commit

Permalink
Added support to get subscription status for lists as well as subscri…
Browse files Browse the repository at this point in the history
…be/unsubscribe from lists
  • Loading branch information
fabianjs committed Apr 13, 2018
1 parent 1c8990a commit 1a6b0e5
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion trello/trellolist.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, board, list_id, name=''):
self.name = name
self.closed = None
self.pos = None
self.subscribed = None

@classmethod
def from_json(cls, board, json_obj):
Expand All @@ -36,6 +37,9 @@ def from_json(cls, board, json_obj):
list = List(board, json_obj['id'], name=json_obj['name'])
list.closed = json_obj['closed']
list.pos = json_obj['pos']
#this method is also called from board.py with a different json object, so we need to make sure 'subscribed' is there
if 'subscribed' in json_obj:
list.subscribed = json_obj['subscribed']
return list

def __repr__(self):
Expand All @@ -47,7 +51,8 @@ def fetch(self):
self.name = json_obj['name']
self.closed = json_obj['closed']
self.pos = json_obj['pos']

self.subscribed = json_obj['subscribed']

def list_cards(self, card_filter="open", actions=None):
"""Lists all cards in this list"""
query_params = {}
Expand Down Expand Up @@ -156,6 +161,22 @@ def move(self, position):
post_args={'value': position, }, )
self.pos = position

# Subscribe to this list
def subscribe(self):
self.client.fetch_json(
'/lists/' + self.id + '/subscribed',
http_method='PUT',
post_args={'value': 'true', }, )
self.subscribed = True

# Unsubscribe from this list
def unsubscribe(self):
self.client.fetch_json(
'/lists/' + self.id + '/subscribed',
http_method='PUT',
post_args={'value': 'false', }, )
self.subscribed = False

def cardsCnt(self):
return len(self.list_cards())

Expand Down

0 comments on commit 1a6b0e5

Please sign in to comment.