get_commenter_portrait and get_commenter_home_url methods added to comments viewlet.

tests for get_commenter_portrait added.

svn path=/plone.app.discussion/trunk/; revision=27349
This commit is contained in:
Timo Stollenwerk
2009-06-07 20:58:41 +00:00
parent dada11c43c
commit 1af2b435fd
3 changed files with 69 additions and 10 deletions
+6 -6
View File
@@ -26,16 +26,16 @@
tal:define="reply reply_dict/comment;
depth reply_dict/depth|python:0;
creator reply/Creator;
author_home_url string:${context/portal_url}/author/${reply/author_username};
portrait python: here.portal_membership.getPersonalPortrait(reply.author_username);
commenter_home_url python:view.get_commenter_home_url(reply.author_username);
portrait python:view.get_commenter_portrait(reply.author_username);
anonymous_creator python:creator in ('Anonymous User', '');"
tal:attributes="class python:'comment replyTreeLevel'+str(depth);
style string:margin-left: ${depth}em;
id string:comment-${reply/id}">
<div class="commentImage" tal:condition="not:anonymous_creator">
<a href="" tal:condition="not:isAnon"
tal:attributes="href author_home_url">
<a href="" tal:condition="python: commenter_home_url and not isAnon"
tal:attributes="href commenter_home_url">
<img src="defaultUser.gif"
alt=""
border="0"
@@ -47,7 +47,7 @@
alt=""
border="0"
width="75"
tal:condition="isAnon"
tal:condition="python: isAnon or not commenter_home_url"
tal:attributes="src portrait/absolute_url;
alt reply/creator" />
</div>
@@ -64,7 +64,7 @@
<a href=""
tal:condition="not:isAnon"
tal:content="creator"
tal:attributes="href author_home_url">
tal:attributes="href commenter_home_url">
Poster Name
</a>
<span tal:condition="isAnon"
+14 -1
View File
@@ -67,6 +67,19 @@ class CommentsViewlet(ViewletBase):
else:
return False
def get_commenter_home_url(self, username):
if username is None:
return None
else:
return "%s/author/%s" % (self.context.portal_url(), username)
def get_commenter_portrait(self, username):
if username is None:
return None
else:
return self.portal_membership.getPersonalPortrait(username);
def is_anonymous(self):
return self.portal_state.anonymous()
@@ -78,7 +91,7 @@ class CommentsViewlet(ViewletBase):
return time.strftime("%a, %d %b %Y %H:%M")
# XXX: Not working, returns None !!!
#return self.context.restrictedTraverse('@@plone').toLocalizedTime(time, long_format=True)
class AddComment(BrowserView):
"""Add a comment to a conversation
"""