add document subject stuff

This commit is contained in:
Sanj 2011-11-23 21:34:21 +05:30
parent 64756a1e58
commit 7384a183b1
3 changed files with 25 additions and 2 deletions

View File

@ -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)

View File

@ -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 = []