From 9919f254ebe6730cfcc021ab95f7a0740af4ba31 Mon Sep 17 00:00:00 2001 From: "Xiongfei(Alex) Guo" Date: Wed, 21 May 2014 15:14:23 +0800 Subject: [PATCH] Rename an item for a Checklist. Signed-off-by: Xiongfei(Alex) Guo --- trello/__init__.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/trello/__init__.py b/trello/__init__.py index 5260f78b..5a44404f 100644 --- a/trello/__init__.py +++ b/trello/__init__.py @@ -712,6 +712,29 @@ def set_checklist_item(self, name, checked): self.items[ix] = json_obj return json_obj + def rename_checklist_item(self, name, new_name): + """Rename the item on this checklist + + :name: name of the checklist item + :new_name: new name of item + """ + + # Locate the id of the checklist item + try: + [ix] = [i for i in range(len(self.items)) if self.items[i]['name'] == name] + except ValueError: + return + + json_obj = self.client.fetch_json( + '/cards/'+self.trello_card+\ + '/checklist/'+self.id+\ + '/checkItem/'+self.items[ix]['id'], + http_method = 'PUT', + post_args = {'name' : new_name}) + + self.items[ix] = json_obj + return json_obj + def __repr__(self): return '' % self.id