Merge "Add API call to return task statuses"
This commit is contained in:
commit
a6114baf8b
storyboard
38
storyboard/api/v1/task_statuses.py
Normal file
38
storyboard/api/v1/task_statuses.py
Normal file
@ -0,0 +1,38 @@
|
||||
# Copyright (c) 2013 Mirantis Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from pecan import rest
|
||||
from pecan.secure import secure
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from storyboard.api.auth import authorization_checks as checks
|
||||
from storyboard.api.v1.wmodels import TaskStatus
|
||||
from storyboard.db.api import tasks as tasks_api
|
||||
|
||||
|
||||
class TaskStatusesController(rest.RestController):
|
||||
"""Manages tasks statuses."""
|
||||
|
||||
@secure(checks.guest)
|
||||
@wsme_pecan.wsexpose([TaskStatus])
|
||||
def get(self):
|
||||
"""Retrieve the possible task statuses
|
||||
"""
|
||||
statuses = tasks_api.task_get_statuses()
|
||||
task_statuses = []
|
||||
for key, val in statuses.items():
|
||||
ts = TaskStatus(key=key, name=val)
|
||||
task_statuses.append(ts)
|
||||
return task_statuses
|
@ -20,6 +20,7 @@ from storyboard.api.v1.stories import StoriesController
|
||||
from storyboard.api.v1.subscription_events import SubscriptionEventsController
|
||||
from storyboard.api.v1.subscriptions import SubscriptionsController
|
||||
from storyboard.api.v1.system_info import SystemInfoController
|
||||
from storyboard.api.v1.task_statuses import TaskStatusesController
|
||||
from storyboard.api.v1.tasks import TasksController
|
||||
from storyboard.api.v1.teams import TeamsController
|
||||
from storyboard.api.v1.users import UsersController
|
||||
@ -33,6 +34,7 @@ class V1Controller(object):
|
||||
teams = TeamsController()
|
||||
stories = StoriesController()
|
||||
tasks = TasksController()
|
||||
task_statuses = TaskStatusesController()
|
||||
subscriptions = SubscriptionsController()
|
||||
subscription_events = SubscriptionEventsController()
|
||||
systeminfo = SystemInfoController()
|
||||
|
@ -329,3 +329,8 @@ class AccessToken(base.APIBase):
|
||||
user_id=1,
|
||||
access_token="a_unique_access_token",
|
||||
expires_in=3600)
|
||||
|
||||
|
||||
class TaskStatus(base.APIBase):
|
||||
key = wtypes.text
|
||||
name = wtypes.text
|
||||
|
@ -88,3 +88,7 @@ def task_build_query(project_group_id, **kwargs):
|
||||
**kwargs)
|
||||
|
||||
return query
|
||||
|
||||
|
||||
def task_get_statuses():
|
||||
return models.Task.TASK_STATUSES
|
||||
|
@ -262,12 +262,17 @@ class Story(FullText, ModelBuilder, Base):
|
||||
class Task(FullText, ModelBuilder, Base):
|
||||
__fulltext_columns__ = ['title']
|
||||
|
||||
_TASK_STATUSES = ('todo', 'inprogress', 'invalid', 'review', 'merged')
|
||||
TASK_STATUSES = {'todo': 'Todo',
|
||||
'merged': 'Merged',
|
||||
'invalid': 'Invalid',
|
||||
'review': 'Review',
|
||||
'inprogress': 'Progress'}
|
||||
|
||||
_TASK_PRIORITIES = ('low', 'medium', 'high')
|
||||
|
||||
creator_id = Column(Integer, ForeignKey('users.id'))
|
||||
title = Column(Unicode(100), nullable=True)
|
||||
status = Column(Enum(*_TASK_STATUSES), default='todo')
|
||||
status = Column(Enum(*TASK_STATUSES.keys()), default='todo')
|
||||
story_id = Column(Integer, ForeignKey('stories.id'))
|
||||
project_id = Column(Integer, ForeignKey('projects.id'))
|
||||
assignee_id = Column(Integer, ForeignKey('users.id'), nullable=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user