]> git.sommitrealweird.co.uk Git - sommitrealweird.git/blobdiff - sommitrealweird/content/models.py
New menu code and reorg of URLs
[sommitrealweird.git] / sommitrealweird / content / models.py
index 6487830f7d6fbab2f2d4690b33067ecb02d7ee98..a310a79a25c0f5bc6e4ea747a8c494b8f2a9ab7a 100644 (file)
@@ -32,6 +32,20 @@ class Document(models.Model):
                 doc.islive = False
                 doc.save()
 
+    def get_basic_url(self):
+        folders = []
+        curfolder = self.folder
+        while curfolder != None:
+            folders.append(curfolder.slug)
+            curfolder = curfolder.parent
+
+        folders.reverse()
+        folderstring = "/".join(folders)
+        if folderstring != u'':
+            folderstring = "%s/" %(folderstring,)
+
+        return "%s%s/" %(folderstring, self.slug)
+
     class Admin:
         pass
 
@@ -46,5 +60,19 @@ class Folder(models.Model):
     def __unicode__(self):
         return u'%s' %(self.title)
 
+    def get_basic_url(self):
+        folders = []
+        curfolder = self
+        while curfolder != None:
+            folders.append(curfolder.slug)
+            curfolder = curfolder.parent
+
+        folders.reverse()
+        folderstring = "/".join(folders)
+        if folderstring != u'':
+            folderstring = "%s/" %(folderstring,)
+
+        return "%s/" %(folderstring)
+
     class Admin:
         pass