X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5a1de03a12a386e83a5c579fefd8e6ffbedc2794..9bec1deeed00ac693e6031c69f0778d3bb0dfbd9:/apps/api/handlers/library_handlers.py?ds=inline diff --git a/apps/api/handlers/library_handlers.py b/apps/api/handlers/library_handlers.py index b30f2e78..591d4e90 100644 --- a/apps/api/handlers/library_handlers.py +++ b/apps/api/handlers/library_handlers.py @@ -175,6 +175,7 @@ class DocumentHandler(BaseHandler): 'html_url': reverse('dochtml_view', args=[udoc.id,udoc.revision]), 'text_url': reverse('doctext_view', args=[udoc.id,udoc.revision]), 'dc_url': reverse('docdc_view', args=[udoc.id,udoc.revision]), + #'gallery_url': reverse('docdc_view', args=[udoc.id,udoc.revision]), 'user_revision': udoc.revision, 'public_revision': doc.revision, } @@ -204,9 +205,6 @@ class DocumentHTMLHandler(BaseHandler): except RevisionNotFound: return response.EntityNotFound().django_response() - - - # # Document Text View # @@ -214,6 +212,7 @@ class DocumentHTMLHandler(BaseHandler): XINCLUDE_REGEXP = r"""<(?:\w+:)?include\s+[^>]*?href=("|')wlrepo://(?P[^\1]+?)\1\s*[^>]*?>""" # # +# class DocumentTextHandler(BaseHandler): allowed_methods = ('GET', 'PUT') @@ -268,13 +267,15 @@ class DocumentTextHandler(BaseHandler): f.write(json.dumps(includes)) f.close() + lib._fileadd(resolve('parts')) + # update the parts cache PartCache.update_cache(docid, current.owner,\ stored_includes, includes) # now that the parts are ok, write xml f = lib._fileopen(resolve('xml'), 'w+') - f.write(data) + f.write(data.encode('utf-8')) f.close() ndoc = None @@ -294,7 +295,9 @@ class DocumentTextHandler(BaseHandler): if ndoc: lib._rollback() raise e except RevisionNotFound, e: - return response.EntityNotFound().django_response(e) + return response.EntityNotFound(mimetype="text/plain").\ + django_response(e.message) + # # Dublin Core handlers @@ -350,16 +353,15 @@ class DocumentDublinCoreHandler(BaseHandler): "document": ndoc.id, "subview": "dc", "previous_revision": current.revision, - "updated_revision": ndoc.revision + "updated_revision": ndoc.revision, + "url": reverse("docdc_view", args=[ndoc.id, ndoc.revision]) } except Exception, e: - lib._rollback() + if ndoc: lib._rollback() raise e except RevisionNotFound: return response.EntityNotFound().django_response() - - class MergeHandler(BaseHandler): allowed_methods = ('POST',) @@ -438,4 +440,4 @@ class MergeHandler(BaseHandler): "parent_user_resivion": udoc.revision, "parent_revision": doc.revision, "revision": udoc.revision, - }) \ No newline at end of file + })