X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/blobdiff_plain/d4b37caed377b2739b82a3ac6e002f008d2616bd..a2883504e45a556b06e76f023395e879e01ae03c:/sommitrealweird/content/models.py diff --git a/sommitrealweird/content/models.py b/sommitrealweird/content/models.py index 6487830..a310a79 100644 --- a/sommitrealweird/content/models.py +++ b/sommitrealweird/content/models.py @@ -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