control comments via loops root options; use TrackDetails as base class for displaying comments instead of TrackView

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3056 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-12-09 12:05:16 +00:00
parent e1a5ba9e3a
commit 252ae21bbc
4 changed files with 16 additions and 24 deletions

View file

@ -63,15 +63,16 @@ Creating comments
Viewing comments
----------------
>>> from loops.organize.comment.browser import CommentsView, CommentView
>>> from loops.organize.comment.browser import CommentsView
>>> comments = CommentsView(home, TestRequest())
>>> items = list(comments.allItems())
>>> items
[<loops.organize.comment.browser.CommentView ...>]
[<Comment ['27', 1, '33', '... ...']:
{'text': 'Comment text', 'subject': 'My comment'}>]
>>> item = items[0]
>>> item.subject, item.timeStamp, item.userTitle
('My comment', '... ...', u'john')
>>> item.subject, item.timeStamp, item.user['title']
('My comment', u'... ...', u'john')
Fin de partie

View file

@ -34,7 +34,7 @@ from loops.browser.form import ObjectForm, EditObject
from loops.browser.node import NodeView
from loops.organize.comment.base import Comment
from loops.organize.party import getPersonForUser
from loops.organize.tracking.browser import BaseTrackView
from loops.organize.tracking.report import TrackDetails
from loops.setup import addObject
from loops import util
from loops.util import _
@ -51,8 +51,7 @@ class CommentsView(NodeView):
@Lazy
def allowed(self):
return False
return True
return self.globalOptions('organize.allowComments')
@Lazy
def addUrl(self):
@ -71,22 +70,20 @@ class CommentsView(NodeView):
if None in (ts, target):
return result
for tr in reversed(list(ts.query(taskId=util.getUidForObject(target)))):
view = CommentView(tr, self.request)
view.parent = self
result.append(view)
result.append(CommentDetails(self, tr))
return result
class CommentView(BaseTrackView):
class CommentDetails(TrackDetails):
@Lazy
def subject(self):
return self.context.data['subject']
return self.track.data['subject']
@Lazy
def text(self):
return self.parent.renderText(self.context.data['text'],
self.context.contentType)
return self.view.renderText(self.track.data['text'],
self.track.contentType)
class CreateCommentForm(ObjectForm):

View file

@ -8,15 +8,15 @@
<br />
<h2 i18n:translate="">Comments</h2>
<metal:comments define-macro="comments_listing"
tal:define="comments comments|nocall:view/comments;
tal:define="comments nocall:comments|nocall:view/comments;
items comments/allItems">
<tal:comment tal:repeat="comment items">
<br />
<div class="comment">
<h3>
<span tal:content="comment/subject">Resource Title</span></h3>
<span tal:content="comment/subject">Subject</span></h3>
<div class="info">
<span tal:replace="comment/userTitle">John</span>,
<span tal:replace="comment/user/title">John</span>,
<span tal:replace="comment/timeStamp">2007-03-30</span>
</div>
<p class="content"
@ -25,7 +25,7 @@
</tal:comment>
</metal:comments>
<div metal:define-macro="comments_button_add"
tal:define="comments comments|nocall:view/comments"
tal:define="comments nocall:comments|nocall:view/comments"
class="button">
<a i18n:translate=""
tal:attributes="href comments/addUrl;

View file

@ -20,12 +20,6 @@
class="loops.organize.comment.browser.CommentsView"
permission="zope.View" />
<browser:page
name="index.html"
for="cybertools.tracking.comment.interfaces.IComment"
class="loops.organize.comment.browser.CommentView"
permission="zope.View" />
<browser:page
name="create_comment.html"
for="loops.interfaces.INode"