Merge lp:~edwin-grubbs/launchpad/bug-248518-setPreferredEmail into lp:launchpad

Proposed by Edwin Grubbs
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~edwin-grubbs/launchpad/bug-248518-setPreferredEmail
Merge into: lp:launchpad
Prerequisite: lp:~edwin-grubbs/launchpad/bug-553384-deactivated-project-oops
Diff against target: 120 lines (+23/-20)
5 files modified
lib/lp/bugs/browser/bugalsoaffects.py (+1/-1)
lib/lp/bugs/browser/tests/bugtask-adding-views.txt (+0/-1)
lib/lp/registry/doc/person.txt (+13/-5)
lib/lp/registry/model/person.py (+0/-11)
lib/lp/testing/factory.py (+9/-2)
To merge this branch: bzr merge lp:~edwin-grubbs/launchpad/bug-248518-setPreferredEmail
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+24041@code.launchpad.net

Description of the change

Summary
-------

Person.setPreferredEmail() no longer activates the account automatically.

Implementation details
----------------------

Changed setPreferredEmail and fixed tests.
    lib/lp/registry/model/person.py
    lib/lp/registry/doc/person.txt
    lib/lp/testing/factory.py

Fixed lint errors.
    lib/lp/bugs/browser/bugalsoaffects.py
    lib/lp/bugs/browser/tests/bugtask-adding-views.txt

Tests
-----

./bin/test -vv -t 'doc/person.txt|bugtask-adding-views.txt'

Demo and Q/A
------------

This has no effect on the UI.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

I am surprised there is not comparable test for account.activate() in doc/account. I think your test is the only documentation we have. My initial though was to move your test, but I think your decision was right. I think your tests tells other launchpad developer how to get a person's account activated.

I like your graceful solution in the factory.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/browser/bugalsoaffects.py'
--- lib/lp/bugs/browser/bugalsoaffects.py 2010-04-23 20:24:36 +0000
+++ lib/lp/bugs/browser/bugalsoaffects.py 2010-04-23 20:24:38 +0000
@@ -593,7 +593,7 @@
593 elif link_upstream_how == LinkUpstreamHowOptions.EMAIL_UPSTREAM_DONE:593 elif link_upstream_how == LinkUpstreamHowOptions.EMAIL_UPSTREAM_DONE:
594 # Ensure there's a bug tracker for this email address.594 # Ensure there's a bug tracker for this email address.
595 bug_url = 'mailto:' + data['upstream_email_address_done']595 bug_url = 'mailto:' + data['upstream_email_address_done']
596 bug_tracker = getUtility(IBugTrackerSet).ensureBugTracker(596 getUtility(IBugTrackerSet).ensureBugTracker(
597 bug_url, self.user, BugTrackerType.EMAILADDRESS)597 bug_url, self.user, BugTrackerType.EMAILADDRESS)
598 data['bug_url'] = bug_url598 data['bug_url'] = bug_url
599599
600600
=== modified file 'lib/lp/bugs/browser/tests/bugtask-adding-views.txt'
--- lib/lp/bugs/browser/tests/bugtask-adding-views.txt 2010-04-23 20:24:36 +0000
+++ lib/lp/bugs/browser/tests/bugtask-adding-views.txt 2010-04-23 20:24:38 +0000
@@ -12,7 +12,6 @@
12 >>> len(bug_four.bugtasks)12 >>> len(bug_four.bugtasks)
13 113 1
14 >>> firefox_task = bug_four.bugtasks[0]14 >>> firefox_task = bug_four.bugtasks[0]
15 >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
1615
17The views registered at +choose-affected-product and +distrotask are in16The views registered at +choose-affected-product and +distrotask are in
18fact meta views responsible for calling other views in order to guide the17fact meta views responsible for calling other views in order to guide the
1918
=== modified file 'lib/lp/registry/doc/person.txt'
--- lib/lp/registry/doc/person.txt 2010-04-23 20:24:36 +0000
+++ lib/lp/registry/doc/person.txt 2010-04-23 20:24:38 +0000
@@ -119,11 +119,9 @@
119119
120By default, newly created Person entries will have120By default, newly created Person entries will have
121AccountStatus.NOACCOUNT as their account_status. This is only changed121AccountStatus.NOACCOUNT as their account_status. This is only changed
122if/when we turn that entry into an actual user account. (Currently, we122if/when we turn that entry into an actual user account. Note that both
123assume that a Person entry is turned into a user account when its first123the Person and the EmailAddress have accounts when they are created
124email address is confirmed) Note that both the Person and the124using the createPersonAndEmail() method.
125EmailAddress have accounts when they are created using the
126createPersonAndEmail() method.
127125
128 >>> p.account_status126 >>> p.account_status
129 <DBItem AccountStatus.NOACCOUNT...127 <DBItem AccountStatus.NOACCOUNT...
@@ -136,6 +134,16 @@
136 <DBItem EmailAddressStatus.PREFERRED...134 <DBItem EmailAddressStatus.PREFERRED...
137135
138 >>> p.account_status136 >>> p.account_status
137 <DBItem AccountStatus.NOACCOUNT...
138
139 >>> from canonical.launchpad.interfaces.lpstorm import IMasterStore
140 >>> from canonical.launchpad.database.account import Account
141 >>> account = IMasterStore(Account).get(Account, p.accountID)
142 >>> account.activate(
143 ... "Activated by doc test.",
144 ... password=p.password,
145 ... preferred_email=email)
146 >>> p.account_status
139 <DBItem AccountStatus.ACTIVE...147 <DBItem AccountStatus.ACTIVE...
140148
141The user can add additional email addresses. The149The user can add additional email addresses. The
142150
=== modified file 'lib/lp/registry/model/person.py'
--- lib/lp/registry/model/person.py 2010-04-23 14:22:30 +0000
+++ lib/lp/registry/model/person.py 2010-04-23 20:24:38 +0000
@@ -2091,17 +2091,6 @@
2091 if email is None:2091 if email is None:
2092 self._unsetPreferredEmail()2092 self._unsetPreferredEmail()
2093 return2093 return
2094 if (self.preferredemail is None
2095 and self.account_status != AccountStatus.ACTIVE):
2096 # XXX sinzui 2008-07-14 bug=248518:
2097 # This is a hack to preserve this function's behaviour before
2098 # Account was split from Person. This can be removed when
2099 # all the callsites ensure that the account is ACTIVE first.
2100 account = IMasterStore(Account).get(Account, self.accountID)
2101 account.activate(
2102 "Activated when the preferred email was set.",
2103 password=self.password,
2104 preferred_email=email)
2105 self._setPreferredEmail(email)2094 self._setPreferredEmail(email)
21062095
2107 def _setPreferredEmail(self, email):2096 def _setPreferredEmail(self, email):
21082097
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2010-04-23 02:35:47 +0000
+++ lib/lp/testing/factory.py 2010-04-23 20:24:38 +0000
@@ -400,10 +400,10 @@
400 # To make the person someone valid in Launchpad, validate the400 # To make the person someone valid in Launchpad, validate the
401 # email.401 # email.
402 if email_address_status == EmailAddressStatus.PREFERRED:402 if email_address_status == EmailAddressStatus.PREFERRED:
403 person.validateAndEnsurePreferredEmail(email)
404 account = IMasterStore(Account).get(403 account = IMasterStore(Account).get(
405 Account, person.accountID)404 Account, person.accountID)
406 account.status = AccountStatus.ACTIVE405 account.status = AccountStatus.ACTIVE
406 person.validateAndEnsurePreferredEmail(email)
407407
408 removeSecurityProxy(email).status = email_address_status408 removeSecurityProxy(email).status = email_address_status
409409
@@ -448,6 +448,13 @@
448 PersonCreationRationale.OWNER_CREATED_LAUNCHPAD,448 PersonCreationRationale.OWNER_CREATED_LAUNCHPAD,
449 name=variable_name, displayname=full_name)449 name=variable_name, displayname=full_name)
450 if set_preferred_email:450 if set_preferred_email:
451 # setPreferredEmail no longer activates the account
452 # automatically.
453 account = IMasterStore(Account).get(Account, person.accountID)
454 account.activate(
455 "Activated by factory.makePersonByName",
456 password='foo',
457 preferred_email=email)
451 person.setPreferredEmail(email)458 person.setPreferredEmail(email)
452459
453 if not use_default_autosubscribe_policy:460 if not use_default_autosubscribe_policy:
@@ -1358,7 +1365,7 @@
1358 def makePackageCodeImport(self, sourcepackage=None, **kwargs):1365 def makePackageCodeImport(self, sourcepackage=None, **kwargs):
1359 """Make a code import targetting a sourcepackage."""1366 """Make a code import targetting a sourcepackage."""
1360 if sourcepackage is None:1367 if sourcepackage is None:
1361 sourcepackage = self.makeSourcePackage()1368 sourcepackage = self.makeSourcePackage()
1362 target = IBranchTarget(sourcepackage)1369 target = IBranchTarget(sourcepackage)
1363 return self.makeCodeImport(target=target, **kwargs)1370 return self.makeCodeImport(target=target, **kwargs)
13641371