12336 review changes

This commit is contained in:
Arthur 2023-10-13 09:21:22 -07:00
parent 960e64c365
commit 870b1fabe5

View File

@ -161,20 +161,20 @@ class NetBoxModelViewSet(
return super().perform_destroy(instance) return super().perform_destroy(instance)
class MPTTLockedMixin(GenericViewSet): class MPTTLockedMixin:
""" """
Puts pglock on objects that derive from MPTTModel for parallel API calling. Puts pglock on objects that derive from MPTTModel for parallel API calling.
Note: If adding this to a view, must add the model name to ADVISORY_LOCK_KEYS Note: If adding this to a view, must add the model name to ADVISORY_LOCK_KEYS
""" """
def create(self, request, *args, **kwargs): def create(self, request, *args, **kwargs):
with advisory_lock(ADVISORY_LOCK_KEYS[self.queryset.model._meta.verbose_name.lower().replace(" ", "")]): with advisory_lock(ADVISORY_LOCK_KEYS[self.queryset.model._meta.model_name]):
return super().create(request, *args, **kwargs) return super().create(request, *args, **kwargs)
def update(self, request, *args, **kwargs): def update(self, request, *args, **kwargs):
with advisory_lock(ADVISORY_LOCK_KEYS[self.queryset.model._meta.verbose_name.lower().replace(" ", "")]): with advisory_lock(ADVISORY_LOCK_KEYS[self.queryset.model._meta.model_name]):
return super().update(request, *args, **kwargs) return super().update(request, *args, **kwargs)
def destroy(self, request, *args, **kwargs): def destroy(self, request, *args, **kwargs):
with advisory_lock(ADVISORY_LOCK_KEYS[self.queryset.model._meta.verbose_name.lower().replace(" ", "")]): with advisory_lock(ADVISORY_LOCK_KEYS[self.queryset.model._meta.model_name]):
return super().destroy(request, *args, **kwargs) return super().destroy(request, *args, **kwargs)