X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/blobdiff_plain/56b2cdf3569443cf4504fe085de9db0466dcd09f..525b287d2a1c652749f6e175568695907ac3a65b:/sommitrealweird/bpcms/content_val.py?ds=sidebyside 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