From 7cba7ced39a72faacfd067ba3992d96c83c1fb1d Mon Sep 17 00:00:00 2001 From: FatemaKhalid Date: Sun, 8 Apr 2018 17:24:45 +0200 Subject: [PATCH] Validating task status in the API Adding enum for task statuses validation in API Story: 2001432 Task: 22469 Change-Id: I39e9227b7dcc39be1fbea131918a3874b1631017 --- storyboard/api/v1/wmodels.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/storyboard/api/v1/wmodels.py b/storyboard/api/v1/wmodels.py index a588164d..1e43ac8e 100644 --- a/storyboard/api/v1/wmodels.py +++ b/storyboard/api/v1/wmodels.py @@ -136,10 +136,13 @@ class ProjectGroup(base.APIBase): name="Infra", title="Awesome projects") +TaskStatuses = wtypes.Enum(wtypes.text, 'todo', 'inprogress', + 'invalid', 'review', 'merged') + class TaskStatusCount(base.APIBase): """Represents a task status and number of occurrences within a story.""" - key = wtypes.text + key = wtypes.wsattr(TaskStatuses) count = int @classmethod @@ -300,11 +303,9 @@ class Task(base.APIBase): title = wtypes.text """An optional short label for the task, to show in listings.""" - # TODO(ruhe): replace with enum - status = wtypes.text - """Status. - Allowed values: ['todo', 'inprogress', 'invalid', 'review', 'merged']. - Human readable versions are left to the UI. + status = wtypes.wsattr(TaskStatuses) + """The type of statuses allowed ['todo', 'inprogress', + 'invalid', 'review', 'merged']. """ creator_id = int