Merge lp:~jml/launchpad/owner-cannot-write-to-official-branch-516709 into lp:launchpad

Proposed by Jonathan Lange
Status: Rejected
Rejected by: Jonathan Lange
Proposed branch: lp:~jml/launchpad/owner-cannot-write-to-official-branch-516709
Merge into: lp:launchpad
Diff against target: 44 lines (+9/-15)
1 file modified
lib/canonical/launchpad/security.py (+9/-15)
To merge this branch: bzr merge lp:~jml/launchpad/owner-cannot-write-to-official-branch-516709
Reviewer Review Type Date Requested Status
Canonical Launchpad Engineering Pending
Review via email: mp+29446@code.launchpad.net

Description of the change

This branch demonstrates how to fix bug 516709

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/security.py'
2--- lib/canonical/launchpad/security.py 2010-06-30 13:49:38 +0000
3+++ lib/canonical/launchpad/security.py 2010-07-08 13:34:12 +0000
4@@ -1703,10 +1703,12 @@
5 usedfor = IBranch
6
7 def checkAuthenticated(self, user):
8+ ssp_list = self.obj.associatedSuiteSourcePackages()
9+ if ssp_list:
10+ return can_upload_linked_package(user, self.obj, ssp_list)
11 can_edit = (
12 user.inTeam(self.obj.owner) or
13- user_has_special_branch_access(user.person) or
14- can_upload_linked_package(user, self.obj))
15+ user_has_special_branch_access(user.person))
16 if can_edit:
17 return True
18 # It used to be the case that all import branches were owned by the
19@@ -1724,20 +1726,12 @@
20 and user.inTeam(code_import.registrant)))
21
22
23-def can_upload_linked_package(person_role, branch):
24+def can_upload_linked_package(person_role, branch, ssp_list):
25 """True if person may upload the package linked to `branch`."""
26- # No associated `ISuiteSourcePackage` data -> not an official branch.
27- # Abort.
28- ssp_list = branch.associatedSuiteSourcePackages()
29- if len(ssp_list) < 1:
30- return False
31-
32- # XXX al-maisan, 2009-10-20: a branch may currently be associated with a
33- # number of (distroseries, sourcepackagename, pocket) combinations.
34- # This does not seem right. But until the database model is fixed we work
35- # around this by assuming that things are fine as long as we find at least
36- # one combination that allows us to upload the corresponding source
37- # package.
38+ # A branch may currently be associated with a number of (distroseries,
39+ # sourcepackagename, pocket) combinations. A user can edit the branch as
40+ # long as there the user can upload to the archive for at least one
41+ # combination.
42 for ssp in ssp_list:
43 archive = ssp.sourcepackage.get_default_archive()
44 if archive.canUploadSuiteSourcePackage(person_role.person, ssp):