filter correct values
This commit is contained in:
parent
39f19f676b
commit
94a586f00b
|
@ -747,13 +747,13 @@ class Device(Thing):
|
||||||
|
|
||||||
def set_hid(self):
|
def set_hid(self):
|
||||||
"""
|
"""
|
||||||
# product_vendor,
|
# product_vendor, is a manufacturer
|
||||||
# product_family,
|
# product_family, is a model but from dmidecode
|
||||||
# product_chassis,
|
# product_chassis, is a type of chassis
|
||||||
# product_number,
|
# product_number, is a ??
|
||||||
# product_version,
|
# product_version,
|
||||||
# product_sku,
|
# product_sku,
|
||||||
# product_serial,
|
# product_serial, is a serial number
|
||||||
# product_uuid,
|
# product_uuid,
|
||||||
# board_vendor,
|
# board_vendor,
|
||||||
# board_number,
|
# board_number,
|
||||||
|
@ -762,6 +762,8 @@ class Device(Thing):
|
||||||
"""
|
"""
|
||||||
with suppress(TypeError):
|
with suppress(TypeError):
|
||||||
family = (self.family or '').replace(' ', '_')
|
family = (self.family or '').replace(' ', '_')
|
||||||
|
model = ((self.model or '').replace(' ', '_'),)
|
||||||
|
model = model or family
|
||||||
chassis = self.type
|
chassis = self.type
|
||||||
if hasattr(self, 'chassis'):
|
if hasattr(self, 'chassis'):
|
||||||
chassis = self.chassis and self.chassis.name or ''
|
chassis = self.chassis and self.chassis.name or ''
|
||||||
|
@ -792,12 +794,11 @@ class Device(Thing):
|
||||||
self.hid = '-'.join(
|
self.hid = '-'.join(
|
||||||
[
|
[
|
||||||
(self.manufacturer or '').replace(' ', '_'),
|
(self.manufacturer or '').replace(' ', '_'),
|
||||||
family,
|
model,
|
||||||
chassis,
|
chassis,
|
||||||
(self.model or '').replace(' ', '_'),
|
self.serial_number,
|
||||||
version,
|
version,
|
||||||
sku,
|
sku,
|
||||||
self.serial_number,
|
|
||||||
system_uuid,
|
system_uuid,
|
||||||
board_manufacturer,
|
board_manufacturer,
|
||||||
board_model,
|
board_model,
|
||||||
|
|
|
@ -208,6 +208,21 @@ class Computer(Device):
|
||||||
receiver_id = UUID(data_key='receiverID')
|
receiver_id = UUID(data_key='receiverID')
|
||||||
system_uuid = UUID(required=False)
|
system_uuid = UUID(required=False)
|
||||||
|
|
||||||
|
@post_load
|
||||||
|
def validate_hid(self, data):
|
||||||
|
"""Validates than exist model manufacturer and system_uuid."""
|
||||||
|
|
||||||
|
minimum = [
|
||||||
|
data['manufacturer'],
|
||||||
|
data['model'],
|
||||||
|
data['system_uuid'],
|
||||||
|
]
|
||||||
|
|
||||||
|
if not all(minimum):
|
||||||
|
txt = 'You can not register one device with out minimum datas, '
|
||||||
|
txt += 'you can to do one placeholder.'
|
||||||
|
raise ValidationError(txt)
|
||||||
|
|
||||||
|
|
||||||
class Desktop(Computer):
|
class Desktop(Computer):
|
||||||
__doc__ = m.Desktop.__doc__
|
__doc__ = m.Desktop.__doc__
|
||||||
|
|
Reference in New Issue