aboutsummaryrefslogtreecommitdiffstats
path: root/bn_django
diff options
context:
space:
mode:
authorbnewbold <bnewbold@eta.mit.edu>2009-01-23 02:24:14 -0500
committerbnewbold <bnewbold@eta.mit.edu>2009-01-23 02:24:14 -0500
commitf9305457e75542195cd8a162be2b9ef0e1d92f63 (patch)
tree0086c74ee980d4b545a50a95d7183305ccd57d22 /bn_django
parent396ece4ee47af923c619dbf21b041dc6132c0139 (diff)
downloadbnewnet-f9305457e75542195cd8a162be2b9ef0e1d92f63.tar.gz
bnewnet-f9305457e75542195cd8a162be2b9ef0e1d92f63.zip
journal prog prog
Diffstat (limited to 'bn_django')
-rw-r--r--bn_django/journal/models.py97
-rw-r--r--bn_django/journal/urls.py12
-rw-r--r--bn_django/settings.py.example1
3 files changed, 77 insertions, 33 deletions
diff --git a/bn_django/journal/models.py b/bn_django/journal/models.py
index 89392b2..962efee 100644
--- a/bn_django/journal/models.py
+++ b/bn_django/journal/models.py
@@ -1,56 +1,87 @@
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)
+ 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)
+ class Meta:
+ get_latest_by = 'date'
+ ordering = ['-date']
+
class JournalCommon(models.Model):
- author =
- date
- edit_date
- subjournal
- defunct
- private
+ author = User("User who created this")
+ date = models.DateTimeField("associated day", auto_now=True)
+ last_edited = models.DateField("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():
- html_content
- title
- slug
+class Entry(JournalCommon):
+ html_content = models.TextField("html format content", blank=False)
+ title = models.CharField("entry title", max_length=384)
+ slug = models.SlugField()
-class MicroEntry(models.Model):
- html_content
- text_content
+class MicroEntry(JournalCommon):
+ html_content = models.TextField("html format content", blank=False)
+ text_content = models.TextField("text version of content", blank=True,null=True)
-class Artifact(models.Model)
- html_caption
- entry
+class Artifact(JournalCommon):
+ html_caption = models.TextField("html format caption", blank=False)
+ text_caption = models.TextField("text format caption", blank=True,null=True)
+ entry = models.ForeignKey(Entry, blank=True)
+ title = models.CharField("title of the artifact", max_length=256, blank=True)
class Meta:
abstract = True
-class ImageArtifact(Artifact)
- original_file
- thumb_file
- pass
+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 VideoArtifact(Artifact)
- codec
- filepath
- external_url
- pass
+class CodeArtifact(Artifact):
+ code = models.TextField("raw source code", blank=False)
+ language = models.CharField("what programming language", max_length=160, \
+ blank=True)
-class CodeArtifact(Artifact)
- code
- language
- pass
+class LinkArtifact(Artifact):
+ url = models.URLField("external link to something wonderful!", blank=True)
-class LinkArtifact(Artifact)
- url
+class ImageArtifact(Artifact,Photo):
+ """Multiply inherets from the photo app
+ """
pass
+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)
+
+from django.contrib import admin
+admin.site.register(Entry)
+admin.site.register(MicroEntry)
+admin.site.register(SubJournal)
+admin.site.register(Artifact)
+admin.site.register(LinkArtifact)
+admin.site.register(CodeArtifact)
+admin.site.register(VideoArtifact)
+admin.site.register(ImageArtifact)
diff --git a/bn_django/journal/urls.py b/bn_django/journal/urls.py
new file mode 100644
index 0000000..d65d52a
--- /dev/null
+++ b/bn_django/journal/urls.py
@@ -0,0 +1,12 @@
+from django.conf.urls.defaults import *
+from django.conf import settings
+
+from models import Entry, MicroEntry, Artifact
+
+urlpatterns = patterns('django.views.generic.list_detail',
+ (r'^$', 'object_list',
+ dict(queryset=Entry.objects.order_by('-date'),
+ paginate_by=35, allow_empty=False)),
+ (r'^(?P<slug>)/$', 'object_detail',
+ dict(info_dict, queryset=Entry.objects.all(), slug_field='slug')),
+)
diff --git a/bn_django/settings.py.example b/bn_django/settings.py.example
index d9e3198..6ce8f3f 100644
--- a/bn_django/settings.py.example
+++ b/bn_django/settings.py.example
@@ -85,4 +85,5 @@ INSTALLED_APPS = (
'bn_django.photos',
'bn_django.git_wiki',
'bn_django.git_browse',
+ 'bn_django.journal',
)