From 2605d938e51d483ee2f0a045549c4de932ba942b Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 23 Jun 2022 15:51:01 +0200 Subject: [PATCH] add placeholder model --- ereuse_devicehub/resources/device/models.py | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index c42d9bec..fd171bb9 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -790,6 +790,43 @@ class DisplayMixin: return v +class Placeholder(Thing): + id = Column(BigInteger, Sequence('placeholder_seq'), primary_key=True) + phid = Column(Unicode(), check_lower('phid'), unique=False) + pallet = Column(BigInteger, nullable=True) + pallet.comment = "used for identification where from where is this placeholders" + info = db.Column(CIText()) + info.comment = "more info of placeholders" + id_device_supplier = db.Column(CIText()) + id_device_supplier.comment = ( + "Identification used for one supplier of one placeholders" + ) + + placeholder_id = db.Column( + BigInteger, + db.ForeignKey(Device.id), + nullable=False, + ) + placeholder = db.relationship( + Device, + backref=backref('placeholder', lazy=True), + primaryjoin=placeholder_id == Device.id, + ) + placeholder_id.comment = "datas of the placeholder" + + device_id = db.Column( + BigInteger, + db.ForeignKey(Device.id), + nullable=True, + ) + device = db.relationship( + Device, + backref=backref('binding', lazy=True), + primaryjoin=placeholder_id == Device.id, + ) + device_id.comment = "device with snapshots than is linked to the placeholder" + + class Computer(Device): """A chassis with components inside that can be processed automatically with Workbench Computer.