Ejemplo n.º 1
0
 def post(self):
     data = get_request_json()
     if 'query' not in data:
         abort(400)
     query_handler_name = 'handle_%s' % data['query']
     if not hasattr(self, query_handler_name):
         abort(404)
     return getattr(self, query_handler_name)(data)
Ejemplo n.º 2
0
 def post(self):
     fields = get_request_json()
     try:
         model = cls(**fields)
         model.save()
     except OperationError:
         abort(403)
     else:
         return self.to_dict(model)
Ejemplo n.º 3
0
 def put(self, model_pk):
     fields = get_request_json()
     model = self.get_or_abort(model_pk)
     try:
         model.update(**fields)
         model.save()
     except OperationError:
         abort(403)
     else:
         return self.to_dict(model)
Ejemplo n.º 4
0
 def post(self):
     data = get_request_json()
     if "topic_id" not in data:
         abort(400)
     if data["topic_id"] in collectors:
         abort(403)
     topic_pk = data["topic_id"]
     try:
         topic = Topic.objects.get(pk=topic_pk)
     except (ValidationError, Topic.DoesNotExist):
         abort(404)
     collector_proc = CollectorProcess(topic)
     collectors[topic_pk] = collector_proc
     collector_proc.start()
     return data
Ejemplo n.º 5
0
 def post(self):
     data = get_request_json()
     if 'topic_id' not in data:
         abort(400)
     if data['topic_id'] in collectors:
         abort(403)
     topic_pk = data['topic_id']
     try:
         topic = Topic.objects.get(pk=topic_pk)
     except (ValidationError, Topic.DoesNotExist):
         abort(404)
     collector_proc = CollectorProcess(topic)
     collectors[topic_pk] = collector_proc
     collector_proc.start()
     return data