Support subscription to worklists in the API

This doesn't yet cause notifications to be recieved for changes to
worklists. That can be a change for a later patch, and should be
configurable.

Change-Id: I14b0b4ddd6138ac23f9e1c10d0de2419f8e8cb4b
This commit is contained in:
Adam Coldrick 2016-06-02 13:11:19 +00:00
parent cb775ab95d
commit 8036187ea8
3 changed files with 50 additions and 2 deletions

View File

@ -26,7 +26,8 @@ SUPPORTED_TYPES = {
'project': models.Project,
'project_group': models.ProjectGroup,
'story': models.Story,
'task': models.Task
'task': models.Task,
'worklist': models.Worklist
}

View File

@ -0,0 +1,46 @@
# 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.
#
"""Allow subscription to worklists
Revision ID: 058
Revises: 057
Create Date: 2016-06-01 13:28:19.033906
"""
# revision identifiers, used by Alembic.
revision = '058'
down_revision = '057'
from alembic import op
import sqlalchemy as sa
old_type_enum = sa.Enum('task', 'story', 'project', 'project_group')
new_type_enum = sa.Enum(
'task', 'story', 'project', 'project_group', 'worklist')
def upgrade(active_plugins=None, options=None):
op.alter_column('subscriptions',
'target_type',
existing_type=old_type_enum,
type_=new_type_enum)
def downgrade(active_plugins=None, options=None):
op.alter_column('subscriptions',
'target_type',
existing_type=new_type_enum,
type_=old_type_enum)

View File

@ -511,7 +511,8 @@ class Comment(FullText, ModelBuilder, Base):
# Subscription and notifications
class Subscription(ModelBuilder, Base):
_SUBSCRIPTION_TARGETS = ('task', 'story', 'project', 'project_group')
_SUBSCRIPTION_TARGETS = ('task', 'story', 'project', 'project_group',
'worklist')
user_id = Column(Integer, ForeignKey('users.id'))
target_type = Column(Enum(*_SUBSCRIPTION_TARGETS))