Fixing nullables in models

This commit is contained in:
Cayo Puigdefabregas 2021-08-04 18:15:15 +02:00
parent 710e61fca8
commit eed117808c
3 changed files with 4 additions and 3 deletions

View File

@ -70,7 +70,7 @@ def upgrade():
# DataWipe table # DataWipe table
op.create_table('data_wipe', op.create_table('data_wipe',
sa.Column('document_id', sa.BigInteger(), nullable=True), sa.Column('document_id', sa.BigInteger(), nullable=False),
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.ForeignKeyConstraint(['document_id'], [f'{get_inv()}.document.id'], ), sa.ForeignKeyConstraint(['document_id'], [f'{get_inv()}.document.id'], ),
sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ), sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ),

View File

@ -20,7 +20,7 @@ class Document(Thing):
date = Column(db.DateTime, nullable=True) date = Column(db.DateTime, nullable=True)
date.comment = """The date of document, some documents need to have one date date.comment = """The date of document, some documents need to have one date
""" """
id_document = Column(CIText(), nullable=False) id_document = Column(CIText(), nullable=True)
id_document.comment = """The id of one document like invoice so they can be linked.""" id_document.comment = """The id of one document like invoice so they can be linked."""
owner_id = db.Column(UUID(as_uuid=True), owner_id = db.Column(UUID(as_uuid=True),
db.ForeignKey(User.id), db.ForeignKey(User.id),
@ -48,7 +48,7 @@ class JoinedTableMixin:
class DataWipeDocument(JoinedTableMixin, Document): class DataWipeDocument(JoinedTableMixin, Document):
"""This represent a generic document.""" """This represent a generic document."""
software = Column(CIText(), nullable=False) software = Column(CIText(), nullable=True)
software.comment = """Which software is used""" software.comment = """Which software is used"""
success = Column(Boolean) success = Column(Boolean)
success.comment = """If the erase was success""" success.comment = """If the erase was success"""

View File

@ -15,6 +15,7 @@ class DataWipeDocument(Thing):
required=False, required=False,
description=m.DataWipeDocument.date.comment) description=m.DataWipeDocument.date.comment)
id_document = SanitizedStr(data_key='documentId', id_document = SanitizedStr(data_key='documentId',
required=False,
default='', default='',
description=m.DataWipeDocument.id_document.comment) description=m.DataWipeDocument.id_document.comment)
file_name = SanitizedStr(data_key='filename', file_name = SanitizedStr(data_key='filename',