--
This commit is contained in:
@@ -7,6 +7,7 @@ from sqlalchemy import Boolean, Date, ForeignKey, Index, String, UniqueConstrain
|
||||
from sqlalchemy.dialects.postgresql import UUID as PGUUID
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.common.enums import MasterApproval
|
||||
from app.database.base import Base, TimestampMixin, UUIDMixin
|
||||
|
||||
|
||||
@@ -25,6 +26,22 @@ class Chemist(Base, UUIDMixin, TimestampMixin):
|
||||
shop_address: Mapped[str] = mapped_column(String(500), nullable=False)
|
||||
contact_number: Mapped[str | None] = mapped_column(String(20))
|
||||
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
||||
#: PENDING until the Area Manager approves one an MR added; only APPROVED ones are listed or visited.
|
||||
approval_status: Mapped[str] = mapped_column(
|
||||
String(10), default=MasterApproval.APPROVED.value, server_default=MasterApproval.APPROVED.value, nullable=False
|
||||
)
|
||||
#: The MR who asked for it (None for one the administrator created).
|
||||
requested_by_user_id: Mapped[uuid.UUID | None] = mapped_column(
|
||||
PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="SET NULL")
|
||||
)
|
||||
rejection_reason: Mapped[str | None] = mapped_column(String(500))
|
||||
requested_by: Mapped["User | None"] = relationship( # noqa: F821
|
||||
lazy="selectin", foreign_keys=[requested_by_user_id]
|
||||
)
|
||||
|
||||
@property
|
||||
def requested_by_name(self) -> str | None:
|
||||
return self.requested_by.full_name if self.requested_by else None
|
||||
|
||||
assignments: Mapped[list["ChemistAssignment"]] = relationship(back_populates="chemist")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user