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
=== modified file 'lib/lp/soyuz/doc/archive.txt'
--- lib/lp/soyuz/doc/archive.txt 2009-10-13 11:17:10 +0000
+++ lib/lp/soyuz/doc/archive.txt 2009-10-13 17:15:20 +0000
@@ -1619,6 +1619,26 @@
1619 PPA for Celso Providelo1619 PPA for Celso Providelo
1620 PPA for No Privileges Person1620 PPA for No Privileges Person
16211621
1622This also works via indirect team memberships. Let's make a dummy team
1623and user and give the team access to cprov's PPA:
1624
1625 >>> uploader_team = factory.makeTeam(owner=cprov, name='uploader-team')
1626 >>> indirect_uploader = factory.makePerson(name='indirect-uploader')
1627 >>> cprov_archive.newComponentUploader(uploader_team, "main")
1628 <ArchivePermission ...>
1629
1630'indirect_uploader' currently can't upload to cprov's PPA:
1631
1632 >>> for ppa in archive_set.getPPAsForUser(indirect_uploader):
1633 ... print ppa.displayname
1634
1635But if we make him part of the uploader_team he'll gain access:
1636
1637 >>> uploader_team.addMember(indirect_uploader, indirect_uploader)
1638 >>> for ppa in archive_set.getPPAsForUser(indirect_uploader):
1639 ... print ppa.displayname
1640 PPA for Celso Providelo
1641
1622When there is no active PPA for the team a user participates the1642When there is no active PPA for the team a user participates the
1623method returns an empty SelectResults.1643method returns an empty SelectResults.
16241644
@@ -1896,10 +1916,12 @@
18961916
1897First we create three copy archives for ubuntu:1917First we create three copy archives for ubuntu:
18981918
1899 >>> copy = factory.makeCopyArchiveLocation(distribution=ubuntu,1919 >>> copy_owner1 = factory.makePerson(name="copy-owner1")
1900 ... name="ultimate-copy")1920 >>> copy_owner2 = factory.makePerson(name="copy-owner2")
1901 >>> copy = factory.makeCopyArchiveLocation(distribution=ubuntu,1921 >>> copy = factory.makeCopyArchiveLocation(
1902 ... name="fine-copy")1922 ... distribution=ubuntu, name="ultimate-copy", owner=copy_owner1)
1923 >>> copy = factory.makeCopyArchiveLocation(
1924 ... distribution=ubuntu, name="fine-copy", owner=copy_owner2)
19031925
1904One of the new copy archives will be owned by a team:1926One of the new copy archives will be owned by a team:
19051927
@@ -1917,10 +1939,10 @@
1917 ... ubuntu, purposes=[ArchivePurpose.COPY])1939 ... ubuntu, purposes=[ArchivePurpose.COPY])
1918 >>> print_archive_names(ubuntu_copy_archives)1940 >>> print_archive_names(ubuntu_copy_archives)
1919 Name Owner Private Enabled1941 Name Owner Private Enabled
1920 fine-copy person-name12 False True1942 fine-copy copy-owner2 False True
1921 my-copy-archive person-name6 False True1943 my-copy-archive person-name6 False True
1922 team-archive t1 False True1944 team-archive t1 False True
1923 ultimate-copy person-name9 False True1945 ultimate-copy copy-owner1 False True
19241946
1925The `getArchivesForDistribution` method can also be used to get an1947The `getArchivesForDistribution` method can also be used to get an
1926archive using an archive name:1948archive using an archive name:
@@ -1947,8 +1969,8 @@
1947 ... ubuntu, purposes=[ArchivePurpose.COPY])1969 ... ubuntu, purposes=[ArchivePurpose.COPY])
1948 >>> print_archive_names(ubuntu_copy_archives)1970 >>> print_archive_names(ubuntu_copy_archives)
1949 Name Owner Private Enabled1971 Name Owner Private Enabled
1950 fine-copy person-name12 False True1972 fine-copy copy-owner2 False True
1951 ultimate-copy person-name9 False True1973 ultimate-copy copy-owner1 False True
19521974
1953Similarly, a user who has no privs for the private archive will not see1975Similarly, a user who has no privs for the private archive will not see
1954the private archives:1976the private archives:
@@ -1957,8 +1979,8 @@
1957 ... ubuntu, purposes=[ArchivePurpose.COPY], user=cprov)1979 ... ubuntu, purposes=[ArchivePurpose.COPY], user=cprov)
1958 >>> print_archive_names(ubuntu_copy_archives)1980 >>> print_archive_names(ubuntu_copy_archives)
1959 Name Owner Private Enabled1981 Name Owner Private Enabled
1960 fine-copy person-name12 False True1982 fine-copy copy-owner2 False True
1961 ultimate-copy person-name9 False True1983 ultimate-copy copy-owner1 False True
19621984
1963The owner of the archive will also see their private archive in the results:1985The owner of the archive will also see their private archive in the results:
19641986
@@ -1967,9 +1989,9 @@
1967 ... user=my_copy_archive.owner)1989 ... user=my_copy_archive.owner)
1968 >>> print_archive_names(ubuntu_copy_archives)1990 >>> print_archive_names(ubuntu_copy_archives)
1969 Name Owner Private Enabled1991 Name Owner Private Enabled
1970 fine-copy person-name12 False True1992 fine-copy copy-owner2 False True
1971 my-copy-archive person-name6 True True1993 my-copy-archive person-name6 True True
1972 ultimate-copy person-name9 False True1994 ultimate-copy copy-owner1 False True
19731995
1974An admin will see all the private and disabled archives in the results:1996An admin will see all the private and disabled archives in the results:
19751997
@@ -1978,11 +2000,11 @@
1978 ... ubuntu, purposes=[ArchivePurpose.COPY], user=foobar)2000 ... ubuntu, purposes=[ArchivePurpose.COPY], user=foobar)
1979 >>> print_archive_names(ubuntu_copy_archives)2001 >>> print_archive_names(ubuntu_copy_archives)
1980 Name Owner Private Enabled2002 Name Owner Private Enabled
1981 fine-copy person-name12 False True2003 fine-copy copy-owner2 False True
1982 my-copy-archive person-name6 True True2004 my-copy-archive person-name6 True True
1983 team-archive t1 True True2005 team-archive t1 True True
1984 there-we-go juergen False False2006 there-we-go juergen False False
1985 ultimate-copy person-name9 False True2007 ultimate-copy copy-owner1 False True
19862008
1987And if the archive is owned by a team, then anyone in the team will also2009And if the archive is owned by a team, then anyone in the team will also
1988be able to view the private team archive:2010be able to view the private team archive:
@@ -1992,9 +2014,9 @@
1992 ... ubuntu, purposes=[ArchivePurpose.COPY], user=cprov)2014 ... ubuntu, purposes=[ArchivePurpose.COPY], user=cprov)
1993 >>> print_archive_names(ubuntu_copy_archives)2015 >>> print_archive_names(ubuntu_copy_archives)
1994 Name Owner Private Enabled2016 Name Owner Private Enabled
1995 fine-copy person-name12 False True2017 fine-copy copy-owner2 False True
1996 team-archive t1 True True2018 team-archive t1 True True
1997 ultimate-copy person-name9 False True2019 ultimate-copy copy-owner1 False True
19982020
19992021
2000== Getting publishing records across a set of Archives ==2022== Getting publishing records across a set of Archives ==
20012023
=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py 2009-10-13 11:17:10 +0000
+++ lib/lp/soyuz/model/archive.py 2009-10-13 17:15:20 +0000
@@ -1424,14 +1424,15 @@
1424 TeamParticipation.team == Archive.ownerID,1424 TeamParticipation.team == Archive.ownerID,
1425 TeamParticipation.person == user,1425 TeamParticipation.person == user,
1426 )1426 )
1427 third_part_upload_acl = store.find(1427 third_party_upload_acl = store.find(
1428 Archive,1428 Archive,
1429 Archive.purpose == ArchivePurpose.PPA,1429 Archive.purpose == ArchivePurpose.PPA,
1430 ArchivePermission.archiveID == Archive.id,1430 ArchivePermission.archiveID == Archive.id,
1431 ArchivePermission.person == user,1431 TeamParticipation.person == user,
1432 TeamParticipation.team == ArchivePermission.personID,
1432 )1433 )
14331434
1434 result = direct_membership.union(third_part_upload_acl)1435 result = direct_membership.union(third_party_upload_acl)
1435 result.order_by(Archive.displayname)1436 result.order_by(Archive.displayname)
14361437
1437 return result1438 return result