equal
deleted
inserted
replaced
30 import logging |
30 import logging |
31 import lucene |
31 import lucene |
32 import tempfile |
32 import tempfile |
33 import uuid |
33 import uuid |
34 from tagging.models import Tag |
34 from tagging.models import Tag |
|
35 from oauth_provider.decorators import * |
35 |
36 |
36 ## Filters the annotation depending on the request parameters |
37 ## Filters the annotation depending on the request parameters |
37 ## Returns an xml containing the resulting annotations |
38 ## Returns an xml containing the resulting annotations |
38 def filter_annotation(request, uri=None, filter=None, limit=None, creator=None): |
39 def filter_annotation(request, uri=None, filter=None, limit=None, creator=None): |
39 annotlist = None |
40 annotlist = None |
63 return HttpResponse(lxml.etree.tostring(doc, pretty_print=True), mimetype="text/xml;charset=utf-8") |
64 return HttpResponse(lxml.etree.tostring(doc, pretty_print=True), mimetype="text/xml;charset=utf-8") |
64 |
65 |
65 |
66 |
66 ## Creates an annotation from a urlencoded xml content |
67 ## Creates an annotation from a urlencoded xml content |
67 ## Returns an xml-structured annotation |
68 ## Returns an xml-structured annotation |
68 #@login_required |
69 @oauth_required |
69 @csrf_exempt |
70 @csrf_exempt |
70 def create_annotation(request): |
71 def create_annotation(request): |
71 cont = request.POST["content"] |
72 cont = request.POST["content"] |
72 doc = lxml.etree.fromstring(cont) |
73 doc = lxml.etree.fromstring(cont) |
73 |
74 |
142 return HttpResponse(lxml.etree.tostring(doc, pretty_print=True), mimetype="text/xml;charset=utf-8") |
143 return HttpResponse(lxml.etree.tostring(doc, pretty_print=True), mimetype="text/xml;charset=utf-8") |
143 |
144 |
144 |
145 |
145 ## Deletes an annotation (from its id) |
146 ## Deletes an annotation (from its id) |
146 ## Returns an empty xml-structured annotation |
147 ## Returns an empty xml-structured annotation |
147 #@login_required |
148 @oauth_required |
148 @csrf_exempt |
149 @csrf_exempt |
149 def delete_annotation(request): |
150 def delete_annotation(request): |
150 try: |
151 try: |
151 annot = Annotation.objects.get(external_id=request.POST["id"]) |
152 annot = Annotation.objects.get(external_id=request.POST["id"]) |
152 annot.delete() |
153 annot.delete() |
157 return HttpResponse(lxml.etree.tostring(doc, pretty_print=True), mimetype="text/xml;charset=utf-8") |
158 return HttpResponse(lxml.etree.tostring(doc, pretty_print=True), mimetype="text/xml;charset=utf-8") |
158 |
159 |
159 |
160 |
160 ## Updates the content of an annotation |
161 ## Updates the content of an annotation |
161 ## Returns the xml-structured updated annotation |
162 ## Returns the xml-structured updated annotation |
162 #@login_required |
163 @oauth_required |
163 @csrf_exempt |
164 @csrf_exempt |
164 def update_annotation(request): |
165 def update_annotation(request): |
165 try: |
166 try: |
166 annot = Annotation.objects.get(external_id=request.POST["id"]) |
167 annot = Annotation.objects.get(external_id=request.POST["id"]) |
167 except Annotation.DoesNotExist: |
168 except Annotation.DoesNotExist: |