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

#15548 - False Positive Related Object in Custom Fields #15705

Conversation

Julio-Oliveira-Encora
Copy link
Contributor

Fixes: #15548

I created the class CustomObjectDeleteView, which was inherited from ObjectDeleteView, and overwritten the "get" method and its dependent_objects variable. This way, the modal from delete_form.html will not display messages about dependent objects.

Also, I changed the inherited class for CustomFieldDeleteView to use generic.CustomObjectDeleteView.

…jects.

Changed the inherited class for CustomFieldDeleteView to use generic.CustomObjectDeleteView.
Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this @Julio-Oliveira-Encora. I think there are a few issues with this approach.

First, we shouldn't need to introduce a custom class: ObjectDeleteView already has a _get_dependent_objects() method which we can override if needed to tweak which objects are returned.

Second, we can't blindly assume that no dependent objects will exist. The bug pertains only to the custom field's association with content types; it's very likely that other dependencies may exist now or in the future.

Finally, we want to consider whether the reported behavior affects other models in NetBox too. For instance, should we also ignore content type associations when deleting a custom link or export template? Probably. We might even want to ignore many-to-many associations entirely, as the deletion of these associations doesn't actually impact the related objects.

@jeremystretch
Copy link
Member

I've proposed an alternative solution to this in #15889, which addresses the root issue more generally.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

false positive related object in custom fields
2 participants