def post(self, request): user = self.request.user data = json.loads(request.body) service = BundleService(self.request.user) if data.get('raw_command', None): data['command'] = service.get_command(data['raw_command']) if not data.get('worksheet_uuid', None) or not data.get( 'command', None): return Response("Must have worksheet uuid and command", status=status.HTTP_400_BAD_REQUEST) service = BundleService(self.request.user) # If 'autocomplete' field is set, return a list of completions instead if data.get('autocomplete', False): return Response({ 'completions': service.complete_command(data['worksheet_uuid'], data['command']) }) result = service.general_command(data['worksheet_uuid'], data['command']) if result['exception'] is None: return Response({ 'success': True, 'data': result, 'input_data': data }) else: return Response(result['exception'], status=500)
def post(self, request): data = json.loads(request.body) service = BundleService(self.request.user) if data.get('raw_command', None): data['command'] = service.get_command(data['raw_command']) if not data.get('worksheet_uuid', None) or not data.get('command', None): return Response("Must have worksheet uuid and command", status=status.HTTP_400_BAD_REQUEST) # If 'autocomplete' field is set, return a list of completions instead if data.get('autocomplete', False): return Response({ 'completions': service.complete_command(data['worksheet_uuid'], data['command']) }) result = service.general_command(data['worksheet_uuid'], data['command']) return Response(result)