mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 03:56:53 -06:00
19644 fix review comments
This commit is contained in:
parent
ed9625d2dd
commit
100f08d04d
@ -1,5 +1,5 @@
|
||||
from django.contrib import messages
|
||||
from django.db import transaction, router
|
||||
from django.db import router, transaction
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from django.apps import apps
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import transaction, router
|
||||
from django.db import router, transaction
|
||||
|
||||
|
||||
def compile_path_node(ct_id, object_id):
|
||||
|
@ -1,7 +1,7 @@
|
||||
from django.contrib import messages
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.paginator import EmptyPage, PageNotAnInteger
|
||||
from django.db import transaction, router
|
||||
from django.db import router, transaction
|
||||
from django.db.models import Prefetch
|
||||
from django.forms import ModelMultipleChoiceField, MultipleHiddenInput, modelformset_factory
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
@ -124,7 +124,7 @@ class BulkDisconnectView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View)
|
||||
|
||||
if form.is_valid():
|
||||
|
||||
with transaction.atomic(using=router.db_for_write(self.queryset.model)):
|
||||
with transaction.atomic(using=router.db_for_write(Cable)):
|
||||
count = 0
|
||||
cable_ids = set()
|
||||
for obj in self.queryset.filter(pk__in=form.cleaned_data['pk']):
|
||||
|
@ -2,11 +2,10 @@ import logging
|
||||
import traceback
|
||||
from contextlib import ExitStack
|
||||
|
||||
from django.db import router, transaction
|
||||
from django.db import transaction
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from core.signals import clear_events
|
||||
from dcim.models import Device
|
||||
from extras.models import Script as ScriptModel
|
||||
from netbox.jobs import JobRunner
|
||||
from netbox.registry import registry
|
||||
@ -45,10 +44,9 @@ class ScriptJob(JobRunner):
|
||||
# any other database (for ChangeLogged models) - choosing Device as
|
||||
# the model to use as it has ChangeLoggingMixin
|
||||
with transaction.atomic():
|
||||
with transaction.atomic(using=router.db_for_write(Device)):
|
||||
script.output = script.run(data, commit)
|
||||
if not commit:
|
||||
raise AbortTransaction()
|
||||
script.output = script.run(data, commit)
|
||||
if not commit:
|
||||
raise AbortTransaction()
|
||||
except AbortTransaction:
|
||||
script.log_info(message=_("Database changes have been reverted automatically."))
|
||||
if script.failed:
|
||||
|
@ -2,7 +2,7 @@ from copy import deepcopy
|
||||
|
||||
from django.contrib.contenttypes.prefetch import GenericPrefetch
|
||||
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
|
||||
from django.db import transaction, router
|
||||
from django.db import router, transaction
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.translation import gettext as _
|
||||
from django_pglocks import advisory_lock
|
||||
|
@ -2,7 +2,7 @@ import logging
|
||||
from functools import cached_property
|
||||
|
||||
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
|
||||
from django.db import transaction, router
|
||||
from django.db import router, transaction
|
||||
from django.db.models import ProtectedError, RestrictedError
|
||||
from django_pglocks import advisory_lock
|
||||
from netbox.constants import ADVISORY_LOCK_KEYS
|
||||
|
@ -1,5 +1,5 @@
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db import transaction, router
|
||||
from django.db import router, transaction
|
||||
from django.http import Http404
|
||||
from rest_framework import status
|
||||
from rest_framework.response import Response
|
||||
|
@ -6,7 +6,7 @@ from django.contrib import messages
|
||||
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRel
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist, ValidationError
|
||||
from django.db import transaction, IntegrityError, router
|
||||
from django.db import IntegrityError, router, transaction
|
||||
from django.db.models import ManyToManyField, ProtectedError, RestrictedError
|
||||
from django.db.models.fields.reverse_related import ManyToManyRel
|
||||
from django.forms import ModelMultipleChoiceField, MultipleHiddenInput
|
||||
|
@ -1,7 +1,7 @@
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib import messages
|
||||
from django.db import transaction, router
|
||||
from django.db import router, transaction
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
@ -297,7 +297,7 @@ class ClusterAddDevicesView(generic.ObjectEditView):
|
||||
if form.is_valid():
|
||||
|
||||
device_pks = form.cleaned_data['devices']
|
||||
with transaction.atomic(using=router.db_for_write(self.queryset.model)):
|
||||
with transaction.atomic(using=router.db_for_write(Device)):
|
||||
|
||||
# Assign the selected Devices to the Cluster
|
||||
for device in Device.objects.filter(pk__in=device_pks):
|
||||
@ -332,7 +332,7 @@ class ClusterRemoveDevicesView(generic.ObjectEditView):
|
||||
if form.is_valid():
|
||||
|
||||
device_pks = form.cleaned_data['pk']
|
||||
with transaction.atomic(using=router.db_for_write(self.queryset.model)):
|
||||
with transaction.atomic(using=router.db_for_write(Device)):
|
||||
|
||||
# Remove the selected Devices from the Cluster
|
||||
for device in Device.objects.filter(pk__in=device_pks):
|
||||
|
Loading…
Reference in New Issue
Block a user