Merge pull request #207 from eReuse/change/#2825-tags-only-computers

fix change #2825, tags only for Computers
This commit is contained in:
Santiago L 2022-03-04 12:11:43 +01:00 committed by GitHub
commit 0a4b77f48a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1206,8 +1206,9 @@ def create_code_tag(mapper, connection, device):
this tag is the same of devicehub_id.
"""
from ereuse_devicehub.resources.tag.model import Tag
tag = Tag(device_id=device.id, id=device.devicehub_id)
db.session.add(tag)
if isinstance(device, Computer):
tag = Tag(device_id=device.id, id=device.devicehub_id)
db.session.add(tag)
event.listen(Device, 'after_insert', create_code_tag, propagate=True)