51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
import uuid
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import Boolean, Unicode, Uuid
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from ..db.base_class import reg
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
from .product import Product
|
|
|
|
|
|
@reg.mapped_as_dataclass(unsafe_hash=True)
|
|
class ProductGroup:
|
|
__tablename__ = "product_groups"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, insert_default=uuid.uuid4)
|
|
name: Mapped[str] = mapped_column(Unicode, unique=True, nullable=False)
|
|
nutritional: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
|
ice_cream: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
|
is_fixture: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
|
is_fixture: Mapped[bool] = mapped_column(Boolean, nullable=False)
|
|
|
|
products: Mapped[list["Product"]] = relationship("Product", back_populates="product_group")
|
|
|
|
def __init__(
|
|
self,
|
|
name: str,
|
|
nutritional: bool = False,
|
|
ice_cream: bool = False,
|
|
id_: uuid.UUID | None = None,
|
|
is_fixture: bool | None = False,
|
|
) -> None:
|
|
self.name = name
|
|
self.nutritional = nutritional
|
|
self.ice_cream = ice_cream
|
|
if id_ is not None:
|
|
self.id = id_
|
|
if is_fixture is not None:
|
|
self.is_fixture = is_fixture
|
|
|
|
@classmethod
|
|
def menu_item(cls) -> uuid.UUID:
|
|
return uuid.UUID("dad46805-f577-4e5b-8073-9b788e0173fc")
|
|
|
|
@classmethod
|
|
def semi(cls) -> uuid.UUID:
|
|
return uuid.UUID("e6bf81b9-1e9b-499f-81d5-ab5662e9d9b1")
|