From 7384a183b1a4495b55bea4e92d70059a038a3e91 Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 23 Nov 2011 21:34:21 +0530 Subject: [PATCH] add document subject stuff --- itf/festival/admin.py | 3 ++- itf/festival/models.py | 24 ++++++++++++++++++- .../modules/festival/documentsubject.html | 0 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 itf/templates/modules/festival/documentsubject.html diff --git a/itf/festival/admin.py b/itf/festival/admin.py index 7150825..8495132 100755 --- a/itf/festival/admin.py +++ b/itf/festival/admin.py @@ -81,7 +81,8 @@ admin.site.register(Audio, AudioAdmin) admin.site.register(Video, VideoAdmin) admin.site.register(Image, ImageAdmin) admin.site.register(PadmaVideo, PadmaVideoAdmin) -admin.site.register(Document) +admin.site.register(Document) +admin.site.register(DocumentSubject) admin.site.register(Project, ProjectAdmin) #admin.site.register(MeetingDay) admin.site.register(Session, SessionAdmin) diff --git a/itf/festival/models.py b/itf/festival/models.py index 86c9343..cd435b0 100755 --- a/itf/festival/models.py +++ b/itf/festival/models.py @@ -166,6 +166,28 @@ class Image(models.Model): def __unicode__(self): return self.title + + +class DocumentSubject(ItfModel): + title = models.CharField(max_length=255) + main_image = models.ImageField(upload_to='upload/images/festival/main/', blank=True, null=True) + + def __unicode__(self): + return self.title + + def list_dict(self): + return { + 'id': self.id, + 'title': self.title + } + + def info_dict(self): + return { + 'id': self.id, + 'title': self.title, + 'documents': [d.info_dict() for d in Document.objects.filter(subject=self)] + } + class Document(ItfModel): title = models.CharField(max_length=255) intro = RichTextField(blank=True, null=True) @@ -173,7 +195,7 @@ class Document(ItfModel): meeting = models.ForeignKey('Meeting', blank=True, null=True) talk = models.ForeignKey('Talk', blank=True, null=True) is_resource = models.BooleanField() - + subject = models.ForeignKey('DocumentSubject', blank=True, null=True) fts_fields = ['title', 'intro'] fk_filters = [] diff --git a/itf/templates/modules/festival/documentsubject.html b/itf/templates/modules/festival/documentsubject.html new file mode 100644 index 0000000..e69de29