Skip to content

Commit 0922581

Browse files
author
Sourcery AI
committed
'Refactored by Sourcery'
1 parent ced12c5 commit 0922581

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

netbox_acls/forms/models.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -490,20 +490,19 @@ def _check_if_interface_already_has_acl_in_direction(self, assigned_object_id, a
490490
"""
491491
Check that the interface does not have an existing ACL applied in the direction already.
492492
"""
493-
if ACLInterfaceAssignment.objects.filter(
493+
if not ACLInterfaceAssignment.objects.filter(
494494
assigned_object_id=assigned_object_id,
495495
assigned_object_type=assigned_object_type_id,
496496
direction=direction,
497497
).exists():
498-
error_interface_already_assigned = (
499-
"Interfaces can only have 1 Access List assigned in each direction."
500-
)
501-
return {
502-
"direction": [error_interface_already_assigned],
503-
assigned_object_type: [error_interface_already_assigned],
504-
}
505-
else:
506498
return {}
499+
error_interface_already_assigned = (
500+
"Interfaces can only have 1 Access List assigned in each direction."
501+
)
502+
return {
503+
"direction": [error_interface_already_assigned],
504+
assigned_object_type: [error_interface_already_assigned],
505+
}
507506

508507

509508
def save(self, *args, **kwargs):

0 commit comments

Comments
 (0)