from django.core import validators
def is_unique_name(slug, all_data):
- from content.models import Document, Folder
+ from bpcms.models import Document, Folder
if all_data["folder"] != '' and all_data["id"] == '':
folder_id = int(all_data["folder"])
try:
- doc = Document.object.get(folder__exact=folder_id, slug__exact=slug)
+ doc = Document.objects.get(folder__exact=folder_id, slug__exact=slug)
raise validators.ValidationError(u'There is already a document with that name')
except:
pass
try:
- folder = Folder.object.get(slug__exact=slug, parent__exact=folder_id)
+ folder = Folder.objects.get(slug__exact=slug, parent__exact=folder_id)
raise validators.ValidationError(u'There is already a folder with that name')
except:
pass
-from content.models import Document, Folder
+from bpcms.models import Document, Folder
import operator
def content_menu(request):
'url': item.get_basic_url(),
}
)
- folders = Folder.objects.filter(folder__isnull=True)
+ folders = Folder.objects.filter(parent__isnull=True)
for folder in folders:
try:
- item = Document.objects.filter(folder__exact=folder, islive__exact=True, slug__exact='index')
+ items = Document.objects.filter(folder__exact=folder, islive__exact=True, slug__exact='index')
+ item = items[0]
menu_items.append(
{
- 'title': folder.title,
+ 'title': item.title,
'url': folder.get_basic_url(),
}
)
except:
pass
-
+
menu_items.sort(cmp=lambda x,y: cmp(x['title'].lower(), y['title'].lower()))
-
+
return {
'content_menu': menu_items,
}
from django.db import models
-from content.content_val import is_unique_name
+from bpcms.content_val import is_unique_name
FORMAT_CHOICES = (
('rst', 'reStructuredText'),
if folderstring != u'':
folderstring = "%s/" %(folderstring,)
- return "%s/" %(folderstring)
+ return "%s" %(folderstring)
class Admin:
pass
-from content.models import Document, Folder
+from bpcms.models import Document, Folder
from django.http import Http404, HttpResponse
from django.template import RequestContext, loader
doc = Document.objects.get(slug__exact='index', islive__exact=True, folder__exact=folder)
except:
raise Http404
- template_name = "%s.html" %(doc.format,)
+ template_name = "bpcms/%s.html" %(doc.format,)
t = loader.get_template(template_name)
c = RequestContext(request,
{