def get(self, request, *args, **kwargs): """ Dump all users, roles, email addresses, review statuses, review status groups, app vars, document types, fields and field detectors to json. """ return HttpResponse(get_full_dump(), content_type='Application/json')
def put(self, request, *args, **kwargs): data = request.data # type: dict buf = io.StringIO() try: with NamedTemporaryFile(mode='w+', suffix='.json') as f: json.dump(data, f) f.seek(0) call_command('loadnewdata', f.name, stdout=buf, interactive=False) buf.seek(0) return HttpResponse(content=get_full_dump(), content_type='Application/json', status=200) except: log = buf.read() tb = traceback.format_exc() data = {'log': log, 'exception': tb} return HttpResponse(content=json.dumps(data), content_type='Application/json', status=400)
def get_json_dump(self) -> str: return get_full_dump()