def process_status(request, import_id, TheImportEvent): ie = TheImportEvent.objects.get(pk=import_id) resp = None if ie.errors: resp = {'status': 'file_error', 'errors': json.loads(ie.errors)} else: errors = [] for row in ie.rows(): if row.errors: errors.append((row.idx, json.loads(row.errors))) if len(errors) > 0: resp = {'status': 'row_error', 'errors': dict(errors)} if resp is None: resp = {'status': 'success', 'rows': ie.rows().count()} return HttpResponse(json.dumps(resp), content_type='application/json')
def process_status(request, instance, import_type, import_event_id): ie = _get_import_event(instance, import_type, import_event_id) resp = None if ie.errors: resp = {'status': 'file_error', 'errors': json.loads(ie.errors)} else: errors = [] for row in ie.rows(): if row.errors: errors.append((row.idx, json.loads(row.errors))) if len(errors) > 0: resp = {'status': 'row_error', 'errors': dict(errors)} if resp is None: resp = {'status': 'success', 'rows': ie.rows().count()} return HttpResponse(json.dumps(resp), content_type='application/json')