1 from django.db import models
2 from content.content_val import is_unique_name
5 ('rst', 'reStructuredText'),
9 class Document(models.Model):
10 title = models.CharField(maxlength=150)
11 islive = models.BooleanField()
12 folder = models.ForeignKey('Folder', null=True, blank=True)
13 format = models.CharField(maxlength=10, choices=FORMAT_CHOICES)
14 slug = models.SlugField(prepopulate_from=("title",), validator_list=[is_unique_name,])
15 content = models.TextField()
18 return self.__unicode__()
20 def __unicode__(self):
21 return u'%s (%s)' %(self.title, self.slug)
24 super(Document, self).save()
25 # now check if we just set our selves to be live
28 otherdocs = Document.objects.filter(slug__exact=self.slug, islive__exact=True, folder__exact=self.folder).exclude(pk=self.id)
30 otherdocs = Document.objects.filter(slug__exact=self.slug, islive__exact=True, folder__isnull=True).exclude(pk=self.id)
38 class Folder(models.Model):
39 title = models.CharField(maxlength=150)
40 slug = models.SlugField(prepopulate_from=("title",))
41 parent = models.ForeignKey('self', null=True, blank=True)
44 return self.__unicode__()
46 def __unicode__(self):
47 return u'%s' %(self.title)