# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1241044537 -7200 # Node ID 68c69980f6a173066ae3e6b2aff6cccf87b8e669 # Parent 53d3d783370f2b3f9b70a03bb7c619763c5a5cbe use datetime diff -r 53d3d783370f -r 68c69980f6a1 goa/skel/views.py --- a/goa/skel/views.py Wed Apr 29 18:56:53 2009 +0200 +++ b/goa/skel/views.py Thu Apr 30 00:35:37 2009 +0200 @@ -1,10 +1,8 @@ # custom application views - -from mx.DateTime import DateTime +from calendar import monthrange +from datetime import date -from cubicweb.web.views import baseviews -from cubicweb.web.views.boxes import BoxTemplate -from cubicweb.web.views.calendar import MONTHNAMES +from cubicweb.web.views import baseviews, boxes, calendar from cubicweb.web.htmlwidgets import BoxLink, BoxWidget _ = unicode @@ -12,15 +10,15 @@ class BlogEntryPrimaryView(baseviews.PrimaryView): accepts = ('BlogEntry',) - + def cell_call(self, row, col): entity = self.entity(row, col) self.w(u'

%s

' % entity.dc_title()) entity.view('metadata', w=self.w) self.w(entity.printable_value('text')) - + -class BlogArchiveBox(BoxTemplate): +class BlogArchiveBox(boxes.BoxTemplate): """side box usually displaying some related entities in a primary view""" id = 'blog_archives_box' title = _('blog archives') @@ -37,12 +35,12 @@ blogmonths.append( (year, month) ) box = BoxWidget(_('Blog archives'), id=self.id) for year, month in blogmonths: - firstday = DateTime(year, month, 1) - lastday = DateTime(year, month, firstday.days_in_month) + firstday = date(year, month, 1) + lastday = date(year, month, monthrange(year, month)[1]) rql = ('Any B WHERE B is BlogEntry, B creation_date >= "%s", B creation_date <= "%s"' % (firstday.strftime('%Y-%m-%d'), lastday.strftime('%Y-%m-%d'))) url = self.build_url(rql=rql) - label = u'%s %s' % (_(MONTHNAMES[month-1]), year) + label = u'%s %s' % (_(calendar.MONTHNAMES[month-1]), year) box.append( BoxLink(url, label) ) box.render(self.w)