From 0d99aa49847bcb9b051c722974056c3d2f2e416c Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 26 Jan 2022 13:50:43 +0100 Subject: [PATCH] fix tags in use --- ereuse_devicehub/inventory/forms.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 8d950b01..ca2338ea 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -437,6 +437,10 @@ class TagDeviceForm(FlaskForm): self._tag = Tag.query.filter(Tag.id == self.tag.data).filter( Tag.owner_id == g.user.id).one() + if not self.delete and self._tag.device_id: + self.tag.errors = [("This tag is actualy in use.")] + return False + if self.device.data: try: self.device.data = int(self.device.data.split(',')[-1])