fix that anonymous users see a link to a non-existent user-home in the comments viewlet.

svn path=/plone.app.discussion/trunk/; revision=27419
This commit is contained in:
Timo Stollenwerk 2009-06-14 11:10:45 +00:00
parent 1670338ace
commit 5e26227ea1
2 changed files with 9 additions and 6 deletions

View File

@ -29,21 +29,22 @@
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);
author_home_url python:view.get_commenter_home_url(username=reply.author_username);
portrait_url 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="showCommenterImage">
<a href="" tal:condition="not:isAnon"
tal:attributes="href author_home_url">
<img src="defaultUser.gif"
alt=""
border="0"
width="75"
tal:attributes="src portrait/absolute_url;
tal:attributes="src portrait_url;
alt reply/creator" />
</a>
<img src="defaultUser.gif"
@ -51,7 +52,7 @@
border="0"
width="75"
tal:condition="isAnon"
tal:attributes="src portrait/absolute_url;
tal:attributes="src portrait_url;
alt reply/creator" />
</div>

View File

@ -100,9 +100,11 @@ class CommentsViewlet(ViewletBase):
def get_commenter_portrait(self, username):
if username is None:
return None
# return the default user image if no username is given
return 'defaultUser.gif'
else:
return self.portal_membership.getPersonalPortrait(username);
portal_membership = getToolByName(self.context, 'portal_membership', None)
return portal_membership.getPersonalPortrait(username).absolute_url();
def anonymous_discussion_allowed(self):
# Check if anonymous comments are allowed in the registry