Skip to content
Snippets Groups Projects
Commit 47260bb652b5 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

avoid empty div when no comments and no right to add comment. Remove spurious...

avoid empty div when no comments and no right to add comment. Remove spurious parameters from ajax place holder url.
parent 96294d425e76
No related branches found
No related tags found
No related merge requests found
......@@ -286,10 +286,10 @@
def entity_call(self, entity, view=None):
req = self._cw
req.add_js( ('cubicweb.ajax.js', 'cubes.comment.js') )
eid = entity.eid
self.w(u'<div id="%s" class="%s" cubicweb:rooteid="%s">' % (
self.div_id(), self.div_class(), eid))
addcomment = self._cw.vreg['actions'].select_or_none(
'reply_comment', req, entity=entity,
rset=entity.cw_rset, row=entity.cw_row, col=entity.cw_col)
if entity.has_eid():
rql = u'Any C,CD,CC,CCF,U,UL,US,UF ORDERBY CD WHERE C is Comment, '\
'C comments X, C creation_date CD, C content CC, C content_format CCF, ' \
'C created_by U?, U login UL, U firstname UF, U surname US, X eid %(x)s'
......@@ -292,12 +292,18 @@
if entity.has_eid():
rql = u'Any C,CD,CC,CCF,U,UL,US,UF ORDERBY CD WHERE C is Comment, '\
'C comments X, C creation_date CD, C content CC, C content_format CCF, ' \
'C created_by U?, U login UL, U firstname UF, U surname US, X eid %(x)s'
rset = req.execute(rql, {'x': eid})
if rset.rowcount:
self.w(u'<h4>%s</h4>' % (req._('Comment_plural')))
self.w(u'<ul class="comment">')
for i in xrange(rset.rowcount):
self.wview('tree', rset, row=i)
self.w(u'</ul>')
rset = req.execute(rql, {'x': entity.eid})
else:
rset = None
if not (rset or addcomment):
return
self.w(u'<div id="%s" class="%s" cubicweb:rooteid="%s">' % (
self.div_id(), self.div_class(), entity.eid))
if rset.rowcount:
self.w(u'<h4>%s</h4>' % (req._('Comment_plural')))
self.w(u'<ul class="comment">')
for i in xrange(rset.rowcount):
self.wview('tree', rset, row=i)
self.w(u'</ul>')
self.w(u'</div>')
......@@ -303,5 +309,2 @@
self.w(u'</div>')
addcomment = self._cw.vreg['actions'].select_or_none(
'reply_comment', req, entity=entity,
rset=entity.cw_rset, row=entity.cw_row, col=entity.cw_col)
if addcomment is not None:
......@@ -307,4 +310,6 @@
if addcomment is not None:
self.w(u'<div id="comment%sHolder"></div>' % eid)
params = self.cw_extra_kwargs
self.w(u'<div id="comment%sHolder"></div>' % entity.eid)
params = self.cw_extra_kwargs.copy()
params.pop('view', None)
params.pop('context', None)
if entity.has_eid():
......@@ -310,5 +315,5 @@
if entity.has_eid():
params['eid'] = eid
params['eid'] = entity.eid
else:
params['etype'] = entity.__regid__
url = req.ajax_replace_url(
......@@ -312,7 +317,7 @@
else:
params['etype'] = entity.__regid__
url = req.ajax_replace_url(
'comment%sHolder' % eid, vid='addcommentform', **params)
'comment%sHolder' % entity.eid, vid='addcommentform', **params)
self.w(u' (<a href="%s">%s</a>)' % (xml_escape(url), req._(addcomment.title)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment