Merge lp:~julian-edwards/launchpad/team-uploader-copy-packages-bug-445828 into lp:launchpad

Proposed by Julian Edwards
Status: Merged
Merged at revision: not available
Proposed branch: lp:~julian-edwards/launchpad/team-uploader-copy-packages-bug-445828
Merge into: lp:launchpad
Diff against target: 143 lines
2 files modified
lib/lp/soyuz/doc/archive.txt (+38/-16)
lib/lp/soyuz/model/archive.py (+4/-3)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/team-uploader-copy-packages-bug-445828
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+13294@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

= Summary =
Allow third-party PPA uploaders copy access to a PPA when they have indirect
permissions via a team.

== Proposed fix ==
See bug https://bugs.edge.launchpad.net/soyuz/+bug/445828

When copying packages from a PPA, the drop-down list didn't include PPAs that
it should do if you were an indirect uploader by virtue of third-party
permissions on a team you're in.

== Pre-implementation notes ==
This is a trivial fix to join via TeamParticipation when needed.

== Implementation details ==
Because the archive.txt doctest was being particularly dense in relying on a
bunch of person names that were auto-generated by makePerson in the test
factory, I also had to make some other unrelated test fixes.

== Tests ==
bin/test -cvvt tests.*/doc/archive.txt

== Demo and Q/A ==
Dogfood FTW.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/soyuz/doc/archive.txt
  lib/lp/soyuz/model/archive.py

== Pylint notices ==

lib/lp/soyuz/model/archive.py
    14: [F0401] Unable to import 'lazr.lifecycle.event' (No module named
lifecycle)

Revision history for this message
Brad Crittenden (bac) :
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/soyuz/doc/archive.txt'
2--- lib/lp/soyuz/doc/archive.txt 2009-10-13 11:17:10 +0000
3+++ lib/lp/soyuz/doc/archive.txt 2009-10-13 17:15:20 +0000
4@@ -1619,6 +1619,26 @@
5 PPA for Celso Providelo
6 PPA for No Privileges Person
7
8+This also works via indirect team memberships. Let's make a dummy team
9+and user and give the team access to cprov's PPA:
10+
11+ >>> uploader_team = factory.makeTeam(owner=cprov, name='uploader-team')
12+ >>> indirect_uploader = factory.makePerson(name='indirect-uploader')
13+ >>> cprov_archive.newComponentUploader(uploader_team, "main")
14+ <ArchivePermission ...>
15+
16+'indirect_uploader' currently can't upload to cprov's PPA:
17+
18+ >>> for ppa in archive_set.getPPAsForUser(indirect_uploader):
19+ ... print ppa.displayname
20+
21+But if we make him part of the uploader_team he'll gain access:
22+
23+ >>> uploader_team.addMember(indirect_uploader, indirect_uploader)
24+ >>> for ppa in archive_set.getPPAsForUser(indirect_uploader):
25+ ... print ppa.displayname
26+ PPA for Celso Providelo
27+
28 When there is no active PPA for the team a user participates the
29 method returns an empty SelectResults.
30
31@@ -1896,10 +1916,12 @@
32
33 First we create three copy archives for ubuntu:
34
35- >>> copy = factory.makeCopyArchiveLocation(distribution=ubuntu,
36- ... name="ultimate-copy")
37- >>> copy = factory.makeCopyArchiveLocation(distribution=ubuntu,
38- ... name="fine-copy")
39+ >>> copy_owner1 = factory.makePerson(name="copy-owner1")
40+ >>> copy_owner2 = factory.makePerson(name="copy-owner2")
41+ >>> copy = factory.makeCopyArchiveLocation(
42+ ... distribution=ubuntu, name="ultimate-copy", owner=copy_owner1)
43+ >>> copy = factory.makeCopyArchiveLocation(
44+ ... distribution=ubuntu, name="fine-copy", owner=copy_owner2)
45
46 One of the new copy archives will be owned by a team:
47
48@@ -1917,10 +1939,10 @@
49 ... ubuntu, purposes=[ArchivePurpose.COPY])
50 >>> print_archive_names(ubuntu_copy_archives)
51 Name Owner Private Enabled
52- fine-copy person-name12 False True
53+ fine-copy copy-owner2 False True
54 my-copy-archive person-name6 False True
55 team-archive t1 False True
56- ultimate-copy person-name9 False True
57+ ultimate-copy copy-owner1 False True
58
59 The `getArchivesForDistribution` method can also be used to get an
60 archive using an archive name:
61@@ -1947,8 +1969,8 @@
62 ... ubuntu, purposes=[ArchivePurpose.COPY])
63 >>> print_archive_names(ubuntu_copy_archives)
64 Name Owner Private Enabled
65- fine-copy person-name12 False True
66- ultimate-copy person-name9 False True
67+ fine-copy copy-owner2 False True
68+ ultimate-copy copy-owner1 False True
69
70 Similarly, a user who has no privs for the private archive will not see
71 the private archives:
72@@ -1957,8 +1979,8 @@
73 ... ubuntu, purposes=[ArchivePurpose.COPY], user=cprov)
74 >>> print_archive_names(ubuntu_copy_archives)
75 Name Owner Private Enabled
76- fine-copy person-name12 False True
77- ultimate-copy person-name9 False True
78+ fine-copy copy-owner2 False True
79+ ultimate-copy copy-owner1 False True
80
81 The owner of the archive will also see their private archive in the results:
82
83@@ -1967,9 +1989,9 @@
84 ... user=my_copy_archive.owner)
85 >>> print_archive_names(ubuntu_copy_archives)
86 Name Owner Private Enabled
87- fine-copy person-name12 False True
88+ fine-copy copy-owner2 False True
89 my-copy-archive person-name6 True True
90- ultimate-copy person-name9 False True
91+ ultimate-copy copy-owner1 False True
92
93 An admin will see all the private and disabled archives in the results:
94
95@@ -1978,11 +2000,11 @@
96 ... ubuntu, purposes=[ArchivePurpose.COPY], user=foobar)
97 >>> print_archive_names(ubuntu_copy_archives)
98 Name Owner Private Enabled
99- fine-copy person-name12 False True
100+ fine-copy copy-owner2 False True
101 my-copy-archive person-name6 True True
102 team-archive t1 True True
103 there-we-go juergen False False
104- ultimate-copy person-name9 False True
105+ ultimate-copy copy-owner1 False True
106
107 And if the archive is owned by a team, then anyone in the team will also
108 be able to view the private team archive:
109@@ -1992,9 +2014,9 @@
110 ... ubuntu, purposes=[ArchivePurpose.COPY], user=cprov)
111 >>> print_archive_names(ubuntu_copy_archives)
112 Name Owner Private Enabled
113- fine-copy person-name12 False True
114+ fine-copy copy-owner2 False True
115 team-archive t1 True True
116- ultimate-copy person-name9 False True
117+ ultimate-copy copy-owner1 False True
118
119
120 == Getting publishing records across a set of Archives ==
121
122=== modified file 'lib/lp/soyuz/model/archive.py'
123--- lib/lp/soyuz/model/archive.py 2009-10-13 11:17:10 +0000
124+++ lib/lp/soyuz/model/archive.py 2009-10-13 17:15:20 +0000
125@@ -1424,14 +1424,15 @@
126 TeamParticipation.team == Archive.ownerID,
127 TeamParticipation.person == user,
128 )
129- third_part_upload_acl = store.find(
130+ third_party_upload_acl = store.find(
131 Archive,
132 Archive.purpose == ArchivePurpose.PPA,
133 ArchivePermission.archiveID == Archive.id,
134- ArchivePermission.person == user,
135+ TeamParticipation.person == user,
136+ TeamParticipation.team == ArchivePermission.personID,
137 )
138
139- result = direct_membership.union(third_part_upload_acl)
140+ result = direct_membership.union(third_party_upload_acl)
141 result.order_by(Archive.displayname)
142
143 return result