From c08158b56caaf66a94da99378bb42c7e8a2bc5c1 Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 27 Dec 2011 14:48:37 +0530 Subject: [PATCH] erang changes + meeting dict changes --- itf/emailer/models.py | 7 ++++++ itf/festival/models.py | 25 +++++++++++++++++++ itf/insidepages/models.py | 1 + itf/settings.py | 2 +- .../modules/emailer/emailerissue.html | 11 ++++++-- 5 files changed, 43 insertions(+), 3 deletions(-) diff --git a/itf/emailer/models.py b/itf/emailer/models.py index 480cd55..f953754 100755 --- a/itf/emailer/models.py +++ b/itf/emailer/models.py @@ -27,6 +27,11 @@ class EmailerIssue(ItfModel): 'title': self.title } + def main_image(self): + for article in self.emailerarticle_set.all(): + if article.main_image: + return article.main_image + return None class EmailerArticle(models.Model): issue = models.ForeignKey(EmailerIssue) @@ -41,6 +46,8 @@ class EmailerArticle(models.Model): def __unicode__(self): return self.title + def get_images(self): + return self.articleimage_set.all() class ArticleImage(models.Model): image = models.ImageField(upload_to='upload/images/emailer/') diff --git a/itf/festival/models.py b/itf/festival/models.py index 72144a3..15d43fd 100755 --- a/itf/festival/models.py +++ b/itf/festival/models.py @@ -62,6 +62,7 @@ class Meeting(ItfModel): 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['days'] = [d.get_dict() for d in self.meetingday_set.all()] meeting_data['talks'] = Talk.objects.filter(session__day__meeting=self) meeting_data['images'] = Image.objects.filter(meeting=self) meeting_data['sessions'] = Session.objects.filter(day__meeting=self).order_by("day").order_by("session_no") @@ -119,6 +120,16 @@ class Talk(models.Model): def __unicode__(self): return "%s - %s" % (self.session.day.meeting.title, self.title) # name of meeting - name of session + def get_dict(self): + return { + 'title': self.title, + 'intro': self.intro, + 'presenter': self.presenter, + 'audios': self.audio_set.all(), + 'videos': self.video_set.all(), + 'documents': self.document_set.all() + } + class Session(models.Model): title = models.CharField(max_length=255) intro = models.TextField(blank=True, null=True) @@ -128,6 +139,14 @@ class Session(models.Model): def __unicode__(self): return "%s - %s" % (self.day.meeting.title, self.title) # name of meeting - name of session + def get_dict(self): + return { + 'title': self.title, + 'intro': self.intro, + 'session_no': self.session_no, + 'talks': [t.get_dict() for t in self.talk_set.all()] + } + class MeetingDay(models.Model): meeting = models.ForeignKey('Meeting') meeting_date = models.DateField() @@ -135,6 +154,12 @@ class MeetingDay(models.Model): def __unicode__(self): return "%s - %s" % (self.meeting, self.meeting_date) + def get_dict(self): + return { + 'date': self.meeting_date, + 'sessions': [s.get_dict() for s in self.session_set.all()] + } + class Audio(models.Model): title = models.CharField(max_length=255) intro = models.TextField(blank=True, null=True) diff --git a/itf/insidepages/models.py b/itf/insidepages/models.py index e5691d5..952ba43 100755 --- a/itf/insidepages/models.py +++ b/itf/insidepages/models.py @@ -66,6 +66,7 @@ class ModelExtra(models.Model): return self.friendly_name + class ModelSort(models.Model): model = models.ForeignKey(ModelExtra) operator = models.CharField(max_length=1, help_text="This should be either + or -.") diff --git a/itf/settings.py b/itf/settings.py index 6e087d0..7145757 100755 --- a/itf/settings.py +++ b/itf/settings.py @@ -9,7 +9,7 @@ DEBUG = True TEMPLATE_DEBUG = DEBUG JSON_DEBUG = DEBUG -THUMBNAIL_DEBUG = True +THUMBNAIL_DEBUG = False LOCAL_DEVELOPMENT = True LOGGING_INTERCEPT_REDIRECTS = True diff --git a/itf/templates/modules/emailer/emailerissue.html b/itf/templates/modules/emailer/emailerissue.html index 9390b28..49b2aea 100755 --- a/itf/templates/modules/emailer/emailerissue.html +++ b/itf/templates/modules/emailer/emailerissue.html @@ -1,4 +1,5 @@ {% load markup %} +{% load thumbnail %}
@@ -51,8 +52,14 @@
- -
+ + {% if article.main_image %} +
+ {% thumbnail article.main_image "570" as im %} + + {% endthumbnail %} +
+ {% endif %}
{{ article.subtitle }}
{{ article.text|markdown }}
{% endfor %}