Skip to content

Commit bfacd02

Browse files
author
Sourcery AI
committed
'Refactored by Sourcery'
1 parent 15fa8ff commit bfacd02

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
@@ -239,18 +239,20 @@ def clean(self):
239239
host_type: [error_same_acl_name],
240240
"name": [error_same_acl_name],
241241
}
242-
if self.instance.pk:
243-
# Check if Access List has no existing rules before change the Access List's type.
244-
if (
242+
if (
243+
self.instance.pk
244+
and (
245245
acl_type == ACLTypeChoices.TYPE_EXTENDED
246246
and self.instance.aclstandardrules.exists()
247-
) or (
247+
)
248+
or (
248249
acl_type == ACLTypeChoices.TYPE_STANDARD
249250
and self.instance.aclextendedrules.exists()
250-
):
251-
error_message["type"] = [
252-
"This ACL has ACL rules associated, CANNOT change ACL type.",
253-
]
251+
)
252+
):
253+
error_message["type"] = [
254+
"This ACL has ACL rules associated, CANNOT change ACL type.",
255+
]
254256

255257
if error_message:
256258
raise forms.ValidationError(error_message)

0 commit comments

Comments
 (0)