--- a/web/views/editforms.py Thu Sep 17 15:52:46 2009 +0200
+++ b/web/views/editforms.py Tue Sep 22 12:11:12 2009 +0200
@@ -326,11 +326,9 @@
def call(self, **kwargs):
"""creation view for an entity"""
+ # at this point we know etype is a valid entity type, thanks to our
+ # selector
etype = kwargs.pop('etype', self.req.form.get('etype'))
- try:
- etype = self.vreg.case_insensitive_etypes[etype.lower()]
- except KeyError:
- raise RequestError(self.req._('no such entity type %s') % etype)
entity = self.vreg['etypes'].etype_class(etype)(self.req)
self.initialize_varmaker()
entity.eid = self.varmaker.next()
@@ -454,7 +452,7 @@
for i in xrange(len(rset)):
self.wview(self.id, rset, row=i, **kwargs)
- def cell_call(self, row, col, peid, rtype, role='subject', **kwargs):
+ def cell_call(self, row, col, peid, rtype, role, i18nctx, **kwargs):
"""
:param peid: the parent entity's eid hosting the inline form
:param rtype: the relation bridging `etype` and `peid`
@@ -463,23 +461,25 @@
entity = self.rset.get_entity(row, col)
divonclick = "restoreInlinedEntity('%s', '%s', '%s')" % (peid, rtype,
entity.eid)
- self.render_form(entity, peid, rtype, role, divonclick=divonclick)
+ self.render_form(entity, peid, rtype, role, i18nctx,
+ divonclick=divonclick)
- def render_form(self, entity, peid, rtype, role, **kwargs):
+ def render_form(self, entity, peid, rtype, role, i18nctx, **kwargs):
"""fetch and render the form"""
form = self.vreg['forms'].select('edition', self.req, entity=entity,
form_renderer_id='inline',
mainform=False, copy_nav_params=False)
self.add_hiddens(form, entity, peid, rtype, role)
divid = '%s-%s-%s' % (peid, rtype, entity.eid)
- title = self.schema.rschema(rtype).display_name(self.req, role)
- removejs = self.removejs % (peid, rtype,entity.eid)
+ title = self.req.pgettext(i18nctx, 'This %s' % entity.e_schema)
+ removejs = self.removejs % (peid, rtype, entity.eid)
countkey = '%s_count' % rtype
try:
self.req.data[countkey] += 1
except:
self.req.data[countkey] = 1
self.w(form.form_render(divid=divid, title=title, removejs=removejs,
+ i18nctx=i18nctx,
counter=self.req.data[countkey], **kwargs))
def add_hiddens(self, form, entity, peid, rtype, role):
@@ -511,7 +511,7 @@
& specified_etype_implements('Any'))
removejs = "removeInlineForm('%s', '%s', '%s')"
- def call(self, etype, peid, rtype, role='subject', **kwargs):
+ def call(self, etype, peid, rtype, role, i18nctx, **kwargs):
"""
:param etype: the entity type being created in the inline form
:param peid: the parent entity's eid hosting the inline form
@@ -519,10 +519,11 @@
:param role: the role played by the `peid` in the relation
"""
try:
- entity = self.vreg['etypes'].etype_class(etype)(self.req, None, None)
+ cls = self.vreg['etypes'].etype_class(etype)
except:
self.w(self.req._('no such entity type %s') % etype)
return
self.initialize_varmaker()
+ entity = cls(self.req)
entity.eid = self.varmaker.next()
- self.render_form(entity, peid, rtype, role)
+ self.render_form(entity, peid, rtype, role, i18nctx, **kwargs)