diff --git a/data/cubes.comment.js b/data/cubes.comment.js index acaf3d2bb7cbe70890de1410845002c7b7e0f7a5_ZGF0YS9jdWJlcy5jb21tZW50Lmpz..ea34a0ba9f268fa056f56d49a83623d1c816b8f9_ZGF0YS9jdWJlcy5jb21tZW50Lmpz 100644 --- a/data/cubes.comment.js +++ b/data/cubes.comment.js @@ -66,12 +66,9 @@ } } -$(document).ready(function() { - function scroll_top(event){ - toggleVisibility('popupLoginBox'); - $('html, body').animate({scrollTop:0}, 'fast'); - return false; - } - $('a.loadPopupLogin').click(scroll_top); -}); +function showLoginBox() { + toggleVisibility('popupLoginBox'); + $('html, body').animate({scrollTop:0}, 'fast'); + return false; +} @@ -77,3 +74,3 @@ -CubicWeb.provide('ecomment.js'); +CubicWeb.provide('comment.js'); diff --git a/i18n/en.po b/i18n/en.po index acaf3d2bb7cbe70890de1410845002c7b7e0f7a5_aTE4bi9lbi5wbw==..ea34a0ba9f268fa056f56d49a83623d1c816b8f9_aTE4bi9lbi5wbw== 100644 --- a/i18n/en.po +++ b/i18n/en.po @@ -37,6 +37,9 @@ msgid "Unknown author" msgstr "" +msgid "You are not authenticated." +msgstr "" + msgid "a comment is a reply about another entity" msgstr "" @@ -58,7 +61,6 @@ msgid "actions_reply_comment" msgstr "reply comment" -# add related box generated message msgid "actions_reply_comment_description" msgstr "" @@ -135,9 +137,6 @@ msgid "thread view" msgstr "" -msgid "to comment" -msgstr "" - msgid "unknown author" msgstr "" diff --git a/i18n/fr.po b/i18n/fr.po index acaf3d2bb7cbe70890de1410845002c7b7e0f7a5_aTE4bi9mci5wbw==..ea34a0ba9f268fa056f56d49a83623d1c816b8f9_aTE4bi9mci5wbw== 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -37,6 +37,9 @@ msgid "Unknown author" msgstr "Auteur inconnu" +msgid "You are not authenticated." +msgstr "Vous n'êtes pas authentifié." + msgid "a comment is a reply about another entity" msgstr "un commentaire autour d'une autre entité" @@ -134,11 +137,8 @@ msgid "thread view" msgstr "vue fil de discussions" -msgid "to comment" -msgstr "pour commenter" - msgid "unknown author" msgstr "auteur inconnu" msgid "written by" msgstr "écrit par" @@ -140,5 +140,8 @@ msgid "unknown author" msgstr "auteur inconnu" msgid "written by" msgstr "écrit par" + +#~ msgid "to comment" +#~ msgstr "pour commenter" diff --git a/views.py b/views.py index acaf3d2bb7cbe70890de1410845002c7b7e0f7a5_dmlld3MucHk=..ea34a0ba9f268fa056f56d49a83623d1c816b8f9_dmlld3MucHk= 100644 --- a/views.py +++ b/views.py @@ -43,14 +43,6 @@ {'vid': 'list', 'label': _('latest comment(s):'), 'limit': True, 'filter': lambda rset: rset.filtered_rset(lambda x: x.e_schema == 'Comment')}) -def _login_register_link(req): - if 'registration' in req.vreg.config.cubes(): - link = u'<a href="%s">%s</a> or ' % (req.build_url('register'), - req._(u'register')) - else: - link = u'' - link += u'<a class="loadPopupLogin">%s</a>' % req._(u'login') - return link # comment views ############################################################### @@ -129,17 +121,12 @@ if replyaction is not None: url = self._cw.build_ajax_replace_url( 'comment%sHolder' % entity.eid, rql_for_eid(entity.eid), - 'inlinecomment') - if self._cw.cnx.anonymous_connection: - self.w(u' | <span class="replyto">%s <a href="%s">%s</a></span>' - % (_login_register_link(self._cw), - xml_escape(url), self._cw._(replyaction.title))) - else: - self.w(u' | <span class="replyto"><a href="%s">%s</a></span>' - % (xml_escape(url), self._cw._(replyaction.title))) + 'addcommentform') + self.w(u' | <span class="replyto"><a href="%s">%s</a></span>' + % (xml_escape(url), self._cw._(replyaction.title))) editaction = actions.select_or_none('edit_comment', self._cw, rset=self.cw_rset, row=row) if editaction is not None: # split(':', 1)[1] to remove javascript: formjs = self._cw.build_ajax_replace_url( cdivid, rql_for_eid(entity.eid), @@ -140,10 +127,10 @@ editaction = actions.select_or_none('edit_comment', self._cw, rset=self.cw_rset, row=row) if editaction is not None: # split(':', 1)[1] to remove javascript: formjs = self._cw.build_ajax_replace_url( cdivid, rql_for_eid(entity.eid), - 'editcomment', 'append').split(':', 1)[1] + 'editcommentform', 'append').split(':', 1)[1] url = "javascript: jQuery('#%s div').hide(); %s" % (cdivid, formjs) self.w(u' | <span class="replyto"><a href="%s">%s</a></span>' % (xml_escape(url), self._cw._(editaction.title))) @@ -176,12 +163,4 @@ # comment edition views ####################################################### -class InlineCommentView(EntityView): - __regid__ = 'inlinecomment' - __select__ = yes() # explicit call when it makes sense - - def cell_call(self, row, col): - entity = self.cw_rset.get_entity(row, col) - self.wview('inlinecommentform', None, commented=entity) - class InlineEditCommentForm(FormViewMixIn, EntityView): @@ -187,5 +166,5 @@ class InlineEditCommentForm(FormViewMixIn, EntityView): - __regid__ = 'editcomment' + __regid__ = 'editcommentform' __select__ = implements('Comment') jsfunc = "processComment(%s, '%s', false)" @@ -194,7 +173,15 @@ def cell_call(self, row, col): self.comment_form(self.cw_rset.get_entity(row, col)) + def propose_to_login(self): + self.w(u'<div class="warning">%s ' % self._cw._('You are not authenticated.')) + if 'registration' in self._cw.vreg.config.cubes(): + self.w(u'<a href="%s">%s</a> or ' % (self._cw.build_url('register'), + self._cw._(u'register'))) + self.w(u'<a onclick="showLoginBox()">%s</a>' % self._cw._(u'login')) + self.w(u'</div>') + def comment_form(self, commented, newcomment=None): self._cw.add_js('cubes.comment.js') if newcomment is None: newcomment = commented @@ -197,7 +184,9 @@ def comment_form(self, commented, newcomment=None): self._cw.add_js('cubes.comment.js') if newcomment is None: newcomment = commented + if self._cw.cnx.anonymous_connection: + self.propose_to_login() # hack to avoid tabindex conflicts caused by Ajax requests self._cw.next_tabindex = count(20).next jseid = dumps(commented.eid) @@ -214,10 +203,10 @@ display_relations_form=False))) -class InlineCommentForm(InlineEditCommentForm): - __regid__ = 'inlinecommentform' - __select__ = match_kwargs('commented') # explicit call when it makes sense +class InlineAddCommentForm(InlineEditCommentForm): + __regid__ = 'addcommentform' + __select__ = relation_possible('comments', 'object', 'Comment', 'add') jsfunc = "processComment(%s, '%s', true)" jsonmeth = 'add_comment' @@ -220,8 +209,9 @@ jsfunc = "processComment(%s, '%s', true)" jsonmeth = 'add_comment' - def call(self, commented): + def cell_call(self, row, col): + commented = self.cw_rset.get_entity(row, col) newcomment = self._cw.vreg['etypes'].etype_class('Comment')(self._cw) newcomment.eid = self._cw.varmaker.next() self.comment_form(commented, newcomment) @@ -263,8 +253,8 @@ if addcomment is not None: self.w(u'<div id="comment%sHolder"></div>' % eid) url = req.build_ajax_replace_url( - 'comment%sHolder' % eid, rql_for_eid(eid), 'inlinecomment') - self.w(u' (<a href="%s" onclick="javascript:toggleVisibility(\'addCommentLinks\');">%s</a>)' % (url, req._(addcomment.title))) + 'comment%sHolder' % eid, rql_for_eid(eid), 'addcommentform') + self.w(u' (<a href="%s">%s</a>)' % (url, req._(addcomment.title))) # XXX still necessary? #if req.use_fckeditor() and req.property_value('ui.default-text-format') == 'text/html': # req.fckeditor_config() @@ -268,9 +258,6 @@ # XXX still necessary? #if req.use_fckeditor() and req.property_value('ui.default-text-format') == 'text/html': # req.fckeditor_config() - if req.cnx.anonymous_connection: - self.w(u'<div id="addCommentLinks" class="hidden">%s %s</div>' % \ - (_login_register_link(req), req._(u'to comment'))) # comment actions #############################################################