Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add model tests (Sourcery refactored) #137

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.",
]
Comment on lines -242 to +255
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AccessListForm.clean refactored with the following changes:

This removes the following comments ( why? ):

# Check if Access List has no existing rules before change the Access List's type.


if error_message:
raise forms.ValidationError(error_message)
Expand Down