From cbe35d606a067c757ba7200e5e1181cd9528e331 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Thu, 4 Feb 2016 15:28:54 +0000 Subject: [PATCH] Don't add non-existent items when resolving lists When a task/story is deleted, the WorklistItem for that task/story is not deleted. Currently, this raises an exception when resolving the items of the worklists containing that task/story. This patch fixes that by skipping WorklistItems whose items no longer exist. In the long run, we should just not delete tasks/stories and archive them instead. Change-Id: I238bc4b86b5358fd11080be6ebfd9b76b09753f4 --- storyboard/api/v1/wmodels.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storyboard/api/v1/wmodels.py b/storyboard/api/v1/wmodels.py index 5a9e8c94..77858072 100644 --- a/storyboard/api/v1/wmodels.py +++ b/storyboard/api/v1/wmodels.py @@ -541,9 +541,13 @@ class Worklist(base.APIBase): item_model = WorklistItem.from_db_model(item) if item.item_type == 'story': story = stories_api.story_get(item.item_id) + if story is None: + continue item_model.story = Story.from_db_model(story) elif item.item_type == 'task': task = tasks_api.task_get(item.item_id) + if task is None or task.story is None: + continue item_model.task = Task.from_db_model(task) self.items.append(item_model) self.items.sort(key=lambda x: x.list_position)