Move JSON/YAML data valdiation to ImportForm

This commit is contained in:
Jeremy Stretch
2019-09-24 16:13:52 -04:00
parent f2cf335e7c
commit 45bed25234
2 changed files with 25 additions and 11 deletions

View File

@@ -420,18 +420,10 @@ class ObjectImportView(GetReturnURLMixin, View):
def post(self, request):
form = ImportForm(request.POST)
if form.is_valid():
# Process object data
if form.cleaned_data['format'] == 'json':
data = json.loads(form.cleaned_data['data'])
else:
data = yaml.load(form.cleaned_data['data'])
# Initialize model form
model_form = self.model_form(data)
model_form = self.model_form(form.cleaned_data['data'])
if model_form.is_valid():
with transaction.atomic():