38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
import uuid
|
|
|
|
from barker.models.meta import Base
|
|
from sqlalchemy import Column, ForeignKey, Integer, UniqueConstraint, text
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import relationship
|
|
|
|
|
|
class SectionPrinter(Base):
|
|
__tablename__ = "section_printers"
|
|
__table_args__ = (UniqueConstraint("sale_category_id", "section_id"),)
|
|
|
|
id = Column(
|
|
"id", UUID(as_uuid=True), primary_key=True, server_default=text("gen_random_uuid()"), default=uuid.uuid4
|
|
)
|
|
sale_category_id = Column("sale_category_id", UUID(as_uuid=True), ForeignKey("sale_categories.id"))
|
|
section_id = Column("section_id", UUID(as_uuid=True), ForeignKey("sections.id"), nullable=False)
|
|
printer_id = Column("printer_id", UUID(as_uuid=True), ForeignKey("printers.id"), nullable=False)
|
|
copies = Column("copies", Integer, nullable=False)
|
|
|
|
sale_category = relationship("SaleCategory", backref="section_printers")
|
|
section = relationship("Section", backref="section_printers")
|
|
printer = relationship("Printer", backref="section_printers")
|
|
|
|
def __init__(
|
|
self,
|
|
sale_category_id=None,
|
|
section_id=None,
|
|
printer_id=None,
|
|
copies=None,
|
|
id_=None,
|
|
):
|
|
self.id = id_
|
|
self.sale_category_id = sale_category_id
|
|
self.section_id = section_id
|
|
self.printer_id = printer_id
|
|
self.copies = copies
|