Now with the ability to handle multiple custom question in the data export
This commit is contained in:
@@ -41,12 +41,11 @@ class Event_Exhibit_Tracking_Base(BaseModel):
|
|||||||
|
|
||||||
exhibitor_notes: Optional[str]
|
exhibitor_notes: Optional[str]
|
||||||
responses_json: Optional[Json] # NOTE: Responses to custom questions
|
responses_json: Optional[Json] # NOTE: Responses to custom questions
|
||||||
# responses_json: Json = [{'test': ''}] # NOTE: Responses to custom questions
|
# Example:
|
||||||
# responses_json: Optional[Json] = Field(
|
# {"5_years": {"response": "I see myself in 5 years doing something."}, "colors": {"response": "green"}}
|
||||||
# default_factory = lambda:[{'test': ''}]
|
# {"example_text": {"response": "This is an example of an text answer."}, "example_option_list": {"response": "no"}, "the_code": {"response": "yes"}, "question_everything": {"response": "tomorrow"}, "pre_assesment": {"response": "yes"}}
|
||||||
# )
|
|
||||||
data_json: Optional[Json]
|
data_json: Optional[Json] # NOTE: Additional data
|
||||||
# data_json: Optional[str]
|
|
||||||
|
|
||||||
enable: Optional[bool]
|
enable: Optional[bool]
|
||||||
hide: Optional[bool]
|
hide: Optional[bool]
|
||||||
|
|||||||
@@ -366,6 +366,17 @@ async def get_event_exhibit_obj_tracking_list(
|
|||||||
data_dict['person_location'] = data_dict.pop('event_badge_location', None)
|
data_dict['person_location'] = data_dict.pop('event_badge_location', None)
|
||||||
else: data_dict['person_location'] = None
|
else: data_dict['person_location'] = None
|
||||||
|
|
||||||
|
# Example values for responses_json:
|
||||||
|
# {"5_years": {"response": "I see myself in 5 years doing something."}, "colors": {"response": "green"}}
|
||||||
|
# {"example_text": {"response": "This is an example of an text answer."}, "example_option_list": {"response": "no"}, "the_code": {"response": "yes"}, "question_everything": {"response": "tomorrow"}, "pre_assesment": {"response": "yes"}}
|
||||||
|
if 'responses_json' in data_dict and data_dict['responses_json']:
|
||||||
|
responses_json = data_dict.pop('responses_json', None)
|
||||||
|
for key, value in responses_json.items():
|
||||||
|
# Only use the response value.
|
||||||
|
data_dict[key] = value.get('response')
|
||||||
|
else:
|
||||||
|
data_dict[key] = None
|
||||||
|
|
||||||
log.debug(data_dict)
|
log.debug(data_dict)
|
||||||
|
|
||||||
data_dict_list_for_export.append(data_dict)
|
data_dict_list_for_export.append(data_dict)
|
||||||
@@ -425,6 +436,9 @@ async def get_event_exhibit_obj_tracking_list(
|
|||||||
'created_on',
|
'created_on',
|
||||||
'updated_on',
|
'updated_on',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Add the custom questions to the column_name_li for the label row of the export file
|
||||||
|
column_name_li.extend(data_dict_list_for_export[0].keys())
|
||||||
|
|
||||||
log.debug(column_name_li)
|
log.debug(column_name_li)
|
||||||
log.debug(data_dict_list_for_export)
|
log.debug(data_dict_list_for_export)
|
||||||
|
|||||||
Reference in New Issue
Block a user