Home | Trees | Indices | Help |
|
---|
|
1 """Calendar module for Zinnia templatetags""" 2 from datetime import date 3 from calendar import HTMLCalendar 4 5 from django.utils.dates import MONTHS 6 from django.utils.dates import WEEKDAYS_ABBR 7 from django.utils.formats import get_format 8 from django.core.urlresolvers import reverse 9 10 from zinnia.models import Entry 11 12 AMERICAN_TO_EUROPEAN_WEEK_DAYS = [6, 0, 1, 2, 3, 4, 5] 13 1416 """Override of HTMLCalendar""" 176319 """Retrieve and convert the localized first week day 20 at initialization""" 21 HTMLCalendar.__init__(self, AMERICAN_TO_EUROPEAN_WEEK_DAYS[ 22 get_format('FIRST_DAY_OF_WEEK')])2325 """Return a day as a table cell with a link 26 if entries are published this day""" 27 if day and day in self.day_entries: 28 day_date = date(self.current_year, self.current_month, day) 29 archive_day_url = reverse('zinnia_entry_archive_day', 30 args=[day_date.strftime('%Y'), 31 day_date.strftime('%m'), 32 day_date.strftime('%d')]) 33 return '<td class="%s entry"><a href="%s" '\ 34 'rel="archives">%d</a></td>' % ( 35 self.cssclasses[weekday], archive_day_url, day) 36 37 return super(ZinniaCalendar, self).formatday(day, weekday)3840 """Return a formatted month as a table with 41 new attributes computed for formatting a day""" 42 self.current_year = theyear 43 self.current_month = themonth 44 self.day_entries = [entries.creation_date.day for entries in 45 Entry.published.filter( 46 creation_date__year=theyear, 47 creation_date__month=themonth)] 48 49 return super(ZinniaCalendar, self).formatmonth( 50 theyear, themonth, withyear)5153 """Return a weekday name translated 54 as a table header.""" 55 return '<th class="%s">%s</th>' % (self.cssclasses[day], 56 WEEKDAYS_ABBR[day].title())5759 """Return a month name translated 60 as a table row.""" 61 monthname = '%s %s' % (MONTHS[themonth].title(), theyear) 62 return '<tr><th colspan="7" class="month">%s</th></tr>' % monthname
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Feb 22 09:38:55 2011 | http://epydoc.sourceforge.net |