fixing change type for document_type
This commit is contained in:
parent
ed43bd477c
commit
9086bb628f
|
@ -39,7 +39,7 @@ def upgrade():
|
|||
comment='The last time Document recorded a change for \n this thing.\n '),
|
||||
sa.Column('created', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'),
|
||||
nullable=False, comment='When Document created this.'),
|
||||
sa.Column('type', sa.Unicode(), nullable=False),
|
||||
sa.Column('document_type', sa.Unicode(), nullable=False),
|
||||
sa.Column('date', sa.TIMESTAMP(timezone=True), nullable=True),
|
||||
sa.Column('id_document', sa.Unicode(), nullable=True),
|
||||
sa.Column('owner_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
|
@ -54,7 +54,7 @@ def upgrade():
|
|||
op.create_index('generic_document_id', 'document', ['id'], unique=False, postgresql_using='hash', schema=f'{get_inv()}')
|
||||
op.create_index(op.f('ix_document_created'), 'document', ['created'], unique=False, schema=f'{get_inv()}')
|
||||
op.create_index(op.f('ix_document_updated'), 'document', ['updated'], unique=False, schema=f'{get_inv()}')
|
||||
op.create_index('document_type_index', 'document', ['type'], unique=False, postgresql_using='hash', schema=f'{get_inv()}')
|
||||
op.create_index('document_type_index', 'document', ['document_type'], unique=False, postgresql_using='hash', schema=f'{get_inv()}')
|
||||
|
||||
|
||||
# DataWipeDocument table
|
||||
|
|
|
@ -29,7 +29,6 @@ class ErasedView():
|
|||
schema = sh_document()
|
||||
[data.pop(x, None) for x in ['severity', 'devices', 'name', 'description']]
|
||||
doc_data = schema.load(data)
|
||||
doc_data['type'] = 'DataWipe'
|
||||
self.document = DataWipeDocument(**doc_data)
|
||||
db.session.add(self.document)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class Document(Thing):
|
|||
id.comment = """The identifier of the device for this database. Used only
|
||||
internally for software; users should not use this.
|
||||
"""
|
||||
type = Column(Unicode(STR_SM_SIZE), nullable=False)
|
||||
document_type = Column(Unicode(STR_SM_SIZE), nullable=False)
|
||||
date = Column(db.DateTime, nullable=True)
|
||||
date.comment = """The date of document, some documents need to have one date
|
||||
"""
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from marshmallow.fields import DateTime, Integer, validate, Boolean
|
||||
from marshmallow import post_load
|
||||
from teal.marshmallow import SanitizedStr, URL
|
||||
from ereuse_devicehub.resources.schemas import Thing
|
||||
from ereuse_devicehub.resources.documents import models as m
|
||||
|
@ -7,7 +8,6 @@ from ereuse_devicehub.resources.documents import models as m
|
|||
class DataWipeDocument(Thing):
|
||||
__doc__ = m.DataWipeDocument.__doc__
|
||||
id = Integer(description=m.DataWipeDocument.id.comment, dump_only=True)
|
||||
type = SanitizedStr(default='DataWipeDocument')
|
||||
url = URL(required= False, description=m.DataWipeDocument.url.comment)
|
||||
success = Boolean(required=False, default=False, description=m.DataWipeDocument.success.comment)
|
||||
software = SanitizedStr(description=m.DataWipeDocument.software.comment)
|
||||
|
@ -26,3 +26,7 @@ class DataWipeDocument(Thing):
|
|||
default='',
|
||||
description=m.DataWipeDocument.file_hash.comment,
|
||||
validate=validate.Length(max=64))
|
||||
|
||||
@post_load
|
||||
def get_trade_document(self, data):
|
||||
data['document_type'] = 'DataWipeDocument'
|
||||
|
|
Reference in New Issue