Skip to content

Commit

Permalink
API: Strata-Hotel Category (bcgov#501)
Browse files Browse the repository at this point in the history
* add strata hotel category column

* remove comment

* update enum names

* add nullable=True
  • Loading branch information
deetz99 authored Jan 29, 2025
1 parent 498cf86 commit 692e5c7
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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 ###
2 changes: 1 addition & 1 deletion strr-api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "strr-api"
version = "0.0.40"
version = "0.0.41"
description = ""
authors = ["thorwolpert <thor@wolpert.ca>"]
license = "BSD 3-Clause"
Expand Down
10 changes: 10 additions & 0 deletions strr-api/src/strr_api/models/strata_hotels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
},
Expand Down
1 change: 1 addition & 0 deletions strr-api/tests/mocks/json/strata_hotel_registration.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"locationDescription": "Test Location"
},
"numberOfUnits": 50,
"category": "MULTI_UNIT_NON_PR",
"buildings": [
{
"country": "CA",
Expand Down
2 changes: 1 addition & 1 deletion strr-api/tests/postman/strr-api.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 692e5c7

Please sign in to comment.