diff --git a/views.py b/views.py index 7fbca19f7e62ed601bfa8ae7c31d4ce9b80b201c_dmlld3MucHk=..2ee5820ef5b9877fbbec426bee3769cce5714508_dmlld3MucHk= 100644 --- a/views.py +++ b/views.py @@ -12,6 +12,7 @@ from simplejson import dumps +from cubicweb.selectors import one_line_rset, but_etype, implements, has_permission from cubicweb.common.uilib import rql_for_eid, cut, safe_cut, ajax_replace_url from cubicweb.common.view import EntityView from cubicweb.common.mixins import TreeViewMixIn @@ -15,6 +16,6 @@ from cubicweb.common.uilib import rql_for_eid, cut, safe_cut, ajax_replace_url from cubicweb.common.view import EntityView from cubicweb.common.mixins import TreeViewMixIn -from cubicweb.common.selectors import (match_kwargs, searchstate_accept, - one_line_rset, accept) +from cubicweb.common.selectors import (match_kwargs, + accept) @@ -20,2 +21,4 @@ +from cubicweb.web import stdmsgs +from cubicweb.web.action import (LinkToEntityAction, Action) from cubicweb.web.views import baseviews @@ -21,5 +24,4 @@ from cubicweb.web.views import baseviews -from cubicweb.web import stdmsgs _ = unicode @@ -134,9 +136,7 @@ class InlineCommentView(EntityView): id = 'inlinecomment' - accepts = ('Any',) # XXX should support the comments relation - requires = ('Comment',) - __selectors__ = (one_line_rset, accept) + __selectors__ = (yes,) # explicit call when it makes sense, def cell_call(self, row, col): entity = self.entity(row, col) @@ -145,4 +145,6 @@ class InlineCommentForm(baseforms.CreationForm): id = 'inlinecommentform' + __selectors__ = (match_kwargs('commented'),) # explicit call when it makes sense, + title = None # hidden @@ -148,8 +150,4 @@ title = None # hidden - requires = ('Comment',) - accepts = ('Comment',) - __selectors__ = (match_kwargs,) - expected_kwargs = ('commented',) EDITION_BODY = u""" @@ -274,6 +272,7 @@ # comment actions ############################################################# -from cubicweb.web.action import (LinkToEntityAction, LinkToEntityAction2, - EntityAction) +class ReplyCommentAction(LinkToEntityAction): + id = 'reply_comment' + __selectors__ = LinkToEntityAction + (implements('Comments'),) @@ -279,7 +278,4 @@ -class ReplyCommentAction(LinkToEntityAction): - category = 'hidden' - accepts = ('Comment',) etype = 'Comment' rtype = 'comments' target = 'subject' @@ -283,4 +279,7 @@ etype = 'Comment' rtype = 'comments' target = 'subject' + + title = _('reply to this comment') + category = 'hidden' order = 111 @@ -286,7 +285,4 @@ order = 111 - - id = 'reply_comment' - title = _('reply to this comment') def url(self): rset = self.rset @@ -298,5 +294,5 @@ __redirectvid=self.req.form.get('vid', '')) -class AddCommentAction(LinkToEntityAction2): +class AddCommentAction(LinkToEntityAction): """add comment is like reply for everything but Comment""" @@ -302,6 +298,7 @@ """add comment is like reply for everything but Comment""" - category = 'hidden' - accepts = ('Any',) + id = 'reply_comment' + __selectors__ = LinkToEntityAction + (implements('Any'), but_etype('Comment'),) + etype = 'Comment' rtype = 'comments' target = 'subject' @@ -305,4 +302,7 @@ etype = 'Comment' rtype = 'comments' target = 'subject' + + title = _('add comment') + category = 'hidden' order = 111 @@ -308,6 +308,3 @@ order = 111 - - id = 'reply_comment' - title = _('add comment') @@ -312,4 +309,8 @@ -class EditCommentAction(EntityAction): +class EditCommentAction(Action): + id = 'edit_comment' + __selectors__ = (one_line_rset, implements('Comment'), has_permission('update')) + + title = _('edit comment') category = 'hidden' @@ -315,6 +316,2 @@ category = 'hidden' - __selectors__ = (one_line_rset, searchstate_accept) - accepts = ('Comment',) - etype = 'Comment' - schema_action = 'update' order = 110 @@ -320,7 +317,4 @@ order = 110 - - id = 'edit_comment' - title = _('edit comment') def url(self): return self.build_url(rql=self.rset.printable_rql(), vid='edition')