UI - Dont allow empty tag names (#1641)

elementpath-xpath20
dgtlmoon 2 years ago committed by GitHub
parent 0e65dda5b6
commit 8cbf8e8f57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1364,7 +1364,8 @@ def changedetection_app(config=None, datastore_o=None):
flash("{} watches set to use default notification settings".format(len(uuids))) flash("{} watches set to use default notification settings".format(len(uuids)))
elif (op == 'assign-tag'): elif (op == 'assign-tag'):
op_extradata = request.form.get('op_extradata') op_extradata = request.form.get('op_extradata', '').strip()
if op_extradata:
tag_uuid = datastore.add_tag(name=op_extradata) tag_uuid = datastore.add_tag(name=op_extradata)
if op_extradata and tag_uuid: if op_extradata and tag_uuid:
for uuid in uuids: for uuid in uuids:

@ -566,9 +566,12 @@ class ChangeDetectionStore:
return ret return ret
def add_tag(self, name): def add_tag(self, name):
print (">>> Adding new tag -", name)
# If name exists, return that # If name exists, return that
n = name.strip().lower() n = name.strip().lower()
print (f">>> Adding new tag - '{n}")
if not n:
return False
for uuid, tag in self.__data['settings']['application'].get('tags', {}).items(): for uuid, tag in self.__data['settings']['application'].get('tags', {}).items():
if n == tag.get('title', '').lower().strip(): if n == tag.get('title', '').lower().strip():
print (f">>> Tag {name} already exists") print (f">>> Tag {name} already exists")

Loading…
Cancel
Save