User Story: As a visitor, I can view portraits, full name and username against each comment, with a link to the author profile

svn path=/plone.app.discussion/trunk/; revision=27188
This commit is contained in:
Timo Stollenwerk 2009-05-28 06:08:55 +00:00
parent 6c7909a4f7
commit 660ee78ca0
2 changed files with 43 additions and 10 deletions

View File

@ -7,23 +7,38 @@
<div class="comment"
tal:define="reply reply_dict/comment;
depth reply_dict/depth|python:0;"
depth reply_dict/depth|python:0;
creator reply/Creator;
author_home_url string:${context/portal_url}/author/${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}">
<tal:authorimage tal:condition="not:anonymous_creator">
<a href="" tal:attributes="href author_home_url">
<img src="" alt=""
tal:attributes="src string:${context/portal_url}/portal_memberdata/portraits/${reply/author_username};
alt reply/creator" />
</a>
</tal:authorimage>
<h3>
<a name="comments" tal:attributes="name reply/title">
<span tal:replace="reply/title">Comment title</span>
</a>
</h3>
<div class="documentByLine"
tal:define="creator reply/Creator;
anonymous_creator python:creator in ('Anonymous User', '');">
<div class="documentByLine">
<tal:posted i18n:translate="label_comment_by">Posted by</tal:posted>
<tal:name content="creator"
condition="not:anonymous_creator">Poster Name</tal:name>
<tal:name condition="not:anonymous_creator">
<a href=""
tal:content="creator"
tal:attributes="href author_home_url">
Poster Name
</a>
</tal:name>
<tal:name i18n:translate="label_anonymous_user"
condition="anonymous_creator">Anonymous User</tal:name>
<tal:at i18n:translate="label_commented_at">at</tal:at>

View File

@ -1,19 +1,24 @@
from datetime import datetime
from zope.interface import implements
from zope.component import createObject
from zope.component import getMultiAdapter
from zope.viewlet.interfaces import IViewlet
from Acquisition import aq_inner, aq_parent
from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.CMFCore.utils import getToolByName
from plone.app.discussion.interfaces import IComment, IReplies
from plone.app.discussion.conversation import conversationAdapterFactory
from plone.app.discussion.comment import CommentFactory
from zope.component import createObject
class View(BrowserView):
"""Comment View
@ -73,10 +78,23 @@ class AddComment(BrowserView):
comment.title = subject
comment.text = text
# Add comment to the conversation
conversation.addComment(comment)
portal_membership = getToolByName(self.context, 'portal_membership')
# Redirect to the document object page
if portal_membership.isAnonymousUser():
# TODO: Not implemented yet
pass
else:
member = portal_membership.getAuthenticatedMember()
comment.creator = member.getProperty('fullname')
comment.author_username = member.getUserName()
comment.author_name = member.getProperty('fullname')
comment.author_email = member.getProperty('email')
comment.creation_date = comment.modification_date = datetime.now()
# Add comment to the conversation
comment_id = conversation.addComment(comment)
# Redirect to the comment
self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url())
class ReplyToComment(BrowserView):