def export_async(self, request, *args, **kwargs): params = request.query_params job_uuid = params.get('job_uuid') export_type = params.get('format') include_hxl = params.get('include_hxl', False) include_labels = params.get('include_labels', False) include_labels_only = params.get('include_labels_only', False) query = params.get("query") dataview = self.get_object() xform = dataview.xform if include_labels is not None: include_labels = str_to_bool(include_labels) if include_labels_only is not None: include_labels_only = str_to_bool(include_labels_only) if include_hxl is not None: include_hxl = str_to_bool(include_hxl) remove_group_name = params.get('remove_group_name', False) columns_with_hxl = get_columns_with_hxl(xform.survey.get('children')) if columns_with_hxl and include_hxl: include_hxl = include_hxl_row( dataview.columns, list(columns_with_hxl) ) options = { 'remove_group_name': remove_group_name, 'dataview_pk': dataview.pk, 'include_hxl': include_hxl, 'include_labels': include_labels, 'include_labels_only': include_labels_only } if query: options.update({'query': query}) if job_uuid: job = AsyncResult(job_uuid) if job.state == 'SUCCESS': export_id = job.result export = Export.objects.get(id=export_id) resp = export_async_export_response(request, export) else: resp = { 'job_status': job.state } else: resp = process_async_export(request, xform, export_type, options=options) return Response(data=resp, status=status.HTTP_202_ACCEPTED, content_type="application/json")
def export_async(self, request, *args, **kwargs): params = request.query_params job_uuid = params.get('job_uuid') export_type = params.get('format') include_hxl = params.get('include_hxl', False) dataview = self.get_object() xform = dataview.xform remove_group_name = params.get('remove_group_name', False) columns_with_hxl = get_columns_with_hxl(xform.survey.get('children')) if columns_with_hxl and include_hxl: include_hxl = include_hxl_row(dataview.columns, columns_with_hxl.keys()) options = { 'remove_group_name': remove_group_name, 'dataview_pk': dataview.pk, 'include_hxl': include_hxl } if job_uuid: job = AsyncResult(job_uuid) if job.state == 'SUCCESS': export_id = job.result export = Export.objects.get(id=export_id) resp = _export_async_export_response(request, xform, export, dataview_pk=dataview.pk) else: resp = {'job_status': job.state} else: resp = process_async_export(request, xform, export_type, options=options) return Response(data=resp, status=status.HTTP_202_ACCEPTED, content_type="application/json")
def get_has_hxl_support(self, obj): columns_with_hxl = get_columns_with_hxl( obj.xform.survey.get('children')) return include_hxl_row(obj.columns, columns_with_hxl.keys())
def get_has_hxl_support(self, obj): columns_with_hxl = get_columns_with_hxl( obj.xform.survey.get('children') ) return include_hxl_row(obj.columns, list(columns_with_hxl))