# HG changeset patch # User Alexandre Fayolle # Date 1285917939 -7200 # Node ID 4c3e2a92e3407a9ae9a48d7f375d557f7d42b8c6 # Parent a151453dc5648d3bae4dd46fc26a1e2090fcc6ce timeline view minor enhancements * support dates < 1900 by using logilab.common.date.ustrftime * make the timeline a public member of the TimeLineWidget * let buildWidget return the created widget, so that we can manipulate it later diff -r a151453dc564 -r 4c3e2a92e340 web/data/cubicweb.widgets.js --- a/web/data/cubicweb.widgets.js Thu Sep 30 15:00:30 2010 +0200 +++ b/web/data/cubicweb.widgets.js Fri Oct 01 09:25:39 2010 +0200 @@ -20,8 +20,9 @@ function buildWidget(wdgnode) { var wdgclass = Widgets[wdgnode.getAttribute('cubicweb:wdgtype')]; if (wdgclass) { - var wdg = new wdgclass(wdgnode); + return new wdgclass(wdgnode); } + return null; } /** @@ -312,7 +313,7 @@ intervalPixels: 100 }; var bandInfos = [Timeline.createBandInfo(bandData)]; - var tl = Timeline.create(tldiv, bandInfos); + this.tl = Timeline.create(tldiv, bandInfos); var loadurl = wdgnode.getAttribute('cubicweb:loadurl'); Timeline.loadJSON(loadurl, function(json, url) { eventSource.loadJSON(json, url); diff -r a151453dc564 -r 4c3e2a92e340 web/views/timeline.py --- a/web/views/timeline.py Thu Sep 30 15:00:30 2010 +0200 +++ b/web/views/timeline.py Fri Oct 01 09:25:39 2010 +0200 @@ -23,6 +23,7 @@ __docformat__ = "restructuredtext en" from logilab.mtconverter import xml_escape +from logilab.common.date import ustrftime from cubicweb.selectors import adaptable from cubicweb.view import EntityView, StartupView @@ -80,7 +81,7 @@ start = start or stop if start is None and stop is None: return None - event_data = {'start': start.strftime(self.date_fmt), + event_data = {'start': ustrftime(start, self.date_fmt), 'title': xml_escape(entity.dc_title()), 'description': entity.dc_description(format='text/html'), 'link': entity.absolute_url(), @@ -89,7 +90,7 @@ if onclick: event_data['onclick'] = onclick if stop: - event_data['end'] = stop.strftime(self.date_fmt) + event_data['end'] = ustrftime(stop, self.date_fmt) return event_data