# HG changeset patch # User Sandrine Ribeau <sandrine.ribeau@logilab.fr> # Date 1254776643 25200 # Mon Oct 05 14:04:03 2009 -0700 # Node ID dfa9d2d8218e769a84b341f368fb85b3044f3713 # Parent 0868384716ed6895222068b923d97d2a1273df03 [views] add login an register link next to the reply action diff --git a/views.py b/views.py --- a/views.py +++ b/views.py @@ -36,6 +36,14 @@ uicfg.primaryview_section.tag_subject_of(('*', 'comments', '*'), 'hidden') uicfg.primaryview_section.tag_object_of(('*', 'comments', '*'), 'hidden') +def _login_register_link(appobj): + link = u'' + if appobj.req.cnx.anonymous_connection: + if 'registration' in appobj.vreg.config.cubes(): + link += u' <a href="/register">%s</a> or' % appobj.req._(u'register') + link += u' <a href="/login">%s</a> %s' % (appobj.req._(u'login'), appobj.req._(u'to')) + return link + # comment views ############################################################### class CommentPrimaryView(primary.PrimaryView): @@ -109,8 +117,9 @@ url = self.req.build_ajax_replace_url( 'comment%sHolder' % entity.eid, rql_for_eid(entity.eid), 'inlinecomment') - reply = ' | <a href="%s">%s</a>' % (html_escape(url), - _(action.title)) + reply = ' | %s <a href="%s"> %s </a>' % ( _login_register_link(self), + html_escape(url), + _(action.title)) if editaction is None: edit = u'' else: @@ -231,7 +240,7 @@ rset = req.execute(rql, {'x': eid}, 'x') if rset.rowcount: self.w(u'<h4>%s</h4>%s' % (req._('Comment_plural'), reply)) - self._login_register_link() + self.w(u'%s %s' % (_login_register_link(self), self.req._(u'comment'))) self.w(u'<div id="comment%sHolder"></div>' % eid) self.w(u'<ul class="comment">') @@ -240,17 +249,11 @@ self.w(u'</ul>') elif reply: self.w(reply) - self._login_register_link() + self.w(u'%s %s' % (_login_register_link(self), self.req._(u'to comment'))) self.w(u'<div id="comment%sHolder"></div>' % eid) self.w(u'</div>') - def _login_register_link(self): - if self.req.cnx.anonymous_connection: - if 'registration' in self.vreg.config.cubes(): - self.w(u' <a href="/register">%s</a> or' % self.req._(u'register')) - self.w(u' <a href="/login">%s</a> %s' % (self.req._(u'login'), self.req._(u'to comment'))) - # comment actions ############################################################# class ReplyCommentAction(LinkToEntityAction):