From 0f563d58d87e7d385a0e12baa9b623e5b62c645e Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 30 May 2022 16:32:02 +0200 Subject: [PATCH] fix closed --- ereuse_devicehub/inventory/models.py | 10 ++++++++-- .../migrations/versions/054a3aea9f08_transfer.py | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/inventory/models.py b/ereuse_devicehub/inventory/models.py index a3fe9b8e..f8aafe51 100644 --- a/ereuse_devicehub/inventory/models.py +++ b/ereuse_devicehub/inventory/models.py @@ -1,7 +1,7 @@ from uuid import uuid4 from citext import CIText -from sqlalchemy import Boolean, Column +from sqlalchemy import Column from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import backref, relationship from teal.db import CASCADE_OWN @@ -19,7 +19,6 @@ class Transfer(Thing): id = Column(UUID(as_uuid=True), primary_key=True, default=uuid4) code = Column(CIText(), default='', nullable=False) - closed = Column(Boolean, nullable=False, default=False) date = Column(db.TIMESTAMP(timezone=True)) description = Column(CIText(), default='', nullable=True) lot_id = db.Column( @@ -36,3 +35,10 @@ class Transfer(Thing): user_from = db.relationship(User, primaryjoin=user_from_id == User.id) user_to_id = db.Column(UUID(as_uuid=True), db.ForeignKey(User.id), nullable=True) user_to = db.relationship(User, primaryjoin=user_to_id == User.id) + + @property + def closed(self): + if self.date: + return True + + return False diff --git a/ereuse_devicehub/migrations/versions/054a3aea9f08_transfer.py b/ereuse_devicehub/migrations/versions/054a3aea9f08_transfer.py index 3fbcba8d..5246c508 100644 --- a/ereuse_devicehub/migrations/versions/054a3aea9f08_transfer.py +++ b/ereuse_devicehub/migrations/versions/054a3aea9f08_transfer.py @@ -42,7 +42,6 @@ def upgrade(): ), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('code', citext.CIText(), nullable=False), - sa.Column('closed', sa.Boolean(), nullable=False), sa.Column( 'description', citext.CIText(),