Merge lp:~michael.nelson/launchpad/506203-ppa-privatisation-check into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Graham Binns on 2010-02-16 |
| Approved revision: | not available |
| Merged at revision: | not available |
| Proposed branch: | lp:~michael.nelson/launchpad/506203-ppa-privatisation-check |
| Merge into: | lp:launchpad |
| Diff against target: |
287 lines (+179/-10) 5 files modified
lib/lp/soyuz/browser/archive.py (+8/-0) lib/lp/soyuz/browser/tests/test_archive_admin_view.py (+95/-0) lib/lp/soyuz/interfaces/archive.py (+10/-1) lib/lp/soyuz/model/archive.py (+17/-7) lib/lp/soyuz/tests/test_archive.py (+49/-2) |
| To merge this branch: | bzr merge lp:~michael.nelson/launchpad/506203-ppa-privatisation-check |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Graham Binns (community) | code | 2010-02-16 | Approve on 2010-02-16 |
|
Review via email:
|
|||
| Michael Nelson (michael.nelson) wrote : | # |
| Graham Binns (gmb) wrote : | # |
Hi Michael,
Nice branch; thanks for fixing this. A couple of nitpicks, but nothing
major. Otherwise this is r=me.
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -1802,6 +1802,14 @@
> """
> form.getWidgets
>
> + if data.get('private') != self.context.
> + # The privacy is being switched.
> + if self.context.
You should use
if not self.context.
rather than checking .count() > 0 as it's more efficient.
> + self.setFieldError(
> + 'private',
> + 'This archive already has published sources. It is '
> + 'not possible to switch the privacy.')
> +
> if data.get(
> self.setFieldError(
> 'buildd_secret',
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -112,10 +113,19 @@
> If the owner of the archive is private, then the archive cannot be
> made public.
> """
> - if not value:
> + if value is False:
> # The archive is transitioning from public to private.
> assert self.owner.
> "Private teams may not have public PPAs.")
> +
> + # If the privacy is being changed ensure there are no sources
> + # published.
> + sources_count = self.getPublish
> + if sources_count > 0:
You should use .is_empty() here, too.
> + raise CannotSwitchPri
> + "This archive has had %d sources published and therefore "
> + "cannot have its privacy switched." % sources_count)
> +
> return value
>
> name = StringCol(
| Michael Nelson (michael.nelson) wrote : | # |
17:37 < noodles775> gmb: lol, re. the is_empty()... we hit the same point last week. I tried is_empty first, but it's not part of ISQLObjectResul
17:38 < gmb> noodles775: Oh, sod. I hate that shim. Okay, checking .count() is an acceptable alternative then.

= Summary =
This branch ensures that the privacy of a PPA cannot be changed once there are published sources for the PPA. It does so both on the model (ie. API usage) as well as on the view.
There will be a second branch following which will update a gazillion tests that switch the privacy of PPAs during tests. And then a third which will just update the UI to present a disabled checkbox when appropriate.
== Implementation details ==
I'd hoped to find a solution that would enable me to re-use the same validation code on both the model and the view (initially I thought a validation constraint defined on the interface might do the job, but it doesn't).
The only way I could see to reuse the code directly would be to add something like validateArchive Privacy( ) on the interface, but that doesn't seem sane either.
== Tests == acySwitching
To test:
bin/test -vvt TestArchivePriv
== Demo and Q/A ==
Visit: /launchpad. dev/~cprov/ +archive/ ppa
https:/
login as <email address hidden> and click on Administer archive, then try changing the checkbox.
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files: soyuz/browser/ tests/test_ archive_ admin_view. py soyuz/tests/ test_archive. py soyuz/interface s/archive. py soyuz/model/ archive. py soyuz/browser/ archive. py
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
== Pylint notices ==
lib/lp/ soyuz/interface s/archive. py declarations' (No module named restful) fields' (No module named restful) newPackagesetUp loader] Operator not preceded by a space
41: [F0401] Unable to import 'lazr.enum' (No module named enum)
54: [F0401] Unable to import 'lazr.restful.
60: [F0401] Unable to import 'lazr.restful.
457: [C0322, IArchivePublic.
packageset= Reference( _("Explicit" ), required=False))
^
Interface, title=_("Package set"), required=True),
explicit=Bool(
title=
followed by a few dozen more of the same incorrect lint report?