From 4ed56f84dedf9da88708fc2c4aef3b0b11f30825 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Tue, 29 Sep 2009 16:31:11 +0200 Subject: [PATCH] URL changes. --- apps/api/handlers/library_handlers.py | 50 +++++++++++++++----------- apps/api/urls.py | 18 +++++----- apps/explorer/models.py | 3 ++ project/static/js/models.js | 2 +- project/templates/explorer/editor.html | 4 +-- 5 files changed, 44 insertions(+), 33 deletions(-) diff --git a/apps/api/handlers/library_handlers.py b/apps/api/handlers/library_handlers.py index 2170b44b..f0ce1863 100644 --- a/apps/api/handlers/library_handlers.py +++ b/apps/api/handlers/library_handlers.py @@ -153,9 +153,9 @@ class BasicDocumentHandler(AnonymousBaseHandler): result = { 'name': doc.id, - 'html_url': reverse('dochtml_view', args=[doc.id,doc.revision]), - 'text_url': reverse('doctext_view', args=[doc.id,doc.revision]), - 'dc_url': reverse('docdc_view', args=[doc.id,doc.revision]), + 'html_url': reverse('dochtml_view', args=[doc.id]), + 'text_url': reverse('doctext_view', args=[doc.id]), + 'dc_url': reverse('docdc_view', args=[doc.id]), 'public_revision': doc.revision, } @@ -183,9 +183,9 @@ class DocumentHandler(BaseHandler): result = { 'name': udoc.id, - '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]), + 'html_url': reverse('dochtml_view', args=[udoc.id]), + 'text_url': reverse('doctext_view', args=[udoc.id]), + 'dc_url': reverse('docdc_view', args=[udoc.id]), 'gallery_url': reverse('docgallery_view', args=[udoc.id]), 'merge_url': reverse('docmerge_view', args=[udoc.id]), 'user_revision': udoc.revision, @@ -207,9 +207,11 @@ class DocumentHTMLHandler(BaseHandler): allowed_methods = ('GET') @hglibrary - def read(self, request, docid, revision, lib): + def read(self, request, docid, lib): """Read document as html text""" try: + revision = request.GET.get('revision', 'latest') + if revision == 'latest': document = lib.document(docid) else: @@ -270,11 +272,12 @@ XINCLUDE_REGEXP = r"""<(?:\w+:)?include\s+[^>]*?href=("|')wlrepo://(?P[^\1 # # class DocumentTextHandler(BaseHandler): - allowed_methods = ('GET', 'PUT') + allowed_methods = ('GET', 'POST') @hglibrary - def read(self, request, docid, revision, lib): - """Read document as raw text""" + def read(self, request, docid, lib): + """Read document as raw text""" + revision = request.GET.get('revision', 'latest') try: if revision == 'latest': document = lib.document(docid) @@ -292,12 +295,13 @@ class DocumentTextHandler(BaseHandler): 'exception': type(e), 'message': e.message}) @hglibrary - def update(self, request, docid, revision, lib): + def create(self, request, docid, lib): try: - data = request.PUT['contents'] + data = request.POST['contents'] + revision = request.POST['revision'] - if request.PUT.has_key('message'): - msg = u"$USER$ " + request.PUT['message'] + if request.POST.has_key('message'): + msg = u"$USER$ " + request.POST['message'] else: msg = u"$AUTO$ XML content update." @@ -353,7 +357,7 @@ class DocumentTextHandler(BaseHandler): "previous_revision": current.revision, "revision": ndoc.revision, 'timestamp': ndoc.revision.timestamp, - "url": reverse("doctext_view", args=[ndoc.id, ndoc.revision]) + "url": reverse("doctext_view", args=[ndoc.id]) }) except Exception, e: if ndoc: lib._rollback() @@ -369,12 +373,14 @@ class DocumentTextHandler(BaseHandler): # @requires librarian # class DocumentDublinCoreHandler(BaseHandler): - allowed_methods = ('GET', 'PUT') + allowed_methods = ('GET', 'POST') @hglibrary - def read(self, request, docid, revision, lib): + def read(self, request, docid, lib): """Read document as raw text""" try: + revision = request.GET.get('revision', 'latest') + if revision == 'latest': doc = lib.document(docid) else: @@ -392,10 +398,12 @@ class DocumentDublinCoreHandler(BaseHandler): 'exception': type(e), 'message': e.message}) @hglibrary - def update(self, request, docid, revision, lib): + def create(self, request, docid, lib): try: - bi_json = request.PUT['contents'] - if request.PUT.has_key('message'): + bi_json = request.POST['contents'] + revision = request.POST['revision'] + + if request.POST.has_key('message'): msg = u"$USER$ " + request.PUT['message'] else: msg = u"$AUTO$ Dublin core update." @@ -425,7 +433,7 @@ class DocumentDublinCoreHandler(BaseHandler): "previous_revision": current.revision, "revision": ndoc.revision, 'timestamp': ndoc.revision.timestamp, - "url": reverse("docdc_view", args=[ndoc.id, ndoc.revision]) + "url": reverse("docdc_view", args=[ndoc.id]) } except Exception, e: if ndoc: lib._rollback() diff --git a/apps/api/urls.py b/apps/api/urls.py index 18fc02c4..c5b0986d 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -7,7 +7,7 @@ from api.resources import * FORMAT = r"\.(?Pxml|json|yaml)" DOC = r'(?P[^/]+)' -REVISION = r'(?Platest|[0-9a-f]{40})' +# REVISION = r'(?Platest|[0-9a-f]{40})' def urlpath(*args, **kwargs): format = kwargs.get('format', True) @@ -35,8 +35,8 @@ urlpatterns = patterns('', url(urlpath(r'documents'), library_resource, name="document_list_view_withformat"), - url(urlpath(r'documents', DOC), - document_resource, name="document_view_withformat"), + #url(urlpath(r'documents', DOC), + # document_resource, name="document_view_withformat"), url(urlpath(r'documents', DOC, format=False), document_resource, {'emitter_format': 'json'}, @@ -47,21 +47,21 @@ urlpatterns = patterns('', name="docgallery_view"), # XML - url(urlpath(r'documents', DOC, 'text', REVISION, format=False), + url(urlpath(r'documents', DOC, 'text', format=False), document_text_resource, {'emitter_format': 'rawxml'}, name="doctext_view"), # HTML - url(urlpath(r'documents', DOC, 'html', REVISION, format=False), + url(urlpath(r'documents', DOC, 'html', format=False), document_html_resource, {'emitter_format': 'rawhtml'}, name="dochtml_view"), # DC - url(urlpath(r'documents', DOC, 'dc', REVISION), - document_dc_resource, - name="docdc_view_withformat"), + #url(urlpath(r'documents', DOC, 'dc'), + # document_dc_resource, + # name="docdc_view_withformat"), - url(urlpath(r'documents', DOC, 'dc', REVISION, format=False), + url(urlpath(r'documents', DOC, 'dc', format=False), document_dc_resource, {'emitter_format': 'json'}, name="docdc_view"), diff --git a/apps/explorer/models.py b/apps/explorer/models.py index 5181e167..a8a8c3b2 100644 --- a/apps/explorer/models.py +++ b/apps/explorer/models.py @@ -100,3 +100,6 @@ class GalleryForDocument(models.Model): # document associated with the gallery document = models.CharField(max_length=255) + + def __unicode__(self): + return u"%s:%s" % self.subpath, self.document \ No newline at end of file diff --git a/project/static/js/models.js b/project/static/js/models.js index 62d1c783..f8149d1c 100644 --- a/project/static/js/models.js +++ b/project/static/js/models.js @@ -203,7 +203,7 @@ Editor.ImageGalleryModel = Editor.Model.extend({ alert('erroneous state:', this.get('state')); } - this.set('pages', data.pages) + this.set('pages', data[0].pages) this.set('state', 'synced'); }, diff --git a/project/templates/explorer/editor.html b/project/templates/explorer/editor.html index de1e2420..3e141679 100644 --- a/project/templates/explorer/editor.html +++ b/project/templates/explorer/editor.html @@ -61,8 +61,8 @@
- <% for (page in panels) { %> -

strona

+ <% for (page in model.pages) { %> +

page.url

<% }; %>
-- 2.20.1