Skip to content
Snippets Groups Projects
Commit 380ac8079ae3 authored by sylvain thenault's avatar sylvain thenault
Browse files

minor refactoring, use optional relation to get creator

parent 4c96b71b1c1b
No related branches found
No related tags found
No related merge requests found
......@@ -237,15 +237,6 @@
req = self.req
req.add_js( ('cubicweb.ajax.js', 'cubes.comment.js') )
eid = self.rset[0][0]
if orderby == 'author':
rql = u'Any C,CD,CC,CCF,U,UL,US,UF ORDERBY UL 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'
else: # orderby == 'diem'
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}, 'x')
self.w(u'<div id="%s" class="%s" cubicweb:rooteid="%s">' % (
self.div_id(), self.div_class(), eid))
action = self.vreg.select_action('reply_comment', req, self.rset, row=0)
......@@ -257,7 +248,19 @@
req.add_js('fckeditor.js')
req.fckeditor_config()
else:
reply = u''
reply = u''
if orderby == 'author':
rql = u'Any C,CD,CC,CCF,U,UL,US,UF ORDERBY UL 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'
else: # orderby == 'diem'
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'
from cubicweb.server import set_debug
set_debug(True)
rset = req.execute(rql, {'x': eid}, 'x')
set_debug(False)
if rset.rowcount:
self.w(u'<h4>%s</h4>%s' % (req._('Comment_plural'), reply))
self.w(u'<div id="comment%sHolder"></div>' % eid)
......@@ -265,5 +268,5 @@
for i in xrange(rset.rowcount):
self.wview('tree', rset, row=i, full=True)
self.w(u'</ul>')
else:
elif reply:
self.w(reply)
......@@ -269,6 +272,5 @@
self.w(reply)
if reply:
self.w(u'<div id="comment%sHolder"></div>' % eid)
self.w(u'<div id="comment%sHolder"></div>' % eid)
self.w(u'</div>')
baseviews.PRIMARY_SKIP_RELS.add('comments') # displayed by the above component
......
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