From c4720f02a13bce563e5368bc370fcb1e4e0bf0bf Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 4 Mar 2012 13:06:53 +0530 Subject: [PATCH] add meeting performance stuff --- itf/festival/admin.py | 10 ++++++++++ itf/festival/models.py | 32 +++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/itf/festival/admin.py b/itf/festival/admin.py index eb05573..e43fb74 100755 --- a/itf/festival/admin.py +++ b/itf/festival/admin.py @@ -18,6 +18,10 @@ class DocumentInline(admin.StackedInline): model = Document extra = 2 +class MeetingPerformanceImageInline(admin.StackedInline): + model = MeetingPerformanceImage + extra = 3 + class PadmaVideoAdmin(admin.ModelAdmin): pass @@ -44,6 +48,11 @@ class MeetingAdmin(admin.ModelAdmin): prepopulated_fields = {"slug": ("title",)} save_on_top = True +class MeetingPerformanceAdmin(admin.ModelAdmin): + inlines = [MeetingPerformanceImageInline] + search_fields = ('title', 'synopsis',) + save_on_top = True + class ProjectAdmin(admin.ModelAdmin): formfield_overrides = {models.TextField: {'widget': MarkItUpWidget}} prepopulated_fields = {"slug": ("title",)} @@ -100,4 +109,5 @@ admin.site.register(Session, SessionAdmin) admin.site.register(Talk, TalkAdmin) admin.site.register(Participant, ParticipantAdmin) admin.site.register(Signup, SignupAdmin) +admin.site.register(MeetingPerformance, MeetingPerformanceAdmin) admin.site.register(CommentCaptcha) diff --git a/itf/festival/models.py b/itf/festival/models.py index 043524e..c35d23c 100755 --- a/itf/festival/models.py +++ b/itf/festival/models.py @@ -68,7 +68,7 @@ class Meeting(ItfModel): meeting_data['images'] = Image.objects.filter(meeting=self) meeting_data['sessions'] = Session.objects.filter(day__meeting=self).order_by("day").order_by("session_no") meeting_data['documents'] = Document.objects.filter(meeting__id=meeting_id).exclude(talk__isnull=False) - + meeting_data['performances'] = [p.get_dict() for p in MeetingPerformance.objects.filter(meeting_day__meeting=self)] 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: @@ -150,6 +150,36 @@ class Session(models.Model): 'talks': [t.get_dict() for t in self.talk_set.all()] } + +class MeetingPerformance(models.Model): + title = models.CharField(max_length=512) + performed_by = models.CharField(max_length=512, blank=True) + synopsis = models.TextField(blank=True) + time = models.TimeField(null=True, blank=True) + meeting_day = models.ForeignKey("MeetingDay") + + def get_dict(self): + return { + 'title': self.title, + 'performed_by': self.performed_by, + 'synopsis': self.synopsis, + #'time': FIXME + 'images': [i for i in MeetingPerformanceImage.objects.filter(performance=self)] + } + + def __unicode__(self): + return self.title + + +class MeetingPerformanceImage(models.Model): + performance = models.ForeignKey(MeetingPerformance) + image = models.ImageField(upload_to='upload/images/') + caption = models.CharField(max_length=512, blank=True) + + def __unicode__(self): + return self.caption + + class MeetingDay(models.Model): meeting = models.ForeignKey('Meeting') meeting_date = models.DateField()