feat: deal attributes with select and options

This commit is contained in:
2025-10-29 19:37:27 +04:00
parent 0e8c9077c9
commit 82fcd6e8cb
14 changed files with 206 additions and 23 deletions

View File

@ -8,8 +8,7 @@ from models.base import BaseModel
from models.mixins import IdMixin, SoftDeleteMixin
if TYPE_CHECKING:
from models import Module, Deal
from models import Module, Deal, AttributeSelect
module_attribute = Table(
"module_attribute",
@ -51,6 +50,12 @@ class Attribute(BaseModel, IdMixin, SoftDeleteMixin):
lazy="joined",
)
select_id: Mapped[Optional[int]] = mapped_column(ForeignKey("attribute_selects.id"))
select: Mapped[Optional["AttributeSelect"]] = relationship(
back_populates="attributes",
lazy="joined",
)
modules: Mapped[list["Module"]] = relationship(
secondary=module_attribute,
back_populates="attributes",