From 8ccd6489286b01821328db43f36dd9c37fcdc8d5 Mon Sep 17 00:00:00 2001 From: maartenkling Date: Sun, 2 Feb 2014 14:55:37 +0100 Subject: [PATCH] user member.getId as author_username, so membrane users and plone users have portraits and author urls --- CHANGES.rst | 4 ++++ plone/app/discussion/browser/comments.py | 8 ++++---- plone/app/discussion/tests/test_comments_viewlet.py | 5 ++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 88650ce..ab43b0d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,10 @@ Changelog 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 [aputtu] diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index caf2859..30bc74c 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -195,7 +195,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form): elif not portal_membership.isAnonymousUser() and can_reply: # Member member = portal_membership.getAuthenticatedMember() - username = member.getUserName() + memberid = member.getId() user = member.getUser() email = member.getProperty('email') fullname = member.getProperty('fullname') @@ -207,9 +207,9 @@ class CommentForm(extensible.ExtensibleForm, form.Form): if email and isinstance(email, str): email = unicode(email, 'utf-8') comment.changeOwnership(user, recursive=False) - comment.manage_setLocalRoles(username, ["Owner"]) - comment.creator = username - comment.author_username = username + comment.manage_setLocalRoles(memberid, ["Owner"]) + comment.creator = memberid + comment.author_username = memberid comment.author_name = fullname comment.author_email = email comment.creation_date = datetime.utcnow() diff --git a/plone/app/discussion/tests/test_comments_viewlet.py b/plone/app/discussion/tests/test_comments_viewlet.py index 5e7d89f..c0d45b2 100644 --- a/plone/app/discussion/tests/test_comments_viewlet.py +++ b/plone/app/discussion/tests/test_comments_viewlet.py @@ -126,12 +126,12 @@ class TestCommentForm(unittest.TestCase): for comment in comments: 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") local_roles = comment.get_local_roles() self.assertEqual(len(local_roles), 1) userid, roles = local_roles[0] - self.assertEqual(userid, 'test-user') + self.assertEqual(userid, 'test_user_1_') self.assertEqual(len(roles), 1) self.assertEqual(roles[0], 'Owner') @@ -558,4 +558,3 @@ class TestCommentsViewlet(unittest.TestCase): localized_time = self.viewlet.format_time(python_time) self.assertTrue( localized_time in ['Feb 01, 2009 11:32 PM', '2009-02-01 23:32']) -