Minor tweaks to sign up on frontend and database structure

This commit is contained in:
Thastertyn committed 2025-03-17 19:27:09 +01:00
1 parent d0690f2f06
commit 260bef98cd
10 files changed
+56 -1037

No files matched your search

+18 -18
View File
@@ -21,7 +21,7 @@ class ShopLinkEntry(BaseModel):
class ShopLinks(BaseModel):
links: list[ShopLinkEntry]
links: list[ShopLinkEntry] = []
class ShopBusinessHourEntry(BaseModel):
@@ -31,15 +31,15 @@ class ShopBusinessHourEntry(BaseModel):
class ShopBusinessHours(BaseModel):
hours: list[ShopBusinessHourEntry]
hours: list[ShopBusinessHourEntry] = []
class ShopAddress(SQLModel):
street: str = Field(max_length=255, nullable=False)
city: str = Field(max_length=100, nullable=False)
state: str = Field(max_length=100, nullable=True)
postal_code: str = Field(max_length=20, nullable=False)
country: str = Field(max_length=100, nullable=False)
street: str = Field(default="", max_length=255, nullable=False)
city: str = Field(default="", max_length=100, nullable=False)
state: Optional[str] = Field(default=None, max_length=100, nullable=True)
postal_code: str = Field(default="", max_length=20, nullable=False)
country: str = Field(default="", max_length=100, nullable=False)
class Shop(SQLModel, table=True):
@@ -55,13 +55,19 @@ class Shop(SQLModel, table=True):
status: ShopStatus = Field(sa_column=Column(Enum(ShopStatus)))
logo: Optional[str] = Field(max_length=100)
contact_email: str = Field(max_length=128, nullable=False, unique=True)
phone_number: str = Field(max_length=15, nullable=False)
address: ShopAddress = Field(sa_column=Column(JSONB, nullable=False, default=lambda: {}))
business_hours: ShopBusinessHours = Field(sa_column=Column(JSONB, nullable=False, default=lambda: {}))
links: ShopLinks = Field(sa_column=Column(JSONB, nullable=False, default=lambda: {}))
contact_phone_number: str = Field(max_length=15, nullable=False)
address: ShopAddress = Field(
sa_column=Column(JSONB, nullable=False, default=lambda: ShopAddress().dict())
)
business_hours: ShopBusinessHours = Field(
sa_column=Column(JSONB, nullable=False, default=lambda: ShopBusinessHours().dict())
)
links: ShopLinks = Field(
sa_column=Column(JSONB, nullable=False, default=lambda: ShopLinks().dict())
)
currency: str = Field(max_length=3, nullable=False)
owner: Optional["User"] = Relationship(
owner: "User" = Relationship(
back_populates='owned_shop',
sa_relationship_kwargs={"foreign_keys": "[Shop.owner_id]"}
)
@@ -71,11 +77,5 @@ class Shop(SQLModel, table=True):
sa_relationship_kwargs={"foreign_keys": "[User.shop_id]"}
)
# __table_args__ = (
# CheckConstraint("business_hours ? 'hours'", name="check_business_hours_keys"),
# CheckConstraint("links ? 'links'", name="check_links_keys"),
# CheckConstraint("address ? 'address'", name="check_address_keys")
# )
__all__ = ["Shop", "ShopBusinessHours", "ShopLinks", "ShopStatus"]
+1 -1
View File
@@ -31,7 +31,7 @@ class User(SQLModel, table=True):
password: str = Field(max_length=60, nullable=False)
first_name: Optional[str] = Field(max_length=64)
last_name: Optional[str] = Field(max_length=64)
phone_number: str = Field(max_length=15, nullable=False)
phone_number: str = Field(max_length=16, nullable=False)
profile_picture: Optional[str] = Field(max_length=100)
created_at: datetime = Field(default_factory=datetime.utcnow, nullable=False)
updated_at: datetime = Field(default_factory=datetime.utcnow, nullable=False)