timeline view minor enhancements stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Fri, 01 Oct 2010 09:25:39 +0200
branchstable
changeset 6372 4c3e2a92e340
parent 6369 a151453dc564
child 6373 41793f2718ce
child 6374 5adf53edfe12
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
web/data/cubicweb.widgets.js
web/views/timeline.py
--- 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);
--- 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