# HG changeset patch # User Sylvain Thénault <sylvain.thenault@logilab.fr> # Date 1280224322 -7200 # Tue Jul 27 11:52:02 2010 +0200 # Node ID e4db834f9a38f24fb71895d88d0ba0b034164d17 # Parent b0524eea1a71cc1acd26f1a73367102525c1b680 #1193307: edition of comment broken in 1.7.0 cleanup/refactor/document comment form generation on the way diff --git a/views.py b/views.py --- a/views.py +++ b/views.py @@ -218,11 +218,6 @@ def comment_form(self, commented, newcomment=None): self._cw.add_js(('cubicweb.edition.js', 'cubes.comment.js')) - if newcomment is None: - newcomment = commented - formvalues = {'comments': commented.eid} - else: - formvalues = {} if self._cw.cnx.anonymous_connection: self.propose_to_login() # hack to avoid tabindex conflicts caused by Ajax requests @@ -232,23 +227,25 @@ fw.Button(stdmsgs.BUTTON_CANCEL, onclick=self.jsfunc % (jseid, 'true'))] fvreg = self._cw.vreg['forms'] - if newcomment is not None and not commented.has_eid(): + formvalues = {} + if newcomment is not None: # creation + formvalues['comments'] = commented.eid + if newcomment is None or commented.has_eid(): # creation / edition + # use formtype=inlined to avoid viewing the relation edition section + form = fvreg.select('edition', self._cw, entity=newcomment or commented, + domid='commentForm%s' % commented.eid, + form_buttons=buttons, + formtype='inlined') + else: # creation of both commented and comment entities form = fvreg.select('composite', self._cw, form_buttons=buttons, domid='commentForm%s' % commented.eid, form_renderer_id='default') form.add_subform(fvreg.select('edition', self._cw, entity=commented, mainform=False)) - cform = fvreg.select('edition', self._cw, entity=newcomment, - mainform=False) - form.add_subform(cform) - else: - # use formtype=inlined to avoid viewing the relation edition section - form = fvreg.select('edition', self._cw, entity=newcomment, - domid='commentForm%s' % commented.eid, - form_buttons=buttons, formtype='inlined') - cform = form + form.add_subform(fvreg.select('edition', self._cw, entity=newcomment, + mainform=False)) self.w(u'<div id="comment%sSlot">%s</div>' % ( - commented.eid, form.render(formvalues={'comments': commented.eid}, + commented.eid, form.render(formvalues=formvalues, main_form_title=u'', display_label=False, display_relations_form=False)))