diff options
Diffstat (limited to 'bn_django/journal/models.py')
-rw-r--r-- | bn_django/journal/models.py | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/bn_django/journal/models.py b/bn_django/journal/models.py deleted file mode 100644 index a4402b2..0000000 --- a/bn_django/journal/models.py +++ /dev/null @@ -1,98 +0,0 @@ -from django.db import models -from django.dispatch import dispatcher -from django.db.models import signals -from django.contrib.auth.models import User, AnonymousUser -from bn_django.photos.models import Photo - -class SubJournal(models.Model): - name = models.CharField("full title", blank=False,max_length=196) - date = models.DateField("date started", auto_now_add=True) - slug = models.SlugField() - description = models.TextField("description of content",blank=True) - - def __unicode__(self): - return self.name - - class Meta: - get_latest_by = 'date' - ordering = ['-date'] - -class JournalCommon(models.Model): - author = User("User who created this") - date = models.DateTimeField("associated day", auto_now=True) - last_edited = models.DateTimeField("day last edited", auto_now_add=True) - subjournal = models.ForeignKey(SubJournal,blank=True,null=True) - defunct = models.BooleanField("is this entry all around done with?",default=False,blank=False) - private = models.BooleanField("is this entry for validated users only?",default=False,blank=False) - - class Meta: - abstract = True - get_latest_by = 'date' - ordering = ['-date'] - -class Entry(JournalCommon): - html_content = models.TextField("html format content", blank=False) - title = models.CharField("entry title", max_length=384) - slug = models.SlugField() - - def __unicode__(self): - return self.title - - def get_absolute_url(self): - #return "/journal/entries/%04d/%02d/%02d/%s/"%(self.date.year, self.date.month, self.date.day, self.slug) - return "/journal/entries/%s/"%self.slug - -class MicroEntry(JournalCommon): - html_content = models.TextField("html format content", blank=False) - text_content = models.TextField("text version of content", blank=True,null=True) - - def __unicode__(self): - return self.html_content[:50] - - def get_absolute_url(self): - return "/journal/microentries/%s/"%self.id - #return "/journal/microentries/%04d/%02d/%02d/%s/"%(self.date.year, self.date.month, self.date.day, self.slug) - -class Artifact(JournalCommon): - html_caption = models.TextField("html format caption", blank=True) - text_caption = models.TextField("text format caption", blank=True) - entry = models.ForeignKey(Entry, blank=True, null=True) - title = models.CharField("title of the artifact", max_length=256, blank=True) - - class Meta: - abstract = True - -class VideoArtifact(Artifact): - codec = models.CharField("what codec/format the video is", max_length=384) - filepath = models.FileField(upload_to="artifacts/%Y/%m/") - external_url = models.URLField("external representation to reduce bandwidth (youtube, etc)", blank=True) - -class CodeArtifact(Artifact): - code = models.TextField("raw source code", blank=False) - language = models.CharField("what programming language", max_length=160, \ - blank=True) - -class LinkArtifact(Artifact): - url = models.URLField("external link to something wonderful!",verify_exists=False) - - def __unicode__(self): - return self.title - - def get_absolute_url(self): - return "/artifacts/links/%s/"% self.id - -class ImageArtifact(Artifact,Photo): - """Multiply inherets from the photo app - """ - -def build_display_images(sender, instance, signal, *args, **kwargs): - """Simple hook for save-after trigger - """ - instance.build_display_images() -def delete_thumbnails(sender, instance, signal, *args, **kwargs): - """Simple hook for pre-delete trigger. - """ - instance.delete_thumbnails() - -signals.post_save.connect(build_display_images, sender=ImageArtifact) -signals.pre_delete.connect(delete_thumbnails, sender=ImageArtifact) |