Creator field added to a Task model
This filed is necessary for tracking story activities. Change-Id: I3e774650b3b851d4338d50d591dbd8f06ca82a65
This commit is contained in:
committed by
Michael Krotscheck
parent
415b5acd3f
commit
c128572feb
@@ -14,6 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
from oslo.config import cfg
|
||||
from pecan import request
|
||||
from pecan import response
|
||||
from pecan import rest
|
||||
from pecan.secure import secure
|
||||
@@ -48,6 +49,9 @@ class Task(base.APIBase):
|
||||
is_active = bool
|
||||
"""Is this an active task, or has it been deleted?"""
|
||||
|
||||
creator_id = int
|
||||
"""Id of the User who has created this Task"""
|
||||
|
||||
story_id = int
|
||||
"""The ID of the corresponding Story."""
|
||||
|
||||
@@ -117,6 +121,10 @@ class TasksController(rest.RestController):
|
||||
|
||||
:param task: a task within the request body.
|
||||
"""
|
||||
|
||||
creator_id = request.current_user_id
|
||||
task.creator_id = creator_id
|
||||
|
||||
created_task = tasks_api.task_create(task.as_dict())
|
||||
return Task.from_db_model(created_task)
|
||||
|
||||
@@ -129,7 +137,7 @@ class TasksController(rest.RestController):
|
||||
:param task: a task within the request body.
|
||||
"""
|
||||
updated_task = tasks_api.task_update(task_id,
|
||||
task.as_dict(omit_unset=True))
|
||||
task.as_dict(omit_unset=True))
|
||||
|
||||
if updated_task:
|
||||
return Task.from_db_model(updated_task)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""We need to know who has created a task.
|
||||
|
||||
Revision ID: 016
|
||||
Revises: 015
|
||||
Create Date: 2014-04-15 17:16:07.368141
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '016'
|
||||
down_revision = '015'
|
||||
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('tasks',
|
||||
sa.Column('creator_id', sa.Integer(), nullable=True))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('tasks', 'creator_id')
|
||||
### end Alembic commands ###
|
||||
@@ -106,7 +106,6 @@ class User(Base):
|
||||
last_login = Column(DateTime)
|
||||
teams = relationship("Team", secondary="team_membership")
|
||||
permissions = relationship("Permission", secondary="user_permissions")
|
||||
tasks = relationship('Task', backref='assignee')
|
||||
|
||||
_public_fields = ["id", "openid", "full_name", "username", "last_login"]
|
||||
|
||||
@@ -182,14 +181,15 @@ class Story(Base):
|
||||
class Task(Base):
|
||||
_TASK_STATUSES = ('todo', 'inprogress', 'invalid', 'review', 'merged')
|
||||
|
||||
creator_id = Column(Integer, ForeignKey('users.id'))
|
||||
title = Column(Unicode(100), nullable=True)
|
||||
status = Column(Enum(*_TASK_STATUSES), 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)
|
||||
|
||||
_public_fields = ["id", "title", "status", "story_id", "project_id",
|
||||
"assignee_id"]
|
||||
_public_fields = ["id", "creator_id", "title", "status", "story_id",
|
||||
"project_id", "assignee_id"]
|
||||
|
||||
|
||||
class Comment(Base):
|
||||
|
||||
Reference in New Issue
Block a user