Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove qpath, use (x)path instead #324

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 3 additions & 7 deletions src/formpack/schema/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ def __init__(
# do not include the root section in the path
self.path = '/'.join(info.name for info in self.hierarchy[1:])

@property
def qpath(self):
return self.path.replace('/', '-')

def get_labels(
self,
lang=UNSPECIFIED_TRANSLATION,
Expand Down Expand Up @@ -536,7 +532,7 @@ def get_value_from_entry(self, entry):
name = self.name.split('/')[-1]

try:
responses = entry['_supplementalDetails'][self.source_field.qpath][
responses = entry['_supplementalDetails'][self.source_field.path][
'qual'
]
except KeyError:
Expand Down Expand Up @@ -626,7 +622,7 @@ def get_value_from_entry(self, entry):
name = self.name.split('/')[-1]

try:
responses = entry['_supplementalDetails'][self.source_field.qpath]
responses = entry['_supplementalDetails'][self.source_field.path]
except KeyError:
return ''

Expand All @@ -653,7 +649,7 @@ def get_value_from_entry(self, entry):
name = self.name.split('/')[-1]

try:
responses = entry['_supplementalDetails'][self.source_field.qpath]
responses = entry['_supplementalDetails'][self.source_field.path]
except KeyError:
return ''

Expand Down
4 changes: 2 additions & 2 deletions src/formpack/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _map_sections_to_analysis_fields(
self, survey_field: FormField
) -> List[FormField]:
_fields = []
for analysis_field in self.fields_by_source[survey_field.qpath]:
for analysis_field in self.fields_by_source[survey_field.path]:
analysis_field.section = survey_field.section
analysis_field.source_field = survey_field
_fields.append(analysis_field)
Expand All @@ -141,7 +141,7 @@ def insert_analysis_fields(
_fields = []
for field in fields:
_fields.append(field)
if field.qpath in self.fields_by_source:
if field.path in self.fields_by_source:
_fields += self._map_sections_to_analysis_fields(field)
return _fields

Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures/analysis_form/analysis_form.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,21 @@
"type": "qual_text",
"name": "name_of_clerk/comment",
"path": [
"clerk_details-name_of_clerk",
"clerk_details/name_of_clerk",
"comment"
],
"label": "Comment on the name of the clerk",
"source": "clerk_details-name_of_clerk"
"source": "clerk_details/name_of_clerk"
},
{
"type": "qual_text",
"name": "name_of_shop/comment",
"path": [
"clerk_details-name_of_shop",
"clerk_details/name_of_shop",
"comment"
],
"label": "Comment on the name of the shop",
"source": "clerk_details-name_of_shop"
"source": "clerk_details/name_of_shop"
}
],
"translations": [
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/analysis_form/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
}
}
},
"clerk_details-name_of_clerk": {
"clerk_details/name_of_clerk": {
"qual": [
{
"uuid": "comment",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/analysis_form/v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"languageCode": "en"
}
},
"clerk_details-name_of_shop": {
"clerk_details/name_of_shop": {
"qual": [
{
"uuid": "comment",
Expand Down
16 changes: 8 additions & 8 deletions tests/fixtures/analysis_form_advanced/analysis_form.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"type": "transcript",
"name": "record_a_note/transcript_en",
"path": [
"clerk_interactions-record_a_note",
"clerk_interactions/record_a_note",
"transcript_en"
],
"source": "clerk_interactions-record_a_note",
"source": "clerk_interactions/record_a_note",
"language": "en",
"settings": {
"mode": "auto",
Expand All @@ -23,15 +23,15 @@
"type": "qual_select_multiple",
"name": "record_a_note/tone_of_voice",
"path": [
"clerk_interactions-record_a_note",
"clerk_interactions/record_a_note",
"tone_of_voice"
],
"label": "How was the tone of the clerk's voice?",
"labels__for_future_use": [
"How was the tone of the clerk's voice?",
"Kiel estis la tono de la voĉo de la oficisto?"
],
"source": "clerk_interactions-record_a_note",
"source": "clerk_interactions/record_a_note",
"choices": [
{
"uuid": "anxious",
Expand Down Expand Up @@ -63,29 +63,29 @@
"type": "qual_text",
"name": "goods_sold/comment",
"path": [
"clerk_interactions-goods_sold",
"clerk_interactions/goods_sold",
"comment"
],
"label": "Comment on the goods sold at the store",
"labels__for_future_use": [
"Comment on the goods sold at the store",
"Komentu la varojn venditajn en la vendejo"
],
"source": "clerk_interactions-goods_sold"
"source": "clerk_interactions/goods_sold"
},
{
"type": "qual_select_one",
"name": "goods_sold/rating",
"path": [
"clerk_interactions-goods_sold",
"clerk_interactions/goods_sold",
"rating"
],
"label": "Rate the quality of the goods sold at the store",
"labels__for_future_use": [
"Rate the quality of the goods sold at the store",
"Komentu la varojn vendojn en la vendejo"
],
"source": "clerk_interactions-goods_sold",
"source": "clerk_interactions/goods_sold",
"choices": [
{
"uuid": "1",
Expand Down
10 changes: 5 additions & 5 deletions tests/fixtures/analysis_form_advanced/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
}
],
"_supplementalDetails": {
"clerk_interactions-record_a_note": {
"clerk_interactions/record_a_note": {
"transcript": {
"value": "Hello how may I help you?",
"languageCode": "en"
Expand All @@ -90,7 +90,7 @@
}
]
},
"clerk_interactions-goods_sold": {
"clerk_interactions/goods_sold": {
"qual": [
{"uuid": "comment", "val": "Not much diversity"},
{"uuid": "rating", "val": {"uuid": "3"}}
Expand All @@ -108,7 +108,7 @@
}
],
"_supplementalDetails": {
"clerk_interactions-record_a_note": {
"clerk_interactions/record_a_note": {
"transcript": {
"value": "Thank you for your business",
"languageCode": "en"
Expand All @@ -120,7 +120,7 @@
}
]
},
"clerk_interactions-goods_sold": {
"clerk_interactions/goods_sold": {
"qual": [
{"uuid": "rating", "val": {"uuid": "2"}}
]
Expand All @@ -137,7 +137,7 @@
}
],
"_supplementalDetails": {
"clerk_interactions-goods_sold": {
"clerk_interactions/goods_sold": {
"qual": [
{"uuid": "rating", "val": {"uuid": "3"}}
]
Expand Down
Loading