Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Feb 7, 2023
1 parent ed8a56c commit 68cea7a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions netbox_acls/forms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,20 @@ def clean(self):
host_type: [error_same_acl_name],
"name": [error_same_acl_name],
}
if self.instance.pk:
# Check if Access List has no existing rules before change the Access List's type.
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)
Expand Down

0 comments on commit 68cea7a

Please sign in to comment.