From 5e8cf78751ad4f62c8783c89c96bcfe6c8f06400 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 5 Dec 2022 19:17:54 +0100 Subject: [PATCH] put the forze of validation in the schemas --- .../versions/564952310b17_add_vendor_family_in_device.py | 4 ++-- ereuse_devicehub/resources/action/views/snapshot.py | 5 ----- ereuse_devicehub/resources/device/schemas.py | 6 +++--- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ereuse_devicehub/migrations/versions/564952310b17_add_vendor_family_in_device.py b/ereuse_devicehub/migrations/versions/564952310b17_add_vendor_family_in_device.py index c1484d66..f37ae2f3 100644 --- a/ereuse_devicehub/migrations/versions/564952310b17_add_vendor_family_in_device.py +++ b/ereuse_devicehub/migrations/versions/564952310b17_add_vendor_family_in_device.py @@ -1,7 +1,7 @@ """add vendor family in device Revision ID: 564952310b17 -Revises: d65745749e34 +Revises: af038a8a388c Create Date: 2022-11-14 13:12:22.916848 """ @@ -11,7 +11,7 @@ from alembic import context, op # revision identifiers, used by Alembic. revision = '564952310b17' -down_revision = 'd65745749e34' +down_revision = 'af038a8a388c' branch_labels = None depends_on = None diff --git a/ereuse_devicehub/resources/action/views/snapshot.py b/ereuse_devicehub/resources/action/views/snapshot.py index 16a89bed..c5df4838 100644 --- a/ereuse_devicehub/resources/action/views/snapshot.py +++ b/ereuse_devicehub/resources/action/views/snapshot.py @@ -8,7 +8,6 @@ from uuid import UUID from flask import current_app as app from flask import g -from marshmallow import ValidationError from sqlalchemy.util import OrderedSet from ereuse_devicehub.db import db @@ -118,10 +117,6 @@ class SnapshotMixin: snapshot.device.set_hid() snapshot.device.binding.device.set_hid() - if not snapshot.device.hid: - txt = "Not exist the basic fields for to do an device. " - txt += "Please do one placeholder instead of one snapshot" - raise ValidationError(txt) return snapshot diff --git a/ereuse_devicehub/resources/device/schemas.py b/ereuse_devicehub/resources/device/schemas.py index 604da213..e34502f5 100644 --- a/ereuse_devicehub/resources/device/schemas.py +++ b/ereuse_devicehub/resources/device/schemas.py @@ -213,9 +213,9 @@ class Computer(Device): """Validates than exist model manufacturer and system_uuid.""" minimum = [ - data['manufacturer'], - data['model'], - data['system_uuid'], + data.get('manufacturer'), + data.get('model'), + data.get('system_uuid'), ] if not all(minimum):