user member.getId as author_username, so membrane users and plone users have portraits and author urls

This commit is contained in:
maartenkling 2014-02-02 14:55:37 +01:00
parent a8dc5dd3f0
commit 8ccd648928
3 changed files with 10 additions and 7 deletions

View File

@ -4,6 +4,10 @@ Changelog
2.3.0 (unreleased) 2.3.0 (unreleased)
------------------ ------------------
- user member.id as author_username, so membrane users having different id
then username still have there picture shown and author path is correct.
[maartenkling]
- Corrections and additions to the Danish translation - Corrections and additions to the Danish translation
[aputtu] [aputtu]

View File

@ -195,7 +195,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
elif not portal_membership.isAnonymousUser() and can_reply: elif not portal_membership.isAnonymousUser() and can_reply:
# Member # Member
member = portal_membership.getAuthenticatedMember() member = portal_membership.getAuthenticatedMember()
username = member.getUserName() memberid = member.getId()
user = member.getUser() user = member.getUser()
email = member.getProperty('email') email = member.getProperty('email')
fullname = member.getProperty('fullname') fullname = member.getProperty('fullname')
@ -207,9 +207,9 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
if email and isinstance(email, str): if email and isinstance(email, str):
email = unicode(email, 'utf-8') email = unicode(email, 'utf-8')
comment.changeOwnership(user, recursive=False) comment.changeOwnership(user, recursive=False)
comment.manage_setLocalRoles(username, ["Owner"]) comment.manage_setLocalRoles(memberid, ["Owner"])
comment.creator = username comment.creator = memberid
comment.author_username = username comment.author_username = memberid
comment.author_name = fullname comment.author_name = fullname
comment.author_email = email comment.author_email = email
comment.creation_date = datetime.utcnow() comment.creation_date = datetime.utcnow()

View File

@ -126,12 +126,12 @@ class TestCommentForm(unittest.TestCase):
for comment in comments: for comment in comments:
self.assertEqual(comment.text, u"bar") self.assertEqual(comment.text, u"bar")
self.assertEqual(comment.creator, "test-user") self.assertEqual(comment.creator, "test_user_1_")
self.assertEqual(comment.getOwner().getUserName(), "test-user") self.assertEqual(comment.getOwner().getUserName(), "test-user")
local_roles = comment.get_local_roles() local_roles = comment.get_local_roles()
self.assertEqual(len(local_roles), 1) self.assertEqual(len(local_roles), 1)
userid, roles = local_roles[0] userid, roles = local_roles[0]
self.assertEqual(userid, 'test-user') self.assertEqual(userid, 'test_user_1_')
self.assertEqual(len(roles), 1) self.assertEqual(len(roles), 1)
self.assertEqual(roles[0], 'Owner') self.assertEqual(roles[0], 'Owner')
@ -558,4 +558,3 @@ class TestCommentsViewlet(unittest.TestCase):
localized_time = self.viewlet.format_time(python_time) localized_time = self.viewlet.format_time(python_time)
self.assertTrue( self.assertTrue(
localized_time in ['Feb 01, 2009 11:32 PM', '2009-02-01 23:32']) localized_time in ['Feb 01, 2009 11:32 PM', '2009-02-01 23:32'])