Skip to content

Commit

Permalink
bug fix overwrite submission
Browse files Browse the repository at this point in the history
  • Loading branch information
jmargutt committed Nov 2, 2024
1 parent 9a0c6cd commit 2db8f42
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions routes/routesKobo.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ async def kobo_to_linked_kobo(
target_url = f"https://kobo.ifrc.org/api/v2/assets/{request.headers['parentasset']}/data/?format=json"
koboheaders = {"Authorization": f"Token {request.headers['kobotoken']}"}
response = requests.get(target_url, headers=koboheaders)
submissions = json.loads(response.content)
parent_submissions = json.loads(response.content)

# create new choice list based on parent form submissions
new_choices_form, kuids = [], []
for submission in submissions["results"]:
if request.headers["parentquestion"] not in submission.keys():
for parent_submission in parent_submissions["results"]:
if request.headers["parentquestion"] not in parent_submission.keys():
continue
kuid = str(uuid.uuid4())[:10].replace("-", "")
while kuid in kuids:
Expand All @@ -277,11 +277,11 @@ async def kobo_to_linked_kobo(

new_choices_form.append(
{
"name": submission[request.headers["parentquestion"]],
"name": parent_submission[request.headers["parentquestion"]],
"$kuid": kuid,
"label": [submission[request.headers["parentquestion"]]],
"label": [parent_submission[request.headers["parentquestion"]]],
"list_name": request.headers["childlist"],
"$autovalue": submission[request.headers["parentquestion"]],
"$autovalue": parent_submission[request.headers["parentquestion"]],
}
)

Expand Down

0 comments on commit 2db8f42

Please sign in to comment.