Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions survey_question_type_binary/models/survey_user_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
question, answer, answer_type
)
if answer_type in ("binary", "multi_binary") and answer:
if answer_type == "binary":
del vals["value_binary"]
else:
del vals["value_multi_binary"]
vals.pop("value_binary", None)
vals.pop("value_multi_binary", None)
if not isinstance(answer, (list, tuple)):
answer = [answer]
answer_binary_datas = []
new_entries = []
for answer_binary in answer:
data = answer_binary.get("data")
filename = answer_binary.get("filename")
answer_binary_datas += [
if not data:
continue

Check warning on line 44 in survey_question_type_binary/models/survey_user_input.py

View check run for this annotation

Codecov / codecov/patch

survey_question_type_binary/models/survey_user_input.py#L44

Added line #L44 was not covered by tests
new_entries.append(
(
0,
0,
Expand All @@ -51,6 +51,10 @@
"filename": filename,
},
)
]
vals.update({"answer_binary_ids": answer_binary_datas})
)
if answer_type == "binary":
vals["answer_binary_ids"] = [(5, 0, 0)] + new_entries
elif answer_type == "multi_binary":
vals.setdefault("answer_binary_ids", [])
vals["answer_binary_ids"].extend(new_entries)
return vals