← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~bac/launchpad/cherrypick-633926 into lp:~launchpad-pqm/launchpad/production-devel

 

Brad Crittenden has proposed merging lp:~bac/launchpad/cherrypick-633926 into lp:~launchpad-pqm/launchpad/production-devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #633926 Changing profile name results in error: 'Not allowed here'
  https://bugs.launchpad.net/bugs/633926


Fix a regression where users are not allowed to change their own name. Rewrote the test to *not* use an administrator to demonstrate the action, which masked the regression.
-- 
https://code.launchpad.net/~bac/launchpad/cherrypick-633926/+merge/35286
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~bac/launchpad/cherrypick-633926 into lp:~launchpad-pqm/launchpad/production-devel.
=== modified file 'lib/lp/registry/browser/person.py'
--- lib/lp/registry/browser/person.py	2010-09-03 03:12:39 +0000
+++ lib/lp/registry/browser/person.py	2010-09-13 13:48:51 +0000
@@ -209,7 +209,6 @@
     PersonFormatterAPI,
     )
 from canonical.lazr.utils import (
-    safe_hasattr,
     smartquote,
     )
 from canonical.widgets import (
@@ -4167,6 +4166,15 @@
 
     @action(_("Save Changes"), name="save")
     def action_save(self, action, data):
+        # XXX: BradCrittenden 2010-09-10 bug=634878: Find a cleaner solution
+        # to the permissions problem for 'name'.  Users should be able to
+        # change their name, but the permission setting for the attribute is
+        # launchpad.Moderate, which only allows admins and registry.  A user
+        # must have launchpad.Edit to access this page.
+        if 'name' in data:
+            new_name = data['name']
+            removeSecurityProxy(self.context).name = new_name
+            del data['name']
         self.updateContextFromData(data)
 
 

=== modified file 'lib/lp/registry/stories/person/xx-person-edit.txt'
--- lib/lp/registry/stories/person/xx-person-edit.txt	2010-03-24 21:45:05 +0000
+++ lib/lp/registry/stories/person/xx-person-edit.txt	2010-09-13 13:48:51 +0000
@@ -1,15 +1,22 @@
-== Changing personal details ==
+Changing personal details
+=========================
 
-Foo Bar wants to check if his personal information is up to date in
+A user wants to check if his personal information is up to date in
 Launchpad.
 
-    >>> browser.addHeader('Authorization', 'Basic foo.bar@xxxxxxxxxxxxx:test')
-    >>> browser.open('http://launchpad.dev/~name16')
+    >>> from lp.testing.sampledata import ADMIN_EMAIL
+    >>> login(ADMIN_EMAIL)
+    >>> user = factory.makePerson(name='ray', displayname='Ray Ray',
+    ...                           email='ray@xxxxxxxxxxx',
+    ...                           password='test')
+    >>> logout()
+    >>> browser.addHeader('Authorization', 'Basic ray@xxxxxxxxxxx:test')
+    >>> browser.open('http://launchpad.dev/~ray')
     >>> browser.getLink('Change details').click()
     >>> browser.getControl('Display Name').value
-    'Foo Bar'
+    'Ray Ray'
     >>> browser.getControl('Name', index=1).value
-    'name16'
+    'ray'
     >>> browser.getControl(
     ...     'Hide my email addresses from other Launchpad users').selected
     False
@@ -25,46 +32,46 @@
 (If he leaves leading or trailing whitespace in the displayname it'll
 be stripped)
 
-    >>> browser.getControl('Name', index=1).value = 'foobar'
-    >>> browser.getControl('Display Name').value = '  Foo Bar2  '
+    >>> browser.getControl('Name', index=1).value = 'rayjay'
+    >>> browser.getControl('Display Name').value = '   Mr Ray Jay '
     >>> browser.getControl(
     ...     'Hide my email addresses from other Launchpad users').click()
     >>> browser.getControl('Save').click()
 
     >>> browser.url
-    'http://launchpad.dev/~foobar'
+    'http://launchpad.dev/~rayjay'
 
 Now we check to make sure the displayname was changed and stripped.
 
-    >>> browser.open('http://launchpad.dev/~foobar/+edit')
+    >>> browser.open('http://launchpad.dev/~rayjay/+edit')
     >>> browser.getControl('Display Name').value
-    'Foo Bar2'
+    'Mr Ray Jay'
 
 And the email addresses are not shown on Foo Bar's home page to any random
 user.
 
-    >>> user_browser.open('http://launchpad.dev/~foobar')
-    >>> 'foo.bar@xxxxxxxxxxxxx' in user_browser.contents
+    >>> user_browser.open('http://launchpad.dev/~rayjay')
+    >>> 'ray@xxxxxxxxxxx' in user_browser.contents
     False
 
 He will decide to make all bug notifications that are sent to him
-verbose.
+not include descriptions.
 
     >>> browser.getControl("Include bug descriptions when sending me "
     ...     "bug notifications").selected
-    False
+    True
 
     >>> browser.getControl("Include bug descriptions when sending me "
     ...     "bug notifications").click()
     >>> browser.getControl('Save').click()
 
     >>> browser.url
-    'http://launchpad.dev/~foobar'
+    'http://launchpad.dev/~rayjay'
 
 We now check to ensure that the verbose bug notifications option was
 changed:
 
-    >>> browser.open('http://launchpad.dev/~foobar/+edit')
+    >>> browser.open('http://launchpad.dev/~rayjay/+edit')
     >>> browser.getControl("Include bug descriptions when sending me "
     ...     "bug notifications").selected
-    True
+    False


Follow ups