web/views/navigation.py
changeset 8015 b9de628f90e6
parent 8009 75638a6ff159
child 8054 11b6589352b6
equal deleted inserted replaced
8014:6ce4ff44b2cf 8015:b9de628f90e6
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 """navigation components definition for CubicWeb web client"""
    18 """navigation components definition for CubicWeb web client"""
    19 
    19 
    20 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    21 _ = unicode
    21 _ = unicode
       
    22 
       
    23 from datetime import datetime
    22 
    24 
    23 from rql.nodes import VariableRef, Constant
    25 from rql.nodes import VariableRef, Constant
    24 
    26 
    25 from logilab.mtconverter import xml_escape
    27 from logilab.mtconverter import xml_escape
    26 from logilab.common.deprecation import deprecated
    28 from logilab.common.deprecation import deprecated
   149             else:
   151             else:
   150                 # no relation but maybe usable anyway if selected
   152                 # no relation but maybe usable anyway if selected
   151                 col = var.selected_index()
   153                 col = var.selected_index()
   152                 attrname = None
   154                 attrname = None
   153             if col is not None:
   155             if col is not None:
       
   156                 # if column type is date[time], set proper 'nb_chars'
       
   157                 if var.stinfo['possibletypes'] & frozenset(('TZDatetime', 'Datetime',
       
   158                                                             'Date')):
       
   159                     self.nb_chars = len(self._cw.format_date(datetime.today()))
   154                 index_display = self.display_func(rset, col, attrname)
   160                 index_display = self.display_func(rset, col, attrname)
   155                 break
   161                 break
   156         else:
   162         else:
   157             # nothing usable found, use the first column
   163             # nothing usable found, use the first column
   158             index_display = self.display_func(rset, 0, None)
   164             index_display = self.display_func(rset, 0, None)