mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Add in in-line vlan editing and Bulk vlan editing (#3350)
* Fixes #3341 - Added in-line vlan editing * Fixes #2160 - Added bulk vlan editing Inconsequential behaviour changes: * APISelect can now take "full=True" to return a non-brief set * Select2 will no group by "group & site, group, site, global" if full=True is set in APISelect
This commit is contained in:
@@ -7,6 +7,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import transaction, IntegrityError
|
||||
from django.db.models import Count, ProtectedError
|
||||
from django.db.models.query import QuerySet
|
||||
from django.forms import CharField, Form, ModelMultipleChoiceField, MultipleHiddenInput, Textarea
|
||||
from django.http import HttpResponse, HttpResponseServerError
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
@@ -530,9 +531,13 @@ class BulkEditView(GetReturnURLMixin, View):
|
||||
|
||||
# Update standard fields. If a field is listed in _nullify, delete its value.
|
||||
for name in standard_fields:
|
||||
if name in form.nullable_fields and name in nullified_fields:
|
||||
if name in form.nullable_fields and name in nullified_fields and isinstance(form.cleaned_data[name], QuerySet):
|
||||
getattr(obj, name).set([])
|
||||
elif name in form.nullable_fields and name in nullified_fields:
|
||||
setattr(obj, name, '' if isinstance(form.fields[name], CharField) else None)
|
||||
elif form.cleaned_data[name] not in (None, ''):
|
||||
elif isinstance(form.cleaned_data[name], QuerySet) and form.cleaned_data[name]:
|
||||
getattr(obj, name).set(form.cleaned_data[name])
|
||||
elif form.cleaned_data[name] not in (None, '') and not isinstance(form.cleaned_data[name], QuerySet):
|
||||
setattr(obj, name, form.cleaned_data[name])
|
||||
obj.full_clean()
|
||||
obj.save()
|
||||
|
Reference in New Issue
Block a user