From d0acafc568bf930808cd54bb3ee6c61051fc46a7 Mon Sep 17 00:00:00 2001 From: manukala6 Date: Thu, 31 Oct 2024 10:28:25 -0700 Subject: [PATCH] GTC-3007 Add content-date-description metadata field --- .../orm/migrations/versions/604bf4e66c2b_.py | 29 +++++++++++++++++++ app/models/orm/version_metadata.py | 1 + app/models/pydantic/metadata.py | 10 ++++++- tests/utils.py | 1 + tests_v2/fixtures/metadata/version.py | 1 + 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 app/models/orm/migrations/versions/604bf4e66c2b_.py diff --git a/app/models/orm/migrations/versions/604bf4e66c2b_.py b/app/models/orm/migrations/versions/604bf4e66c2b_.py new file mode 100644 index 000000000..8eebb37ba --- /dev/null +++ b/app/models/orm/migrations/versions/604bf4e66c2b_.py @@ -0,0 +1,29 @@ +"""Add content_date_description to version_metadata + +Revision ID: 604bf4e66c2b +Revises: ef3392e8e054 +Create Date: 2024-10-31 16:52:56.571782 + +""" +from alembic import op +import sqlalchemy as sa +import sqlalchemy_utils +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '604bf4e66c2b' +down_revision = 'ef3392e8e054' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('version_metadata', sa.Column('content_date_description', sa.String(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('version_metadata', 'content_date_description') + # ### end Alembic commands ### diff --git a/app/models/orm/version_metadata.py b/app/models/orm/version_metadata.py index f1a09042f..df39cc94e 100644 --- a/app/models/orm/version_metadata.py +++ b/app/models/orm/version_metadata.py @@ -10,6 +10,7 @@ class VersionMetadata(Base, MetadataMixin): version = db.Column(db.String, nullable=False) content_date = db.Column(db.Date) content_start_date = db.Column(db.Date) + content_date_description = db.Column(db.String) content_end_date = db.Column(db.Date) last_update = db.Column(db.Date) description = db.Column(db.String) diff --git a/app/models/pydantic/metadata.py b/app/models/pydantic/metadata.py index 01f5a7308..63e836d81 100644 --- a/app/models/pydantic/metadata.py +++ b/app/models/pydantic/metadata.py @@ -112,7 +112,10 @@ class VersionMetadata(CommonMetadata): None, description="Date range covered by the content", ) - + content_date_description: Optional[str] = Field( + None, + description="Date of content to display", + ) last_update: Optional[date] = Field( None, description="Date the data were last updated", @@ -130,6 +133,7 @@ class Config: "start_date": "2000-01-01", # TODO fix date "end_date": "2021-04-06", }, + "content_date_description": "2000 - present", } ] } @@ -159,6 +163,10 @@ class VersionMetadataUpdate(VersionMetadataIn): None, description="Date range covered by the content", ) + content_date_description: Optional[str] = Field( + None, + description="Date of content to display", + ) last_update: Optional[date] = Field( None, diff --git a/tests/utils.py b/tests/utils.py index a9a4075a0..026fbf2ec 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -31,6 +31,7 @@ version_metadata = { "content_date_range": {"start_date": "2000-01-01", "end_date": "2021-01-01"}, + "content_date_description": "2000 - present", "last_update": "2020-01-03", "spatial_resolution": 10, "resolution_description": "10 meters", diff --git a/tests_v2/fixtures/metadata/version.py b/tests_v2/fixtures/metadata/version.py index 63a81369c..07f442d2c 100644 --- a/tests_v2/fixtures/metadata/version.py +++ b/tests_v2/fixtures/metadata/version.py @@ -1,5 +1,6 @@ VERSION_METADATA = { "content_date_range": {"start_date": "2000-01-01", "end_date": "2021-01-01"}, + "content_date_description": "2000 - present", "last_update": "2020-01-03", "spatial_resolution": 10, "resolution_description": "10 meters",