1 from django.core import validators
2 from django.conf import settings
4 def is_allowed_name(slug, all_data):
5 from bpcms.models import Document, Folder
7 if all_data.has_key('folder'):
8 folder = all_data['folder']
9 elif all_data.has_key('parent'):
10 folder = all_data['parent']
14 # right - we're at the root.
15 if slug in settings.BPCMS_DISALLOWED_ROOT_DOC_NAMES \
16 or slug in ['cms-admin']:
17 raise validators.ValidationError(u'That slug is reserved')
19 def is_unique_name(slug, all_data):
20 from bpcms.models import Document, Folder
21 if all_data["folder"] != '' and all_data["id"] == '':
22 folder_id = int(all_data["folder"])
24 doc = Document.objects.get(folder__exact=folder_id, slug__exact=slug)
25 raise validators.ValidationError(u'There is already a document with that name')
30 folder = Folder.objects.get(slug__exact=slug, parent__exact=folder_id)
31 raise validators.ValidationError(u'There is already a folder with that name')