This commit is contained in:
2024-05-09 01:32:37 +03:00
parent 3e83cf6f92
commit 61d27d2389
16 changed files with 179 additions and 115 deletions

View File

@@ -1,7 +1,7 @@
from sqlalchemy import Integer, Column, String, Boolean
from sqlalchemy import Integer, Column, String, Boolean, ForeignKey
from sqlalchemy.orm import relationship
from models import BaseModel
from models import BaseModel, barcode_template_attribute_link
class BarcodeTemplateAttribute(BaseModel):
@@ -11,14 +11,31 @@ class BarcodeTemplateAttribute(BaseModel):
name = Column(String, nullable=False, index=True, comment='Метка атрибута')
class BarcodeTemplateAdditionalField(BaseModel):
__tablename__ = 'barcode_template_additional_fields'
id = Column(Integer, autoincrement=True, primary_key=True, index=True)
name = Column(String, nullable=False)
value = Column(String, nullable=False)
barcode_template_id = Column(Integer, ForeignKey('barcode_templates.id'), nullable=False)
barcode_template = relationship('BarcodeTemplate', back_populates='additional_fields')
class BarcodeTemplate(BaseModel):
__tablename__ = 'barcode_templates'
id = Column(Integer, autoincrement=True, primary_key=True, index=True)
name = Column(String, nullable=False, index=True, comment='Название шаблона')
attributes = relationship('BarcodeTemplateAttributeLink',
back_populates='barcode_template',
cascade="all, delete-orphan",
lazy='joined')
attributes = relationship('BarcodeTemplateAttribute',
secondary=barcode_template_attribute_link,
# back_populates='barcode_template',
# cascade="all, delete-orphan",
lazy='selectin'
)
additional_fields = relationship('BarcodeTemplateAdditionalField',
back_populates='barcode_template',
lazy='selectin'
)
is_default = Column(Boolean, nullable=False, default=False, comment='По умолчанию')
# size