1 from django.core import validators
3 def is_unique_name(slug, all_data):
4 from content.models import Document, Folder
5 if all_data["folder"] != '' and all_data["id"] == '':
6 folder_id = int(all_data["folder"])
8 doc = Document.object.get(folder__exact=folder_id, slug__exact=slug)
9 raise validators.ValidationError(u'There is already a document with that name')
14 folder = Folder.object.get(slug__exact=slug, parent__exact=folder_id)
15 raise validators.ValidationError(u'There is already a folder with that name')