adding success and software field in document

This commit is contained in:
Cayo Puigdefabregas 2021-07-29 14:54:58 +02:00
parent bfe56a8626
commit 1811b81e93
5 changed files with 14 additions and 6 deletions

View File

@ -42,6 +42,8 @@ def upgrade():
sa.Column('type', sa.Unicode(), nullable=False),
sa.Column('date', sa.TIMESTAMP(timezone=True), nullable=True),
sa.Column('id_document', sa.Unicode(), nullable=True),
sa.Column('software', sa.Unicode(), nullable=True),
sa.Column('success', sa.Boolean(), nullable=False),
sa.Column('owner_id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('file_name', sa.Unicode(), nullable=False),
sa.Column('file_hash', sa.Unicode(), nullable=False),

View File

@ -45,7 +45,7 @@ class ErasedView():
db.session.add(db_hash)
def insert_action(self, data):
[data.pop(x, None) for x in ['url', 'documentId', 'filename', 'hash']]
[data.pop(x, None) for x in ['url', 'documentId', 'filename', 'hash', 'software', 'success']]
self.data = self.schema.load(data)
for dev in self.data['devices']:

View File

@ -1,6 +1,6 @@
from citext import CIText
from flask import g
from sqlalchemy import BigInteger, Column, Sequence, Unicode
from sqlalchemy import BigInteger, Column, Sequence, Unicode, Boolean
from sqlalchemy.dialects.postgresql import UUID
from teal.db import URL
from ereuse_devicehub.db import db
@ -19,6 +19,10 @@ class Document(Thing):
date = Column(db.DateTime, nullable=True)
date.comment = """The date of document, some documents need to have one date
"""
software = Column(CIText(), nullable=False)
software.comment = """Which software is used"""
success = Column(Boolean)
success.comment = """If the erase was success"""
id_document = Column(CIText(), nullable=False)
id_document.comment = """The id of one document like invoice so they can be linked."""
owner_id = db.Column(UUID(as_uuid=True),

View File

@ -1,4 +1,4 @@
from marshmallow.fields import DateTime, Integer, validate
from marshmallow.fields import DateTime, Integer, validate, Boolean
from teal.marshmallow import SanitizedStr, URL
from ereuse_devicehub.resources.schemas import Thing
from ereuse_devicehub.resources.documents import models as m
@ -9,6 +9,9 @@ class Document(Thing):
__doc__ = m.Document.__doc__
id = Integer(description=m.Document.id.comment, dump_only=True)
type = SanitizedStr(default='Document')
url = URL(description=m.Document.url.comment)
success = Boolean(description=m.Document.success.comment)
software = SanitizedStr(description=m.Document.software.comment)
date = DateTime(data_key='endTime',
required=False,
description=m.Document.date.comment)
@ -23,4 +26,3 @@ class Document(Thing):
default='',
description=m.Document.file_hash.comment,
validate=validate.Length(max=64))
url = URL(description=m.Document.url.comment)

View File

@ -2419,7 +2419,7 @@ def test_action_web_erase(user: UserClient, client: Client):
bfile = BytesIO(b'abc')
hash3 = hashlib.sha3_256(bfile.read()).hexdigest()
snap, _ = user.post(file('acer.happy.battery.snapshot'), res=models.Snapshot)
request = {'type': 'DataWipe', 'devices': [snap['device']['id']], 'name': 'borrado universal', 'severity': 'Info', 'description': 'nada que describir', 'url': 'http://www.google.com/', 'documentId': '33', 'endTime': '2021-07-07T22:00:00.000Z', 'filename': 'Certificado de borrado1.pdf', 'hash': hash3}
request = {'type': 'DataWipe', 'devices': [snap['device']['id']], 'name': 'borrado universal', 'severity': 'Info', 'description': 'nada que describir', 'url': 'http://www.google.com/', 'documentId': '33', 'endTime': '2021-07-07T22:00:00.000Z', 'filename': 'Certificado de borrado1.pdf', 'hash': hash3, 'success': 1, 'software': "Blanco"}
user.post(res=models.Action, data=request)
action = models.DataWipe.query.one()