diff --git a/strr-api/migrations/versions/20250128_2128_73f39f000110_add_category_column_to_stratahotel_model.py b/strr-api/migrations/versions/20250128_2128_73f39f000110_add_category_column_to_stratahotel_model.py new file mode 100644 index 00000000..ea412153 --- /dev/null +++ b/strr-api/migrations/versions/20250128_2128_73f39f000110_add_category_column_to_stratahotel_model.py @@ -0,0 +1,47 @@ +"""Add category column to StrataHotel model + +Revision ID: 73f39f000110 +Revises: 5ac8342c6534 +Create Date: 2025-01-28 21:28:15.026837 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '73f39f000110' +down_revision = '5ac8342c6534' +branch_labels = None +depends_on = None + +def upgrade(): + stratahotelcategory = postgresql.ENUM('FULL_SERVICE', 'MULTI_UNIT_NON_PR', 'POST_DECEMBER_2023', name='stratahotelcategory') + stratahotelcategory.create(op.get_bind(), checkfirst=True) + + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('strata_hotels', schema=None) as batch_op: + batch_op.add_column(sa.Column('category', sa.Enum('FULL_SERVICE', 'MULTI_UNIT_NON_PR', 'POST_DECEMBER_2023', name='stratahotelcategory'), nullable=True)) + batch_op.create_index(batch_op.f('ix_strata_hotels_category'), ['category'], unique=False) + + with op.batch_alter_table('strata_hotels_history', schema=None) as batch_op: + batch_op.add_column(sa.Column('category', sa.Enum('FULL_SERVICE', 'MULTI_UNIT_NON_PR', 'POST_DECEMBER_2023', name='stratahotelcategory'), autoincrement=False, nullable=True)) + batch_op.create_index(batch_op.f('ix_strata_hotels_history_category'), ['category'], unique=False) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('strata_hotels_history', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_strata_hotels_history_category')) + batch_op.drop_column('category') + + with op.batch_alter_table('strata_hotels', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_strata_hotels_category')) + batch_op.drop_column('category') + + stratahotelcategory = postgresql.ENUM(name='stratahotelcategory') + stratahotelcategory.drop(op.get_bind(), checkfirst=True) + + # ### end Alembic commands ### diff --git a/strr-api/pyproject.toml b/strr-api/pyproject.toml index 488cc9dc..8bc8d53a 100644 --- a/strr-api/pyproject.toml +++ b/strr-api/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "strr-api" -version = "0.0.40" +version = "0.0.41" description = "" authors = ["thorwolpert "] license = "BSD 3-Clause" diff --git a/strr-api/src/strr_api/models/strata_hotels.py b/strr-api/src/strr_api/models/strata_hotels.py index 172d6433..1193b714 100644 --- a/strr-api/src/strr_api/models/strata_hotels.py +++ b/strr-api/src/strr_api/models/strata_hotels.py @@ -4,8 +4,10 @@ from __future__ import annotations from sql_versioning import Versioned +from sqlalchemy import Enum from sqlalchemy.orm import relationship +from strr_api.common.enum import BaseEnum, auto from strr_api.models.base_model import BaseModel from .db import db @@ -14,6 +16,13 @@ class StrataHotel(Versioned, BaseModel): """Strata Hotel""" + class StrataHotelCategory(BaseEnum): + """Enum of the strata hotel category.""" + + FULL_SERVICE = auto() # pylint: disable=invalid-name + MULTI_UNIT_NON_PR = auto() # pylint: disable=invalid-name + POST_DECEMBER_2023 = auto() # pylint: disable=invalid-name + __tablename__ = "strata_hotels" id = db.Column(db.Integer, primary_key=True, autoincrement=True) @@ -24,6 +33,7 @@ class StrataHotel(Versioned, BaseModel): brand_name = db.Column("brand_name", db.String(250), nullable=False) website = db.Column("website", db.String(1000), nullable=False) number_of_units = db.Column("number_of_units", db.Integer, nullable=False) + category = db.Column(Enum(StrataHotelCategory), nullable=True, index=True) mailing_address_id = db.Column(db.Integer, db.ForeignKey("addresses.id"), nullable=False) location_id = db.Column(db.Integer, db.ForeignKey("addresses.id"), nullable=False) diff --git a/strr-api/src/strr_api/schemas/schemas/strata-hotel-registration.json b/strr-api/src/strr_api/schemas/schemas/strata-hotel-registration.json index 6d76eee8..fa362dbc 100644 --- a/strr-api/src/strr_api/schemas/schemas/strata-hotel-registration.json +++ b/strr-api/src/strr_api/schemas/schemas/strata-hotel-registration.json @@ -118,12 +118,21 @@ "items": { "$ref": "https://strr.gov.bc.ca/.well_known/schemas/address" } + }, + "category": { + "type": "string", + "enum": [ + "FULL_SERVICE", + "MULTI_UNIT_NON_PR", + "POST_DECEMBER_2023" + ] } }, "required": [ "brand", "location", - "numberOfUnits" + "numberOfUnits", + "category" ] } }, diff --git a/strr-api/tests/mocks/json/strata_hotel_registration.json b/strr-api/tests/mocks/json/strata_hotel_registration.json index a758d210..9d68b1b4 100644 --- a/strr-api/tests/mocks/json/strata_hotel_registration.json +++ b/strr-api/tests/mocks/json/strata_hotel_registration.json @@ -75,6 +75,7 @@ "locationDescription": "Test Location" }, "numberOfUnits": 50, + "category": "MULTI_UNIT_NON_PR", "buildings": [ { "country": "CA", diff --git a/strr-api/tests/postman/strr-api.postman_collection.json b/strr-api/tests/postman/strr-api.postman_collection.json index 008e3c97..593a205f 100644 --- a/strr-api/tests/postman/strr-api.postman_collection.json +++ b/strr-api/tests/postman/strr-api.postman_collection.json @@ -170,7 +170,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"registration\": {\n \"registrationType\": \"STRATA_HOTEL\",\n \"completingParty\": {\n \"firstName\": \"Test\",\n \"middleName\": \"\",\n \"lastName\": \"Test\",\n \"phoneNumber\": \"604-999-9999\",\n \"phoneCountryCode\": \"001\",\n \"extension\": \"x64\",\n \"faxNumber\": \"604-777-7777\",\n \"emailAddress\": \"test@test.test\",\n \"jobTitle\": \"Sales Manager\"\n },\n \"strataHotelRepresentatives\": [\n {\n \"firstName\": \"Test\",\n \"lastName\": \"Test\",\n \"phoneNumber\": \"123-456-8970\",\n \"phoneCountryCode\": \"001\",\n \"extension\": \"x64\",\n \"faxNumber\": \"604-777-7777\",\n \"emailAddress\": \"test@test.test\",\n \"jobTitle\": \"Sales Manager\"\n },\n {\n \"firstName\": \"Test\",\n \"lastName\": \"Test\",\n \"phoneNumber\": \"604-999-9999\",\n \"phoneCountryCode\": \"001\",\n \"extension\": \"x64\",\n \"faxNumber\": \"604-777-7777\",\n \"emailAddress\": \"test@test.test\",\n \"jobTitle\": \"Sales Manager\"\n }\n ],\n \"businessDetails\": {\n \"legalName\": \"Test Business\",\n \"homeJurisdiction\": \"Vancouver\",\n \"businessNumber\": \"BN12345\",\n \"mailingAddress\": {\n \"country\": \"CA\",\n \"address\": \"12766 227st\",\n \"addressLineTwo\": \"\",\n \"city\": \"MAPLE RIDGE\",\n \"province\": \"BC\",\n \"postalCode\": \"V2X 6K6\",\n \"locationDescription\": \"Test Location\"\n },\n \"registeredOfficeOrAttorneyForServiceDetails\": {\n \"attorneyName\": \"Test\",\n \"mailingAddress\": {\n \"country\": \"CA\",\n \"address\": \"12766 227st\",\n \"addressLineTwo\": \"\",\n \"city\": \"MAPLE RIDGE\",\n \"province\": \"BC\",\n \"postalCode\": \"V2X 6K6\",\n \"locationDescription\": \"Test Location\"\n }\n }\n },\n \"strataHotelDetails\": {\n \"brand\": {\n \"name\": \"Brand A\",\n \"website\": \"http://abc.com\"\n },\n \"location\": {\n \"country\": \"CA\",\n \"address\": \"12766 227st\",\n \"addressLineTwo\": \"\",\n \"city\": \"MAPLE RIDGE\",\n \"province\": \"BC\",\n \"postalCode\": \"V2X 6K6\",\n \"locationDescription\": \"Test Location\"\n },\n \"numberOfUnits\": 50,\n \"buildings\": [\n {\n \"country\": \"CA\",\n \"address\": \"12766 227st\",\n \"addressLineTwo\": \"\",\n \"city\": \"MAPLE RIDGE\",\n \"province\": \"BC\",\n \"postalCode\": \"V2X 6K6\",\n \"locationDescription\": \"Test Location\"\n },\n {\n \"country\": \"CA\",\n \"address\": \"12766 228st\",\n \"addressLineTwo\": \"\",\n \"city\": \"MAPLE RIDGE\",\n \"province\": \"BC\",\n \"postalCode\": \"V2X 6K6\",\n \"locationDescription\": \"Test Location\"\n }\n ]\n }\n }\n}\n", + "raw": "{\n \"registration\": {\n \"registrationType\": \"STRATA_HOTEL\",\n \"completingParty\": {\n \"firstName\": \"Test\",\n \"middleName\": \"\",\n \"lastName\": \"Test\",\n \"phoneNumber\": \"604-999-9999\",\n \"phoneCountryCode\": \"001\",\n \"extension\": \"x64\",\n \"faxNumber\": \"604-777-7777\",\n \"emailAddress\": \"test@test.test\",\n \"jobTitle\": \"Sales Manager\"\n },\n \"strataHotelRepresentatives\": [\n {\n \"firstName\": \"Test\",\n \"lastName\": \"Test\",\n \"phoneNumber\": \"123-456-8970\",\n \"phoneCountryCode\": \"001\",\n \"extension\": \"x64\",\n \"faxNumber\": \"604-777-7777\",\n \"emailAddress\": \"test@test.test\",\n \"jobTitle\": \"Sales Manager\"\n },\n {\n \"firstName\": \"Test\",\n \"lastName\": \"Test\",\n \"phoneNumber\": \"604-999-9999\",\n \"phoneCountryCode\": \"001\",\n \"extension\": \"x64\",\n \"faxNumber\": \"604-777-7777\",\n \"emailAddress\": \"test@test.test\",\n \"jobTitle\": \"Sales Manager\"\n }\n ],\n \"businessDetails\": {\n \"legalName\": \"Test Business\",\n \"homeJurisdiction\": \"Vancouver\",\n \"businessNumber\": \"BN12345\",\n \"mailingAddress\": {\n \"country\": \"CA\",\n \"address\": \"12766 227st\",\n \"addressLineTwo\": \"\",\n \"city\": \"MAPLE RIDGE\",\n \"province\": \"BC\",\n \"postalCode\": \"V2X 6K6\",\n \"locationDescription\": \"Test Location\"\n },\n \"registeredOfficeOrAttorneyForServiceDetails\": {\n \"attorneyName\": \"Test\",\n \"mailingAddress\": {\n \"country\": \"CA\",\n \"address\": \"12766 227st\",\n \"addressLineTwo\": \"\",\n \"city\": \"MAPLE RIDGE\",\n \"province\": \"BC\",\n \"postalCode\": \"V2X 6K6\",\n \"locationDescription\": \"Test Location\"\n }\n }\n },\n \"strataHotelDetails\": {\n \"brand\": {\n \"name\": \"Brand A\",\n \"website\": \"http://abc.com\"\n },\n \"location\": {\n \"country\": \"CA\",\n \"address\": \"12766 227st\",\n \"addressLineTwo\": \"\",\n \"city\": \"MAPLE RIDGE\",\n \"province\": \"BC\",\n \"postalCode\": \"V2X 6K6\",\n \"locationDescription\": \"Test Location\"\n },\n \"numberOfUnits\": 50,\n \"category\": \"MULTI_UNIT_NON_PR\",\n \"buildings\": [\n {\n \"country\": \"CA\",\n \"address\": \"12766 227st\",\n \"addressLineTwo\": \"\",\n \"city\": \"MAPLE RIDGE\",\n \"province\": \"BC\",\n \"postalCode\": \"V2X 6K6\",\n \"locationDescription\": \"Test Location\"\n },\n {\n \"country\": \"CA\",\n \"address\": \"12766 228st\",\n \"addressLineTwo\": \"\",\n \"city\": \"MAPLE RIDGE\",\n \"province\": \"BC\",\n \"postalCode\": \"V2X 6K6\",\n \"locationDescription\": \"Test Location\"\n }\n ]\n }\n }\n}\n", "options": { "raw": { "language": "json"