from django.core import validators
+from django.conf import settings
+
+def is_allowed_name(slug, all_data):
+ from bpcms.models import Document, Folder
+ folder = None
+ if all_data.has_key('folder'):
+ folder = all_data['folder']
+ elif all_data.has_key('parent'):
+ folder = all_data['parent']
+ if folder == u'':
+ folder = None
+ if folder == None:
+ # right - we're at the root.
+ if slug in settings.BPCMS_DISALLOWED_ROOT_DOC_NAMES \
+ or slug in ['cms-admin']:
+ raise validators.ValidationError(u'That slug is reserved')
def is_unique_name(slug, all_data):
from bpcms.models import Document, Folder