it/itf/festival/models.py

243 lines
6.9 KiB
Python
Raw Normal View History

2010-03-03 14:28:00 +00:00
from django.db import models
import datetime
import time
2010-11-26 00:52:54 +00:00
from ckeditor.fields import RichTextField
2011-01-04 06:27:10 +00:00
from app.models import ItfModel
2010-03-03 14:28:00 +00:00
class Comment(models.Model):
name = models.CharField(max_length=255)
email = models.EmailField(max_length=255)
comment = models.TextField()
is_displayed = models.BooleanField(default=True)
meeting = models.ForeignKey('Meeting')
parent = models.ForeignKey('Comment', default=0, related_name='child')
posted_date = models.DateTimeField(default=datetime.datetime.now())
def __unicode__(self):
return "%s by %s on %s" % (self.comment, self.name, self.posted_date,)
def epoch_date(self):
return time.mktime(self.posted_date.timetuple())
class CommentCaptcha(models.Model):
question = models.CharField(max_length=500)
answer = models.CharField(max_length=10)
def __unicode__(self):
return self.question
#Not using this class right now - but use this as a constant reminder ...
# class CommentVote(models.Model):
2011-01-04 06:27:10 +00:00
class Meeting(ItfModel):
2010-03-03 14:28:00 +00:00
title = models.CharField(max_length=255)
intro = models.TextField(blank=True, null=True)
slug = models.SlugField()
2011-01-04 06:27:10 +00:00
fts_fields = ['title', 'intro']
2010-03-03 14:28:00 +00:00
2011-09-09 23:13:27 +00:00
def preview_dict(self):
return {
'id': self.id,
'title': self.title,
}
2010-03-03 14:28:00 +00:00
def __unicode__(self):
return self.title
2011-09-10 02:28:23 +00:00
def list_dict(self):
return self.preview_dict()
2011-10-10 10:30:18 +00:00
def main_image(self):
img = Image.objects.filter(meeting=self)[0]
return img.file
2011-09-09 23:13:27 +00:00
def info_dict(self):
meeting_data = {}
meeting_data['meeting'] = self
meeting_id = self.id
# meeting_data['sessions'] = Session.objects.filter(day__meeting__id=meeting_id) # get meetings session objs
meeting_data['talks'] = Talk.objects.filter(session__day__meeting__id=meeting_id)
meeting_data['images'] = Image.objects.filter(meeting__id=meeting_id)
meeting_data['sessions'] = Session.objects.filter(day__meeting__id=meeting_id).order_by("day").order_by("session_no")
meeting_data['documents'] = Document.objects.filter(meeting__id=meeting_id).exclude(talk__isnull=False)
for s in meeting_data['sessions']:
s.talks = Talk.objects.select_related('image', 'audio', 'document').filter(session__id=s.id)
for t in s.talks:
t.images = Image.objects.filter(talk__id=t.id)
t.documents = Document.objects.filter(talk__id=t.id)
t.audio = Audio.objects.filter(talk__id=t.id)
t.video = Video.objects.filter(talk__id=t.id)
meeting_data['imagegallery'] = Image.objects.filter(meeting__id=meeting_id)
meeting_data['participants'] = Participant.objects.filter(meeting__id=meeting_id).order_by('name')
return meeting_data
2011-09-10 02:35:18 +00:00
class Participant(ItfModel):
2010-03-03 14:28:00 +00:00
name = models.CharField(max_length=255)
title = models.CharField(max_length=255, blank=True, null=True)
short_bio = models.TextField(max_length=255, blank=True, null=True)
meeting = models.ForeignKey('Meeting')
def __unicode__(self):
return self.name
2011-09-10 03:03:22 +00:00
def get_title(self):
2011-09-28 11:27:19 +00:00
return self.name
2011-09-10 03:03:22 +00:00
2011-09-10 02:35:18 +00:00
def list_dict(self):
return {
'id': self.id,
2011-09-10 02:40:44 +00:00
'title': self.name
2011-09-10 02:35:18 +00:00
}
def info_dict(self):
return {
'id': self.id,
2011-09-10 02:40:44 +00:00
'name': self.name,
2011-09-10 02:35:18 +00:00
'title': self.title,
2011-09-10 03:03:22 +00:00
'short_bio': self.short_bio
2011-09-10 02:35:18 +00:00
}
2010-03-03 14:28:00 +00:00
class Talk(models.Model):
title = models.CharField(max_length=255)
intro = models.TextField(blank=True, null=True)
presenter = models.CharField(max_length=255)
session = models.ForeignKey('Session') # name of meeting - name of session
def __unicode__(self):
return "%s - %s" % (self.session.day.meeting.title, self.title) # name of meeting - name of session
class Session(models.Model):
title = models.CharField(max_length=255)
intro = models.TextField(blank=True, null=True)
day = models.ForeignKey('MeetingDay')
session_no = models.IntegerField(blank=True, null=True)
def __unicode__(self):
return "%s - %s" % (self.day.meeting.title, self.title) # name of meeting - name of session
class MeetingDay(models.Model):
meeting = models.ForeignKey('Meeting')
meeting_date = models.DateField()
def __unicode__(self):
return "%s - %s" % (self.meeting, self.meeting_date)
class Audio(models.Model):
title = models.CharField(max_length=255)
intro = models.TextField(blank=True, null=True)
file = models.FileField(upload_to='upload/audio')
meeting = models.ForeignKey('Meeting', blank=True, null=True)
talk = models.ForeignKey('Talk', blank=True, null=True)
class Meta:
verbose_name_plural = "Audio"
def __unicode__(self):
return self.title
class Video(models.Model):
title = models.CharField(max_length=255)
intro = models.TextField(blank=True, null=True)
file = models.FileField(upload_to='upload/video')
meeting = models.ForeignKey('Meeting', blank=True, null=True)
talk = models.ForeignKey('Talk', blank=True, null=True)
def __unicode__(self):
return self.title
2010-05-14 02:33:11 +00:00
class PadmaVideo(models.Model):
padma_id = models.CharField(max_length=50)
talk = models.ForeignKey('Talk')
def __unicode__(self):
return self.padma_id
2010-03-03 14:28:00 +00:00
class Image(models.Model):
title = models.CharField(max_length=255)
intro = models.TextField(blank=True, null=True)
file = models.FileField(upload_to='upload/images')
meeting = models.ForeignKey('Meeting', blank=True, null=True)
talk = models.ForeignKey('Talk', blank=True, null=True)
def __unicode__(self):
return self.title
2011-04-10 02:00:43 +00:00
class Document(ItfModel):
2010-03-03 14:28:00 +00:00
title = models.CharField(max_length=255)
2010-11-26 00:52:54 +00:00
intro = RichTextField(blank=True, null=True)
2011-01-19 10:10:29 +00:00
file = models.FileField(upload_to='upload/docs', blank=True, null=True)
2010-03-03 14:28:00 +00:00
meeting = models.ForeignKey('Meeting', blank=True, null=True)
talk = models.ForeignKey('Talk', blank=True, null=True)
is_resource = models.BooleanField()
2011-10-04 17:17:55 +00:00
2011-04-10 02:00:43 +00:00
fts_fields = ['title', 'intro']
fk_filters = []
sort_fields = ['title']
2011-10-24 03:12:01 +00:00
2011-04-10 02:00:43 +00:00
def preview_dict(self):
return {
'id': self.id,
'title': self.title,
'intro': self.intro,
'file': self.file.url
}
def list_dict(self):
return {
'id': self.id,
'title': self.title
}
def info_dict(self):
return self.preview_dict()
2010-03-03 14:28:00 +00:00
def __unicode__(self):
return self.title
2011-09-09 23:13:27 +00:00
@classmethod
def get_qset(kls):
return kls.objects.filter(is_resource=True)
2011-04-10 02:00:43 +00:00
class Project(ItfModel):
2010-03-03 14:28:00 +00:00
title = models.CharField(max_length=255)
intro = models.TextField(blank=True, null=True)
start_date = models.DateField(blank=True, null=True)
end_date = models.DateField(blank=True, null=True)
slug = models.SlugField()
2011-04-10 02:00:43 +00:00
fts_fields = ['title', 'intro']
fk_filters = []
sort_fields = ['title', 'start_date']
def preview_dict(self):
return {
'id': self.id,
'title': self.title,
'intro': self.intro
}
def info_dict(self):
return self.preview_dict()
def list_dict(self):
return {
'id': self.id,
'title': self.title
}
2010-03-03 14:28:00 +00:00
def __unicode__(self):
return self.title
class Signup(models.Model):
email = models.EmailField()
def __unicode__(self):
return self.email