mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 01:06:11 -06:00
Don't cancel wipe out creation records when an object is deleted
This commit is contained in:
parent
b57616e9ce
commit
d6f1e18192
@ -143,12 +143,6 @@ class checkout:
|
|||||||
key = self.get_key_for_instance(instance)
|
key = self.get_key_for_instance(instance)
|
||||||
object_type = instance._meta.verbose_name
|
object_type = instance._meta.verbose_name
|
||||||
|
|
||||||
# Cancel the creation of a new object
|
|
||||||
if key in self.queue and self.queue[key][0] == ChangeActionChoices.ACTION_CREATE:
|
|
||||||
logger.debug(f"[{self.branch}] Removing staged creation of {object_type} {instance} (PK: {instance.pk})")
|
|
||||||
del self.queue[key]
|
|
||||||
return
|
|
||||||
|
|
||||||
# Delete an existing object
|
# Delete an existing object
|
||||||
logger.debug(f"[{self.branch}] Staging deletion of {object_type} {instance} (PK: {instance.pk})")
|
logger.debug(f"[{self.branch}] Staging deletion of {object_type} {instance} (PK: {instance.pk})")
|
||||||
self.queue[key] = (ChangeActionChoices.ACTION_DELETE, None)
|
self.queue[key] = (ChangeActionChoices.ACTION_DELETE, None)
|
||||||
|
@ -168,25 +168,6 @@ class StagingTestCase(TransactionTestCase):
|
|||||||
self.assertEqual(Circuit.objects.count(), 6)
|
self.assertEqual(Circuit.objects.count(), 6)
|
||||||
self.assertEqual(Change.objects.count(), 0)
|
self.assertEqual(Change.objects.count(), 0)
|
||||||
|
|
||||||
def test_create_update_delete_clean(self):
|
|
||||||
branch = Branch.objects.create(name='Branch 1')
|
|
||||||
|
|
||||||
with checkout(branch):
|
|
||||||
|
|
||||||
# Create a new object
|
|
||||||
provider = Provider.objects.create(name='Provider D', slug='provider-d')
|
|
||||||
provider.save()
|
|
||||||
|
|
||||||
# Update it
|
|
||||||
provider.comments = 'Another change'
|
|
||||||
provider.save()
|
|
||||||
|
|
||||||
# Delete it
|
|
||||||
provider.delete()
|
|
||||||
|
|
||||||
# Check that the staged Change has been deleted
|
|
||||||
self.assertFalse(Change.objects.exists())
|
|
||||||
|
|
||||||
def test_exit_enter_context(self):
|
def test_exit_enter_context(self):
|
||||||
branch = Branch.objects.create(name='Branch 1')
|
branch = Branch.objects.create(name='Branch 1')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user