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

Closes: #15239 - Allow adding/removing tagged VLANs in bulk editing of Interfaces #17524

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

bctiemann
Copy link
Contributor

Closes: #15239

Adds "Add Tagged VLANs" and "Remove tagged VLANs" widgets to the bulk edit form of Interfaces, both when editing them standalone and when accessing them as components of a device. These fields operate in the same way as the existing "Add tags"/"Remove tags" and allow the user to add or remove the selected items to all selected objects regardless of their existing VLANs, rather than having to set all objects to the same VLAN settings in the edit operation.

Note that this PR also cleans up the __init__ function of InterfaceBulkEditForm, removing the after-the-fact modification of the widgets to add query parameters, as these params can be set in the field definitions directly using the $device token.

Screenshot 2024-09-17 at 4 01 39 PM

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.

Nice work with this @bctiemann, we just need to figure out a pattern for accommodating these non-model many-to-many fields generically.

Comment on lines 618 to 623
# Add/remove tagged VLANs
if form.cleaned_data.get('add_tagged_vlans', None):
obj.tagged_vlans.add(*form.cleaned_data['add_tagged_vlans'])
if form.cleaned_data.get('remove_tagged_vlans', None):
obj.tagged_vlans.remove(*form.cleaned_data['remove_tagged_vlans'])

Copy link
Member

Choose a reason for hiding this comment

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

Model-specific fields can't go into a generic view. We'll need to come up with a pattern for handling these generically, probably in a manner similar to how we handle many-to-many assignments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, how about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow bulk assignment/unassignment of VLANs to interfaces
2 participants