Skip to content

Commit 2338db4

Browse files
author
Sourcery AI
committed
'Refactored by Sourcery'
1 parent 5ad1810 commit 2338db4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

netbox_acls/forms/models.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,20 @@ def clean(self):
230230
host_type: [error_same_acl_name],
231231
"name": [error_same_acl_name],
232232
}
233-
if self.instance.pk:
234-
# Check if Access List has no existing rules before change the Access List's type.
235-
if (
233+
if (
234+
self.instance.pk
235+
and (
236236
acl_type == ACLTypeChoices.TYPE_EXTENDED
237237
and self.instance.aclstandardrules.exists()
238-
) or (
238+
)
239+
or (
239240
acl_type == ACLTypeChoices.TYPE_STANDARD
240241
and self.instance.aclextendedrules.exists()
241-
):
242-
error_message["type"] = [
243-
"This ACL has ACL rules associated, CANNOT change ACL type.",
244-
]
242+
)
243+
):
244+
error_message["type"] = [
245+
"This ACL has ACL rules associated, CANNOT change ACL type.",
246+
]
245247

246248
if error_message:
247249
raise forms.ValidationError(error_message)

0 commit comments

Comments
 (0)