From b6ae7270f2bda2f98c48d559ea40d62b180840e3 Mon Sep 17 00:00:00 2001 From: Sourcery AI <> Date: Fri, 27 Jan 2023 14:59:45 +0000 Subject: [PATCH] 'Refactored by Sourcery' --- netbox_acls/forms/models.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/netbox_acls/forms/models.py b/netbox_acls/forms/models.py index 1fc7f104..b5a06135 100644 --- a/netbox_acls/forms/models.py +++ b/netbox_acls/forms/models.py @@ -239,17 +239,20 @@ def clean(self): "name": [error_same_acl_name], } # Check if Access List has no existing rules before change the Access List's type. - if self.instance.pk: - if ( + if ( + self.instance.pk + and ( acl_type == ACLTypeChoices.TYPE_EXTENDED and self.instance.aclstandardrules.exists() - ) or ( + ) + or ( acl_type == ACLTypeChoices.TYPE_STANDARD and self.instance.aclextendedrules.exists() - ): - error_message["type"] = [ - "This ACL has ACL rules associated, CANNOT change ACL type.", - ] + ) + ): + error_message["type"] = [ + "This ACL has ACL rules associated, CANNOT change ACL type.", + ] if error_message: raise forms.ValidationError(error_message)