--- a/web/views/baseviews.py Mon Mar 02 20:44:14 2009 +0100
+++ b/web/views/baseviews.py Mon Mar 02 21:03:54 2009 +0100
@@ -11,6 +11,8 @@
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
+#from __future__ import with_statement
+
__docformat__ = "restructuredtext en"
from warnings import warn
@@ -50,6 +52,21 @@
entities)
"""
id = 'final'
+ # record generated i18n catalog messages
+ _('%d years')
+ _('%d months')
+ _('%d weeks')
+ _('%d days')
+ _('%d hours')
+ _('%d minutes')
+ _('%d seconds')
+ _('%d years')
+ _('%d months')
+ _('%d weeks')
+ _('%d days')
+ _('%d hours')
+ _('%d minutes')
+ _('%d seconds')
def cell_call(self, row, col, props=None, displaytime=False, format='text/html'):
etype = self.rset.description[row][col]
@@ -61,23 +78,26 @@
self.w(entity.printable_value(rtype, value, format=format))
return
if etype in ('Time', 'Interval'):
- _ = self.req._
# value is DateTimeDelta but we have no idea about what is the
# reference date here, so we can only approximate years and months
+ if format == 'text/html':
+ space = ' '
+ else:
+ space = ' '
if value.days > 730: # 2 years
- self.w(_('%d years') % (value.days // 365))
+ self.w(self.req.__('%%d%syears' % space) % (value.days // 365))
elif value.days > 60: # 2 months
- self.w(_('%d months') % (value.days // 30))
+ self.w(self.req.__('%%d%smonths' % space) % (value.days // 30))
elif value.days > 14: # 2 weeks
- self.w(_('%d weeks') % (value.days // 7))
+ self.w(self.req.__('%%d%sweeks' % space) % (value.days // 7))
elif value.days > 2:
- self.w(_('%s days') % int(value.days))
+ self.w(self.req.__('%%d%sdays' % space) % int(value.days))
elif value.hours > 2:
- self.w(_('%s hours') % int(value.hours))
+ self.w(self.req.__('%%d%shours' % space) % int(value.hours))
elif value.minutes >= 2:
- self.w(_('%s minutes') % int(value.minutes))
+ self.w(self.req.__('%%d%sminutes' % space) % int(value.minutes))
else:
- self.w(_('%s seconds') % int(value.seconds))
+ self.w(self.req.__('%%d%sseconds' % space) % int(value.seconds))
return
self.wdata(printable_value(self.req, etype, value, props, displaytime=displaytime))
@@ -223,27 +243,43 @@
non-meta in a first step, meta in a second step
"""
if hasattr(self, 'get_side_boxes_defs'):
- for label, rset in self.get_side_boxes_defs(entity):
- if rset:
+ sideboxes = [(label, rset) for label, rset in self.get_side_boxes_defs(entity)
+ if rset]
+ if sideboxes:
+ self.w(u'<table width="100%">')
+ for label, rset in sideboxes:
+ self.w(u'<tr><td>')
self.w(u'<div class="sideRelated">')
self.wview('sidebox', rset, title=label)
self.w(u'</div>')
+ self.w(u'</td></tr>')
+ self.w(u'</table>')
elif siderelations:
+ self.w(u'<table width="100%">')
+ self.w(u'<tr><td>')
self.w(u'<div class="sideRelated">')
for relatedinfos in siderelations:
# if not relatedinfos[0].meta:
# continue
self._render_related_entities(entity, *relatedinfos)
self.w(u'</div>')
- for box in self.vreg.possible_vobjects('boxes', self.req, self.rset,
- row=self.row, view=self,
- context='incontext'):
- try:
- box.dispatch(w=self.w, row=self.row)
- except NotImplementedError:
- # much probably a context insensitive box, which only implements
- # .call() and not cell_call()
- box.dispatch(w=self.w)
+ self.w(u'</td></tr>')
+ self.w(u'</table>')
+ boxes = list(self.vreg.possible_vobjects('boxes', self.req, self.rset,
+ row=self.row, view=self,
+ context='incontext'))
+ if boxes:
+ self.w(u'<table width="100%">')
+ for box in boxes:
+ self.w(u'<tr><td>')
+ try:
+ box.dispatch(w=self.w, row=self.row)
+ except NotImplementedError:
+ # much probably a context insensitive box, which only implements
+ # .call() and not cell_call()
+ box.dispatch(w=self.w)
+ self.w(u'</td></tr>')
+ self.w(u'</table>')
def is_side_related(self, rschema, eschema):
return rschema.meta and \