From 074f4048c3e6b1bb3d514aa9edbb591ef5c47072 Mon Sep 17 00:00:00 2001 From: Rutvij Mehta Date: Thu, 16 Mar 2023 18:32:46 -0700 Subject: [PATCH] Allows tags to have external IDs (#3028) (#13) * Allows tags to have external IDs * Adds external id UI Co-authored-by: kevgliss --- .../versions/2023-02-27_20d3801ad5b7.py | 26 +++++++++++++++++++ .../static/dispatch/src/tag/NewEditSheet.vue | 14 ++++++++++ .../static/dispatch/src/tag/Table.vue | 1 + src/dispatch/static/dispatch/src/tag/store.js | 1 + src/dispatch/tag/models.py | 2 ++ 5 files changed, 44 insertions(+) create mode 100644 src/dispatch/database/revisions/tenant/versions/2023-02-27_20d3801ad5b7.py diff --git a/src/dispatch/database/revisions/tenant/versions/2023-02-27_20d3801ad5b7.py b/src/dispatch/database/revisions/tenant/versions/2023-02-27_20d3801ad5b7.py new file mode 100644 index 000000000000..3d58de331f0d --- /dev/null +++ b/src/dispatch/database/revisions/tenant/versions/2023-02-27_20d3801ad5b7.py @@ -0,0 +1,26 @@ +"""Adds external id for tags + +Revision ID: 20d3801ad5b7 +Revises: 93b517de08e2 +Create Date: 2023-02-27 15:38:07.029395 + +""" +from alembic import op +import sqlalchemy as sa + +# revision identifiers, used by Alembic. +revision = "20d3801ad5b7" +down_revision = "93b517de08e2" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column("tag", sa.Column("external_id", sa.String(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("tag", "external_id") diff --git a/src/dispatch/static/dispatch/src/tag/NewEditSheet.vue b/src/dispatch/static/dispatch/src/tag/NewEditSheet.vue index d922d72a81b3..d988340a475e 100644 --- a/src/dispatch/static/dispatch/src/tag/NewEditSheet.vue +++ b/src/dispatch/static/dispatch/src/tag/NewEditSheet.vue @@ -88,6 +88,19 @@ /> + + + + + { uri: null, id: null, description: "Generic tag", + external_id: null, project: null, created_at: null, discoverable: null, diff --git a/src/dispatch/tag/models.py b/src/dispatch/tag/models.py index 2ee97dad2453..d5ca2be69ab3 100644 --- a/src/dispatch/tag/models.py +++ b/src/dispatch/tag/models.py @@ -21,6 +21,7 @@ class Tag(Base, TimeStampMixin, ProjectMixin): description = Column(String) uri = Column(String) source = Column(String) + external_id = Column(String) discoverable = Column(Boolean, default=True) # Relationships @@ -37,6 +38,7 @@ class TagBase(DispatchBase): source: Optional[str] = Field(None, nullable=True) uri: Optional[str] = Field(None, nullable=True) discoverable: Optional[bool] = True + external_id: Optional[str] = Field(None, nullable=True) description: Optional[str] = Field(None, nullable=True)