Пример #1
0
 def post(self, request, client_data):
     # create. Creates an annotation object and returns a 303.
     obj = Annotation()
     obj.owner = request.user if request.user.is_authenticated() else None
     try:
         obj.document = Sentence.objects.get(id=client_data.get("document"))
     except:
         raise ValueError("Invalid or missing 'document' value passed in annotation data.")
     obj.set_guid()
     obj.data = "{ }"
     obj.update_from_json(client_data)
     obj.save()
     return obj.as_json(request.user)  # Spec wants redirect but warns of browser bugs, so return the object.
Пример #2
0
 def post(self, request, client_data):
     # create. Creates an annotation object and returns a 303.
     obj = Annotation()
     obj.owner = request.user if request.user.is_authenticated() else None
     try:
         obj.document = Sentence.objects.get(id=client_data.get("document"))
     except:
         raise ValueError("Invalid or missing 'document' value passed in annotation data.")
     obj.set_guid()
     obj.data = "{ }"
     obj.update_from_json(client_data)
     obj.save()
     return obj.as_json(request.user)  # Spec wants redirect but warns of browser bugs, so return the object.