mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
Make function atomic
This commit is contained in:
parent
08f958dd72
commit
774872e6a6
@ -6,6 +6,7 @@ Django views for interacting with Part app
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
from django.db import transaction
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.shortcuts import HttpResponseRedirect
|
from django.shortcuts import HttpResponseRedirect
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
@ -194,11 +195,15 @@ class PartSetCategory(AjaxUpdateView):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if valid:
|
if valid:
|
||||||
for part in self.parts:
|
self.set_category()
|
||||||
part.set_category(self.category)
|
|
||||||
|
|
||||||
return self.renderJsonResponse(request, data=data, form=self.get_form(), context=self.get_context_data())
|
return self.renderJsonResponse(request, data=data, form=self.get_form(), context=self.get_context_data())
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
|
def set_category(self):
|
||||||
|
for part in self.parts:
|
||||||
|
part.set_category(self.category)
|
||||||
|
|
||||||
def get_context_data(self):
|
def get_context_data(self):
|
||||||
""" Return context data for rendering in the form """
|
""" Return context data for rendering in the form """
|
||||||
ctx = {}
|
ctx = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user