Merge lp:~wallyworld/launchpad/person-vocab-1006244 into lp:launchpad

Proposed by Ian Booth
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 15346
Proposed branch: lp:~wallyworld/launchpad/person-vocab-1006244
Merge into: lp:launchpad
Diff against target: 62 lines (+19/-0)
2 files modified
lib/lp/registry/tests/test_person_vocabularies.py (+13/-0)
lib/lp/registry/vocabularies.py (+6/-0)
To merge this branch: bzr merge lp:~wallyworld/launchpad/person-vocab-1006244
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+108124@code.launchpad.net

Commit message

Add extra account check to person vocab search so that inactive people are not included

Description of the change

== Implementation ==

This branch filters people with inactive accounts from person vocab results.

Add a new left join to Account table main person query and filter result on active accounts or teams.
Query was checked on dogfood and its all good.

== Tests ==

Add new test to test_person_vocabularies:
- test_inactive_people_ignored

Run existing vocab tests to check that other queries still work.

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/vocabularies.py
  lib/lp/registry/tests/test_person_vocabularies.py

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

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/tests/test_person_vocabularies.py'
2--- lib/lp/registry/tests/test_person_vocabularies.py 2012-04-11 02:15:10 +0000
3+++ lib/lp/registry/tests/test_person_vocabularies.py 2012-05-31 08:51:19 +0000
4@@ -20,6 +20,7 @@
5 TeamSubscriptionPolicy,
6 )
7 from lp.registry.vocabularies import ValidPersonOrTeamVocabulary
8+from lp.services.identity.interfaces.account import AccountStatus
9 from lp.services.webapp.vocabulary import FilteredVocabularyBase
10 from lp.testing import (
11 login_person,
12@@ -155,6 +156,18 @@
13 results = self.searchVocabulary(None, u'fred', 'TEAM')
14 self.assertContentEqual(teams, list(results))
15
16+ def test_inactive_people_ignored(self):
17+ # Only people with active accounts (or teams) are returned.
18+ for status in AccountStatus:
19+ if status.value != AccountStatus.ACTIVE:
20+ self.factory.makePerson(
21+ name='fred' + status.token.lower(),
22+ account_status=status.value)
23+ active_person = self.factory.makePerson(name='fredactive')
24+ team = self.factory.makePerson(name='fredteam')
25+ results = self.searchVocabulary(None, 'fred')
26+ self.assertContentEqual([active_person, team], list(results))
27+
28
29 class TestValidPersonOrTeamVocabulary(ValidPersonOrTeamVocabularyMixin,
30 TestCaseWithFactory):
31
32=== modified file 'lib/lp/registry/vocabularies.py'
33--- lib/lp/registry/vocabularies.py 2012-05-29 03:16:43 +0000
34+++ lib/lp/registry/vocabularies.py 2012-05-31 08:51:19 +0000
35@@ -180,7 +180,9 @@
36 ensure_unicode,
37 shortlist,
38 )
39+from lp.services.identity.interfaces.account import AccountStatus
40 from lp.services.identity.interfaces.emailaddress import EmailAddressStatus
41+from lp.services.identity.model.account import Account
42 from lp.services.identity.model.emailaddress import EmailAddress
43 from lp.services.propertycache import (
44 cachedproperty,
45@@ -701,6 +703,7 @@
46 SQL("MatchingPerson"),
47 Person,
48 LeftJoin(EmailAddress, EmailAddress.person == Person.id),
49+ LeftJoin(Account, Account.id == Person.accountID),
50 ]
51
52 # If private_tables is empty, we are searching for all private
53@@ -721,6 +724,9 @@
54 And(
55 SQL("Person.id = MatchingPerson.id"),
56 Or(
57+ Account.status == AccountStatus.ACTIVE,
58+ Person.teamowner != None),
59+ Or(
60 And( # A public person or team
61 Person.visibility == PersonVisibility.PUBLIC,
62 Person.merged == None,