2025-08-29 18:19:46 +02:00
|
|
|
from sqlalchemy import String, Text, ForeignKey
|
|
|
|
|
from sqlalchemy.orm import Mapped, mapped_column, declared_attr
|
|
|
|
|
|
|
|
|
|
from .base import Base, bidirectional_relationship
|
|
|
|
|
# noinspection PyProtectedMember
|
|
|
|
|
from .status import StatusForeignKey
|
|
|
|
|
from .user import Versioned
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = ["Contact"]
|
|
|
|
|
|
|
|
|
|
class Contact(StatusForeignKey, Versioned, Base):
|
|
|
|
|
"""Contact"""
|
|
|
|
|
|
2025-08-31 07:53:17 +02:00
|
|
|
code: Mapped[str] = mapped_column(String(80), unique=True)
|
2025-08-29 18:19:46 +02:00
|
|
|
address: Mapped[str | None] = mapped_column(String(253))
|
|
|
|
|
notes: Mapped[str | None] = mapped_column(Text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContactForeignKey:
|
|
|
|
|
"""Foreign Key Mixin for :py:class:`Contact`"""
|
|
|
|
|
|
|
|
|
|
contact_id: Mapped[int | None] = mapped_column(ForeignKey("contact.id"))
|
|
|
|
|
|
|
|
|
|
@declared_attr
|
|
|
|
|
def contact(cls) -> Mapped["Contact"]:
|
|
|
|
|
return bidirectional_relationship(cls, Contact)
|