URL changes.
authorŁukasz Rekucki <lrekucki@gmail.com>
Tue, 29 Sep 2009 14:31:11 +0000 (16:31 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Tue, 29 Sep 2009 14:31:11 +0000 (16:31 +0200)
apps/api/handlers/library_handlers.py
apps/api/urls.py
apps/explorer/models.py
project/static/js/models.js
project/templates/explorer/editor.html

index 2170b44..f0ce186 100644 (file)
@@ -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<link>[^\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()
index 18fc02c..c5b0986 100644 (file)
@@ -7,7 +7,7 @@ from api.resources import *
 
 FORMAT = r"\.(?P<emitter_format>xml|json|yaml)"
 DOC = r'(?P<docid>[^/]+)'
-REVISION = r'(?P<revision>latest|[0-9a-f]{40})'
+REVISION = r'(?P<revision>latest|[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"),
 
index 5181e16..a8a8c3b 100644 (file)
@@ -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
index 62d1c78..f8149d1 100644 (file)
@@ -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');
   },
 
index de1e242..3e14167 100644 (file)
@@ -61,8 +61,8 @@
         </div>
 
         <div>
-            <% for (page in panels) { %>
-                <p>strona</p>
+            <% for (page in model.pages) { %>
+                <p>page.url</p>
             <% }; %>
        </div>