.
This commit is contained in:
@@ -116,15 +116,12 @@
|
|||||||
json_toolstates.push(JSON.stringify(toolstate[image]));
|
json_toolstates.push(JSON.stringify(toolstate[image]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log(json_toolstates);
|
|
||||||
return
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'rapids:question_save_annotation' pk=question.pk %}",
|
url: "{% url 'rapids:question_save_annotation' pk=question.pk %}",
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
annotation: json,
|
// Yes we do double encode the json....
|
||||||
|
annotation: JSON.stringify(json_toolstates),
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
|
|||||||
+8
-3
@@ -1156,10 +1156,15 @@ def question_save_annotation(request, pk):
|
|||||||
if request.is_ajax() and request.method == "POST":
|
if request.is_ajax() and request.method == "POST":
|
||||||
question = get_object_or_404(Rapid, pk=pk)
|
question = get_object_or_404(Rapid, pk=pk)
|
||||||
|
|
||||||
question.image_annotations = request.POST.get("annotation")
|
image_annotations = json.loads(request.POST.get("annotation"))
|
||||||
print(question.image_annotations)
|
|
||||||
|
question_images = question.images.all()
|
||||||
|
|
||||||
|
for n, annotation in enumerate(image_annotations):
|
||||||
|
if annotation != "undefined":
|
||||||
|
question.images[n].image_annotations = annotation
|
||||||
|
question.images[n].save()
|
||||||
|
|
||||||
question.save()
|
|
||||||
data = {"status": "success"}
|
data = {"status": "success"}
|
||||||
return JsonResponse(data, status=200)
|
return JsonResponse(data, status=200)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user