erang changes + meeting dict changes

This commit is contained in:
Sanj 2011-12-27 14:48:37 +05:30
parent bc61c2221c
commit c08158b56c
5 changed files with 43 additions and 3 deletions

View File

@ -27,6 +27,11 @@ class EmailerIssue(ItfModel):
'title': self.title '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): class EmailerArticle(models.Model):
issue = models.ForeignKey(EmailerIssue) issue = models.ForeignKey(EmailerIssue)
@ -41,6 +46,8 @@ class EmailerArticle(models.Model):
def __unicode__(self): def __unicode__(self):
return self.title return self.title
def get_images(self):
return self.articleimage_set.all()
class ArticleImage(models.Model): class ArticleImage(models.Model):
image = models.ImageField(upload_to='upload/images/emailer/') image = models.ImageField(upload_to='upload/images/emailer/')

View File

@ -62,6 +62,7 @@ class Meeting(ItfModel):
meeting_data['meeting'] = self meeting_data['meeting'] = self
meeting_id = self.id meeting_id = self.id
# meeting_data['sessions'] = Session.objects.filter(day__meeting__id=meeting_id) # get meetings session objs # 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['talks'] = Talk.objects.filter(session__day__meeting=self)
meeting_data['images'] = Image.objects.filter(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") 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): def __unicode__(self):
return "%s - %s" % (self.session.day.meeting.title, self.title) # name of meeting - name of session 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): class Session(models.Model):
title = models.CharField(max_length=255) title = models.CharField(max_length=255)
intro = models.TextField(blank=True, null=True) intro = models.TextField(blank=True, null=True)
@ -128,6 +139,14 @@ class Session(models.Model):
def __unicode__(self): def __unicode__(self):
return "%s - %s" % (self.day.meeting.title, self.title) # name of meeting - name of session 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): class MeetingDay(models.Model):
meeting = models.ForeignKey('Meeting') meeting = models.ForeignKey('Meeting')
meeting_date = models.DateField() meeting_date = models.DateField()
@ -135,6 +154,12 @@ class MeetingDay(models.Model):
def __unicode__(self): def __unicode__(self):
return "%s - %s" % (self.meeting, self.meeting_date) 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): class Audio(models.Model):
title = models.CharField(max_length=255) title = models.CharField(max_length=255)
intro = models.TextField(blank=True, null=True) intro = models.TextField(blank=True, null=True)

View File

@ -66,6 +66,7 @@ class ModelExtra(models.Model):
return self.friendly_name return self.friendly_name
class ModelSort(models.Model): class ModelSort(models.Model):
model = models.ForeignKey(ModelExtra) model = models.ForeignKey(ModelExtra)
operator = models.CharField(max_length=1, help_text="This should be either + or -.") operator = models.CharField(max_length=1, help_text="This should be either + or -.")

View File

@ -9,7 +9,7 @@ DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
JSON_DEBUG = DEBUG JSON_DEBUG = DEBUG
THUMBNAIL_DEBUG = True THUMBNAIL_DEBUG = False
LOCAL_DEVELOPMENT = True LOCAL_DEVELOPMENT = True
LOGGING_INTERCEPT_REDIRECTS = True LOGGING_INTERCEPT_REDIRECTS = True

View File

@ -1,4 +1,5 @@
{% load markup %} {% load markup %}
{% load thumbnail %}
<link rel="stylesheet" href="/static/css/modules/emailer.css" /> <link rel="stylesheet" href="/static/css/modules/emailer.css" />
<div id="wrapperEmailer"> <div id="wrapperEmailer">
@ -51,8 +52,14 @@
<div class="articleAuthor">by: {{ article.author }}</div><!-- ARTICLE TITLE CLOSING --> <div class="articleAuthor">by: {{ article.author }}</div><!-- ARTICLE TITLE CLOSING -->
<div class="clear"></div> <div class="clear"></div>
<div class="articleImg"><img src="logo-erang.jpg" width="151" height="127"></div><!-- ARTICLE IMAGE CLOSING --> {% if article.main_image %}
<div class="articleImg">
{% thumbnail article.main_image "570" as im %}
<img class="itfInfoImg" src="{{ im.url }}" />
{% endthumbnail %}
</div><!-- ARTICLE IMAGE CLOSING -->
{% endif %}
<div class="articleCaption">{{ article.subtitle }}</div><!-- ARTICLE CAPTION CLOSING --> <div class="articleCaption">{{ article.subtitle }}</div><!-- ARTICLE CAPTION CLOSING -->
<div class="articleText">{{ article.text|markdown }}</div> <div class="articleText">{{ article.text|markdown }}</div>
{% endfor %} {% endfor %}