web/views/editforms.py
changeset 5590 a56eb02f9ce7
parent 5557 1a534c596bff
parent 5583 24125df012f3
child 5658 7b9553a9db65
equal deleted inserted replaced
5578:6b9fee0c5c42 5590:a56eb02f9ce7
    15 #
    15 #
    16 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 """Set of HTML automatic forms to create, delete, copy or edit a single entity
    18 """Set of HTML automatic forms to create, delete, copy or edit a single entity
    19 or a list of entities of the same type
    19 or a list of entities of the same type
    20 
       
    21 """
    20 """
       
    21 
    22 __docformat__ = "restructuredtext en"
    22 __docformat__ = "restructuredtext en"
    23 _ = unicode
    23 _ = unicode
    24 
    24 
    25 from copy import copy
    25 from copy import copy
    26 
    26 
    27 from logilab.mtconverter import xml_escape
    27 from logilab.mtconverter import xml_escape
    28 from logilab.common.decorators import cached
    28 from logilab.common.decorators import cached
    29 
    29 
       
    30 from cubicweb import tags
    30 from cubicweb.selectors import (match_kwargs, one_line_rset, non_final_entity,
    31 from cubicweb.selectors import (match_kwargs, one_line_rset, non_final_entity,
    31                                 specified_etype_implements, implements, yes)
    32                                 specified_etype_implements, implements, yes)
    32 from cubicweb.view import EntityView
    33 from cubicweb.view import EntityView
    33 from cubicweb import tags
    34 from cubicweb.schema import display_name
    34 from cubicweb.web import uicfg, stdmsgs, eid_param, dumps, \
    35 from cubicweb.web import uicfg, stdmsgs, eid_param, dumps, \
    35      formfields as ff, formwidgets as fw
    36      formfields as ff, formwidgets as fw
    36 from cubicweb.web.form import FormViewMixIn, FieldNotFound
    37 from cubicweb.web.form import FormViewMixIn, FieldNotFound
    37 from cubicweb.web.views import forms
    38 from cubicweb.web.views import forms
    38 
    39 
   304         assert rtype
   305         assert rtype
   305         assert role in ('subject', 'object'), '%s is not an acceptable role value' % role
   306         assert role in ('subject', 'object'), '%s is not an acceptable role value' % role
   306         self._cw.add_js('cubicweb.edition.js')
   307         self._cw.add_js('cubicweb.edition.js')
   307         self._cw.add_css('cubicweb.form.css')
   308         self._cw.add_css('cubicweb.form.css')
   308         if default is None:
   309         if default is None:
   309             default = xml_escape(self._cw._('<no value>'))
   310             default = xml_escape(self._cw._('<%s not specified>')
       
   311                                  % display_name(self._cw, rtype, role))
   310         schema = self._cw.vreg.schema
   312         schema = self._cw.vreg.schema
   311         entity = self.cw_rset.get_entity(row, col)
   313         entity = self.cw_rset.get_entity(row, col)
   312         rschema = schema.rschema(rtype)
   314         rschema = schema.rschema(rtype)
   313         lzone = self._build_landing_zone(landing_zone)
   315         lzone = self._build_landing_zone(landing_zone)
   314         # compute value, checking perms, build form
   316         # compute value, checking perms, build form