
- Create base model with timestamp mixin - Add user model with roles - Add restaurant model - Add menu item model with categories - Add order and order item models - Add delivery model - Fix import issues and linting errors
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
from sqlalchemy import Boolean, Column, Float, ForeignKey, Integer, String
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.models.base import BaseModel, TimestampMixin
|
|
|
|
|
|
class Restaurant(BaseModel, TimestampMixin):
|
|
"""Restaurant model."""
|
|
|
|
name = Column(String, nullable=False)
|
|
description = Column(String, nullable=True)
|
|
address = Column(String, nullable=False)
|
|
phone = Column(String, nullable=False)
|
|
email = Column(String, nullable=True)
|
|
logo_url = Column(String, nullable=True)
|
|
is_active = Column(Boolean, default=True, nullable=False)
|
|
latitude = Column(Float, nullable=True)
|
|
longitude = Column(Float, nullable=True)
|
|
opening_time = Column(String, nullable=True) # Format: HH:MM
|
|
closing_time = Column(String, nullable=True) # Format: HH:MM
|
|
owner_id = Column(Integer, ForeignKey("user.id"), nullable=False)
|
|
|
|
# Relationships
|
|
owner = relationship("User", backref="owned_restaurants")
|
|
menu_items = relationship("MenuItem", back_populates="restaurant", cascade="all, delete-orphan")
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<Restaurant {self.name}>" |