X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/blobdiff_plain/c2e85644c4128b2545fd4bbe0382f4e2e502bd83..56b2cdf3569443cf4504fe085de9db0466dcd09f:/sommitrealweird/content/models.py diff --git a/sommitrealweird/content/models.py b/sommitrealweird/content/models.py deleted file mode 100644 index 6487830..0000000 --- a/sommitrealweird/content/models.py +++ /dev/null @@ -1,50 +0,0 @@ -from django.db import models -from content.content_val import is_unique_name - -FORMAT_CHOICES = ( - ('rst', 'reStructuredText'), - ('html', 'HTML'), - ) - -class Document(models.Model): - title = models.CharField(maxlength=150) - islive = models.BooleanField() - folder = models.ForeignKey('Folder', null=True, blank=True) - format = models.CharField(maxlength=10, choices=FORMAT_CHOICES) - slug = models.SlugField(prepopulate_from=("title",), validator_list=[is_unique_name,]) - content = models.TextField() - - def __str__(self): - return self.__unicode__() - - def __unicode__(self): - return u'%s (%s)' %(self.title, self.slug) - - def save(self): - super(Document, self).save() - # now check if we just set our selves to be live - if self.islive: - if self.folder: - otherdocs = Document.objects.filter(slug__exact=self.slug, islive__exact=True, folder__exact=self.folder).exclude(pk=self.id) - else: - otherdocs = Document.objects.filter(slug__exact=self.slug, islive__exact=True, folder__isnull=True).exclude(pk=self.id) - for doc in otherdocs: - doc.islive = False - doc.save() - - class Admin: - pass - -class Folder(models.Model): - title = models.CharField(maxlength=150) - slug = models.SlugField(prepopulate_from=("title",)) - parent = models.ForeignKey('self', null=True, blank=True) - - def __str__(self): - return self.__unicode__() - - def __unicode__(self): - return u'%s' %(self.title) - - class Admin: - pass