add meeting performance stuff

This commit is contained in:
Sanj 2012-03-04 13:06:53 +05:30
parent ddf7de3840
commit c4720f02a1
2 changed files with 41 additions and 1 deletions

View File

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

View File

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