fix tags in use

This commit is contained in:
Cayo Puigdefabregas 2022-01-26 13:50:43 +01:00
parent 0f30bbda35
commit 0d99aa4984
1 changed files with 4 additions and 0 deletions

View File

@ -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])