From 81e7f115bbce4a62f5759731a28418c4601bced0 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Mon, 4 Mar 2019 17:03:13 +0000 Subject: [PATCH] Add a 'security' flag to Teams This will be used to determine whether or not a Team is responsible for (and therefore should be automatically subscribed to) security issues. Change-Id: I0869e9acc366f3a5546b4e39d736a229762999c2 --- storyboard/api/v1/wmodels.py | 6 +++- .../064_add_a_security_flag_to_teams.py | 36 +++++++++++++++++++ storyboard/db/models.py | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 storyboard/db/migration/alembic_migrations/versions/064_add_a_security_flag_to_teams.py diff --git a/storyboard/api/v1/wmodels.py b/storyboard/api/v1/wmodels.py index 171a585a..daf20892 100644 --- a/storyboard/api/v1/wmodels.py +++ b/storyboard/api/v1/wmodels.py @@ -197,11 +197,15 @@ class Team(base.APIBase): description = wtypes.text """Details about the team.""" + security = bool + """Whether or not the team is responsible for managing security issues.""" + @classmethod def sample(cls): return cls( name="StoryBoard-core", - description="Core reviewers of StoryBoard team.") + description="Core reviewers of StoryBoard team.", + security=False) class Story(base.APIBase): diff --git a/storyboard/db/migration/alembic_migrations/versions/064_add_a_security_flag_to_teams.py b/storyboard/db/migration/alembic_migrations/versions/064_add_a_security_flag_to_teams.py new file mode 100644 index 00000000..53b35228 --- /dev/null +++ b/storyboard/db/migration/alembic_migrations/versions/064_add_a_security_flag_to_teams.py @@ -0,0 +1,36 @@ +# 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. +# + +"""Add a 'security' flag to Teams + +Revision ID: 064 +Revises: 063 +Create Date: 2019-03-04 16:24:44.264120 + +""" + +# revision identifiers, used by Alembic. +revision = '064' +down_revision = '063' + + +from alembic import op +import sqlalchemy as sa + + +def upgrade(active_plugins=None, options=None): + op.add_column('teams', sa.Column('security', sa.Boolean(), nullable=True)) + + +def downgrade(active_plugins=None, options=None): + op.drop_column('teams', 'security') diff --git a/storyboard/db/models.py b/storyboard/db/models.py index 0432fffd..c7d60d82 100644 --- a/storyboard/db/models.py +++ b/storyboard/db/models.py @@ -211,6 +211,7 @@ class Team(ModelBuilder, Base): schema.UniqueConstraint('name', name='uniq_team_name'), ) name = Column(Unicode(CommonLength.top_middle_length)) + security = Column(Boolean, default=False) users = relationship("User", secondary="team_membership") permissions = relationship("Permission", secondary="team_permissions", backref="teams")