mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Fixes #17278: Rebuild the tree after bulk editing MPTT-enabled object types
This commit is contained in:
parent
50839fcb6b
commit
e3e351d1f0
@ -9,13 +9,14 @@ from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist, Valida
|
|||||||
from django.db import transaction, IntegrityError
|
from django.db import transaction, IntegrityError
|
||||||
from django.db.models import ManyToManyField, ProtectedError, RestrictedError
|
from django.db.models import ManyToManyField, ProtectedError, RestrictedError
|
||||||
from django.db.models.fields.reverse_related import ManyToManyRel
|
from django.db.models.fields.reverse_related import ManyToManyRel
|
||||||
from django.forms import HiddenInput, ModelMultipleChoiceField, MultipleHiddenInput
|
from django.forms import ModelMultipleChoiceField, MultipleHiddenInput
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django_tables2.export import TableExport
|
from django_tables2.export import TableExport
|
||||||
|
from mptt.models import MPTTModel
|
||||||
|
|
||||||
from core.models import ObjectType
|
from core.models import ObjectType
|
||||||
from extras.choices import CustomFieldUIEditableChoices
|
from extras.choices import CustomFieldUIEditableChoices
|
||||||
@ -614,6 +615,10 @@ class BulkEditView(GetReturnURLMixin, BaseMultiObjectView):
|
|||||||
if form.cleaned_data.get('remove_tags', None):
|
if form.cleaned_data.get('remove_tags', None):
|
||||||
obj.tags.remove(*form.cleaned_data['remove_tags'])
|
obj.tags.remove(*form.cleaned_data['remove_tags'])
|
||||||
|
|
||||||
|
# Rebuild the tree for MPTT models
|
||||||
|
if issubclass(self.queryset.model, MPTTModel):
|
||||||
|
self.queryset.model.objects.rebuild()
|
||||||
|
|
||||||
return updated_objects
|
return updated_objects
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user