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

cw 3.10 api update

parent a78e7ba718a2
No related branches found
No related tags found
No related merge requests found
......@@ -273,8 +273,8 @@
# contextual components ########################################################
class CommentSectionVComponent(component.EntityVComponent):
class CommentSectionVComponent(component.EntityCtxComponent):
"""a component to display a <div> html section including comments
related to an object
"""
__regid__ = 'commentsection'
......@@ -277,9 +277,9 @@
"""a component to display a <div> html section including comments
related to an object
"""
__regid__ = 'commentsection'
__select__ = ((component.EntityVComponent.__select__ | match_kwargs('entity'))
__select__ = ((component.EntityCtxComponent.__select__ | match_kwargs('entity'))
& relation_possible('comments', 'object', 'Comment'))
context = 'navcontentbottom'
......@@ -282,7 +282,7 @@
& relation_possible('comments', 'object', 'Comment'))
context = 'navcontentbottom'
def entity_call(self, entity, view=None):
def render_body(self, w):
req = self._cw
req.add_js( ('cubicweb.ajax.js', 'cubes.comment.js') )
......@@ -287,5 +287,6 @@
req = self._cw
req.add_js( ('cubicweb.ajax.js', 'cubes.comment.js') )
entity = self.entity
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)
......@@ -298,6 +299,6 @@
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))
w(u'<div id="%s" class="%s" cubicweb:rooteid="%s">' % (
self.domid, self.cssclass, entity.eid))
if rset.rowcount:
......@@ -303,4 +304,4 @@
if rset.rowcount:
self.w(u'<h4>%s</h4>' % (req._('Comment_plural')))
self.w(u'<ul class="comment">')
w(u'<h4>%s</h4>' % (req._('Comment_plural')))
w(u'<ul class="comment">')
for i in xrange(rset.rowcount):
......@@ -306,5 +307,5 @@
for i in xrange(rset.rowcount):
self.wview('tree', rset, row=i)
self.w(u'</ul>')
self.w(u'</div>')
wview('tree', rset, row=i)
w(u'</ul>')
w(u'</div>')
if addcomment is not None:
......@@ -310,5 +311,5 @@
if addcomment is not None:
self.w(u'<div id="comment%sHolder"></div>' % entity.eid)
w(u'<div id="comment%sHolder"></div>' % entity.eid)
params = self.cw_extra_kwargs.copy()
params.pop('view', None)
params.pop('context', None)
......@@ -318,6 +319,6 @@
params['etype'] = entity.__regid__
url = req.ajax_replace_url(
'comment%sHolder' % entity.eid, vid='addcommentform', **params)
self.w(u' (<a href="%s">%s</a>)' % (xml_escape(url), req._(addcomment.title)))
w(u' (<a href="%s">%s</a>)' % (xml_escape(url), req._(addcomment.title)))
......@@ -322,4 +323,4 @@
class UserLatestCommentsSection(component.EntityVComponent):
class UserLatestCommentsSection(component.EntityCtxComponent):
"""a section to display latest comments by a user"""
......@@ -325,4 +326,4 @@
"""a section to display latest comments by a user"""
__select__ = component.EntityVComponent.__select__ & is_instance('CWUser')
__select__ = component.EntityCtxComponent.__select__ & is_instance('CWUser')
__regid__ = 'latestcomments'
......@@ -327,6 +328,6 @@
__regid__ = 'latestcomments'
def cell_call(self, row, col, view=None):
def render_body(self, w):
user = self.cw_rset.get_entity(row, col)
maxrelated = self._cw.property_value('navigation.related-limit') + 1
rset = self._cw.execute(
......@@ -335,15 +336,15 @@
'C created_by U, U eid %%(u)s' % maxrelated,
{'u': user.eid})
if rset:
self.w(u'<div class="section">')
self.w(u'<h4>%s</h4>\n' % self._cw._('Latest comments').capitalize())
self.wview('table', rset,
headers=[_('about'), _('on date'),
_('comment content')],
cellvids={0: 'commentroot',
2: 'commentsummary',
})
self.w(u'</div>')
w(u'<div class="section">')
w(u'<h4>%s</h4>\n' % self._cw._('Latest comments').capitalize())
self.view('table', rset, w=w,
headers=[_('about'), _('on date'),
_('comment content')],
cellvids={0: 'commentroot',
2: 'commentsummary',
})
w(u'</div>')
# adapters #####################################################################
......
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