From 7b1ef1b1e01f920d9f77e5e15a05320484401518 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Sat, 25 Nov 2023 15:13:21 +0100 Subject: [PATCH] Rename LocationOSMType to LocationOSMEnum --- app/crud.py | 4 ++-- app/enums.py | 2 +- app/models.py | 6 +++--- app/schemas.py | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/crud.py b/app/crud.py index 6f41d6fe..e2311700 100644 --- a/app/crud.py +++ b/app/crud.py @@ -8,7 +8,7 @@ from sqlalchemy.sql import func from app import config -from app.enums import LocationOSMType +from app.enums import LocationOSMEnum from app.models import Location, Price, Product, Proof, User from app.schemas import ( LocationBase, @@ -214,7 +214,7 @@ def get_location_by_id(db: Session, id: int): def get_location_by_osm_id_and_type( - db: Session, osm_id: int, osm_type: LocationOSMType + db: Session, osm_id: int, osm_type: LocationOSMEnum ): return ( db.query(Location) diff --git a/app/enums.py b/app/enums.py index 6384daaf..f971a05f 100644 --- a/app/enums.py +++ b/app/enums.py @@ -7,7 +7,7 @@ CurrencyEnum = Enum("CurrencyEnum", CURRENCIES) -class LocationOSMType(Enum): +class LocationOSMEnum(Enum): NODE = "NODE" WAY = "WAY" RELATION = "RELATION" diff --git a/app/models.py b/app/models.py index 0909427e..ccda8106 100644 --- a/app/models.py +++ b/app/models.py @@ -16,7 +16,7 @@ from sqlalchemy_utils.types.choice import ChoiceType from app.db import Base -from app.enums import CurrencyEnum, LocationOSMType +from app.enums import CurrencyEnum, LocationOSMEnum force_auto_coercion() @@ -54,7 +54,7 @@ class Location(Base): id = Column(Integer, primary_key=True, index=True) osm_id = Column(BigInteger) - osm_type = Column(ChoiceType(LocationOSMType)) + osm_type = Column(ChoiceType(LocationOSMEnum)) osm_name = Column(String) osm_display_name = Column(String) osm_address_postcode = Column(String) @@ -99,7 +99,7 @@ class Price(Base): currency = Column(ChoiceType(CurrencyEnum)) location_osm_id = Column(BigInteger, index=True) - location_osm_type = Column(ChoiceType(LocationOSMType)) + location_osm_type = Column(ChoiceType(LocationOSMEnum)) location_id: Mapped[int] = mapped_column(ForeignKey("locations.id"), nullable=True) location: Mapped[Location] = relationship(back_populates="prices") diff --git a/app/schemas.py b/app/schemas.py index 6402d61a..f571bbc3 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -12,7 +12,7 @@ model_validator, ) -from app.enums import CurrencyEnum, LocationOSMType +from app.enums import CurrencyEnum, LocationOSMEnum from app.models import Price @@ -63,7 +63,7 @@ class LocationCreate(BaseModel): model_config = ConfigDict(from_attributes=True, arbitrary_types_allowed=True) osm_id: int = Field(gt=0) - osm_type: LocationOSMType + osm_type: LocationOSMEnum class LocationBase(LocationCreate): @@ -135,7 +135,7 @@ class PriceCreate(BaseModel): description="ID of the location in OpenStreetMap: the store where the product was bought.", examples=[1234567890], ) - location_osm_type: LocationOSMType = Field( + location_osm_type: LocationOSMEnum = Field( description="type of the OpenStreetMap location object. Stores can be represented as nodes, " "ways or relations in OpenStreetMap. It is necessary to be able to fetch the correct " "information about the store using the ID.", @@ -192,7 +192,7 @@ class ProofBase(ProofCreate): class PriceFilter(Filter): product_code: Optional[str] | None = None location_osm_id: Optional[int] | None = None - location_osm_type: Optional[LocationOSMType] | None = None + location_osm_type: Optional[LocationOSMEnum] | None = None price: Optional[int] | None = None currency: Optional[str] | None = None price__gt: Optional[int] | None = None