X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/blobdiff_plain/56b2cdf3569443cf4504fe085de9db0466dcd09f..46647a368631f22e961dfe2fdf9bcc0b64b2d281:/sommitrealweird/bpcms/content_val.py diff --git a/sommitrealweird/bpcms/content_val.py b/sommitrealweird/bpcms/content_val.py index 0e62150..3463d18 100644 --- a/sommitrealweird/bpcms/content_val.py +++ b/sommitrealweird/bpcms/content_val.py @@ -1,4 +1,20 @@ 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