Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 2 additions & 5 deletions src/formpack/schema/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,8 @@ def get_value_from_entry(self, entry):
except KeyError:
return ''

# sure would be nice if this were a dict with uuids as keys instead of
# a list requiring this kind of iteration
for response in responses:
if response['uuid'] == field_uuid:
return response['value']
if question_response := responses.get(field_uuid):
return question_response['value']

return ''

Expand Down
7 changes: 3 additions & 4 deletions tests/fixtures/analysis_form/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@
}
},
"clerk_details/name_of_clerk": {
"qual": [
{
"uuid": "uuid_for_comment",
"qual": {
"uuid_for_comment": {
"value": "Sounds like an interesting person"
}
]
}
}
}
},
Expand Down
7 changes: 3 additions & 4 deletions tests/fixtures/analysis_form/v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@
}
},
"clerk_details/name_of_shop": {
"qual": [
{
"uuid": "uuid_for_comment",
"qual": {
"uuid_for_comment": {
"value": "Pretty cliche"
}
]
}
}
}
},
Expand Down
38 changes: 16 additions & 22 deletions tests/fixtures/analysis_form_advanced/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@
"value": "Hello how may I help you?",
"languageCode": "en"
},
"qual": [
{
"uuid": "uuid_for_tone_of_voice",
"qual": {
"uuid_for_tone_of_voice": {
"value": [
{
"uuid": "uuid_for_excited",
Expand All @@ -101,24 +100,22 @@
}
]
}
]
}
},
"clerk_interactions/goods_sold": {
"qual": [
{
"uuid": "uuid_for_comment",
"qual": {
"uuid_for_comment": {
"value": "Not much diversity"
},
{
"uuid": "uuid_for_rating",
"uuid_for_rating": {
"value": {
"uuid": "uuid_for_3",
"labels": {
"_default": "3"
}
}
}
]
}
}
}
},
Expand All @@ -137,9 +134,8 @@
"value": "Thank you for your business",
"languageCode": "en"
},
"qual": [
{
"uuid": "uuid_for_tone_of_voice",
"qual": {
"uuid_for_tone_of_voice": {
"value": [
{
"uuid": "uuid_for_anxious",
Expand All @@ -155,20 +151,19 @@
}
]
}
]
}
},
"clerk_interactions/goods_sold": {
"qual": [
{
"uuid": "uuid_for_rating",
"qual": {
"uuid_for_rating": {
"value": {
"uuid": "uuid_for_2",
"labels": {
"_default": "2"
}
}
}
]
}
}
}
},
Expand All @@ -183,17 +178,16 @@
],
"_supplementalDetails": {
"clerk_interactions/goods_sold": {
"qual": [
{
"uuid": "uuid_for_rating",
"qual": {
"uuid_for_rating": {
"value": {
"uuid": "uuid_for_3",
"labels": {
"_default": "3"
}
}
}
]
}
}
}
}
Expand Down