1 from bpcms.models import Document, Folder
2 from django.conf import settings
5 def content_menu(request):
6 items = Document.objects.filter(folder__isnull=True, islive__exact=True)
9 if item.slug != 'index':
13 'url': item.get_basic_url(),
16 folders = Folder.objects.filter(parent__isnull=True)
17 for folder in folders:
19 items = Document.objects.filter(folder__exact=folder, islive__exact=True, slug__exact='index')
24 'url': folder.get_basic_url(),
31 cmp=lambda x,y: cmp(x['title'].lower(), y['title'].lower()))
34 'content_menu': menu_items,
37 def content_submenu(request):
38 # find where we are in the tree first
39 folderpath = request.path
40 folderpath = re.sub(u'^%s' %(settings.BPCMS_ROOT), '', folderpath)
41 # right - that should be any prefix got rid of, now traverse the tree till
44 folderpath = folderpath.split('/')
45 for part in folderpath:
48 f = Folder.objects.get(parent__exact=folder, slug__exact=part)
50 f = Folder.objects.get(parent__isnull=True, slug__exact=part)
55 # We have the folder (in theory)
58 items = Document.objects.filter(folder__exact=folder, \
61 if item.slug != 'index':
65 'url': item.get_basic_url(),
69 folders = Folder.objects.filter(parent__exact=folder)
72 for folder in folders:
74 items = Document.objects.filter(folder__exact=folder, \
75 islive__exact=True, slug__exact='index')
80 'url': folder.get_basic_url(),
87 cmp=lambda x,y: cmp(x['title'].lower(), y['title'].lower()))
90 'content_submenu': menu_items,