From 91b8ceaf4a9cbd6c6de025a0707ba917a63e4b9b Mon Sep 17 00:00:00 2001
From: Te Hung Tseng <te-hung.tseng@ess.eu>
Date: Fri, 26 Mar 2021 09:45:09 +0100
Subject: [PATCH] fixed bug introduced with last commit during validation for
 ansible group

---
 app/models.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/models.py b/app/models.py
index 80c80a2..d1bc664 100644
--- a/app/models.py
+++ b/app/models.py
@@ -1179,7 +1179,7 @@ class AnsibleGroup(CreatedMixin, SearchableMixin, db.Model):
         lower_string = string.lower()
         if GROUP_NAME_RE.fullmatch(lower_string) is None:
             raise ValidationError(f"Group name shall match {GROUP_NAME_RE.pattern}")
-        existing_group_name = AnsibleGroup.query.filter_by(name=lower_string).first()
+        existing_group_name = AnsibleGroup.query.filter(AnsibleGroup.name == lower_string, AnsibleGroup.id != self.id).first()      
         if existing_group_name:
             raise ValidationError("Group name matches an existing group")
         return lower_string
-- 
GitLab