Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
fix iframe results json serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
dmorina committed Dec 13, 2017
1 parent 3235056 commit 6908605
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions crowdsourcing/viewsets/file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import StringIO
import json
import zipfile
from collections import OrderedDict
from django.http import HttpResponse
Expand Down Expand Up @@ -92,11 +93,17 @@ def _to_dict(result):
'answer' in x and x['answer']])
}
elif result.template_item.type == 'iframe' and isinstance(result.result, list):
return {
"result": result.result
}
try:
return {"result": json.dumps(result.result)}
except Exception:
return {
"result": result.result
}
elif result.template_item.type == 'iframe' and isinstance(result.result, dict):
return result.result
try:
return json.dumps(result.result)
except Exception:
return result.result
else:
return {
str(field_name): result.result
Expand Down

0 comments on commit 6908605

Please sign in to comment.