accept a default value for empty attributes/relations tls-sprint
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 12 May 2009 19:58:55 +0200
branchtls-sprint
changeset 1762 1f7bb0cd950c
parent 1761 fef5d4b4f511
child 1763 65ec5ccc8927
accept a default value for empty attributes/relations
web/views/editforms.py
--- a/web/views/editforms.py	Tue May 12 19:21:42 2009 +0200
+++ b/web/views/editforms.py	Tue May 12 19:58:55 2009 +0200
@@ -94,18 +94,18 @@
     ondblclick = "showInlineEditionForm(%(eid)s, '%(rtype)s', '%(divid)s')"
 
     def cell_call(self, row, col, rtype=None, role='subject', reload=False,
-                  vid='textoutofcontext'):
+                  vid='textoutofcontext', default=u''):
         """display field to edit entity's `rtype` relation on double-click"""
         rschema = self.schema.rschema(rtype)
         entity = self.entity(row, col)
         if rschema.is_final():
             if getattr(entity, rtype) is None:
-                value = self.req._('not specified')
+                value = default or self.req._('not specified')
             else:
                 value = entity.printable_value(rtype)
         else:
             rset = entity.related(rtype, role)
-            value = self.view(vid, rset, 'null')
+            value = self.view(vid, rset, 'null') or default
         if not entity.has_perm('update'):
             self.w(value)
             return