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

Removed extra gfk validation #144

Merged
merged 1 commit into from
Apr 22, 2023
Merged
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
30 changes: 0 additions & 30 deletions netbox_acls/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,6 @@ def validate(self, data):
"""
error_message = {}

# Check that the GFK object is valid.
if "assigned_object_type" in data and "assigned_object_id" in data:
# TODO: This can removed after https://github.com/netbox-community/netbox/issues/10221 is fixed.
try:
assigned_object = data[ # noqa: F841
"assigned_object_type"
].get_object_for_this_type(
id=data["assigned_object_id"],
)
except ObjectDoesNotExist:
# Sets a standard error message for invalid GFK
error_message_invalid_gfk = f"Invalid assigned_object {data['assigned_object_type']} ID {data['assigned_object_id']}"
error_message["assigned_object_type"] = [error_message_invalid_gfk]
error_message["assigned_object_id"] = [error_message_invalid_gfk]

# Check if Access List has no existing rules before change the Access List's type.
if (
self.instance
Expand Down Expand Up @@ -182,21 +167,6 @@ def validate(self, data):
error_message = {}
acl_host = data["access_list"].assigned_object

# Check that the GFK object is valid.
if "assigned_object_type" in data and "assigned_object_id" in data:
# TODO: This can removed after https://github.com/netbox-community/netbox/issues/10221 is fixed.
try:
assigned_object = data[ # noqa: F841
"assigned_object_type"
].get_object_for_this_type(
id=data["assigned_object_id"],
)
except ObjectDoesNotExist:
# Sets a standard error message for invalid GFK
error_message_invalid_gfk = f"Invalid assigned_object {data['assigned_object_type']} ID {data['assigned_object_id']}"
error_message["assigned_object_type"] = [error_message_invalid_gfk]
error_message["assigned_object_id"] = [error_message_invalid_gfk]

if data["assigned_object_type"].model == "interface":
interface_host = (
data["assigned_object_type"]
Expand Down