Re: [Launchpad-reviewers] [Merge] ~pappacena/launchpad:oci-bug-indexes into launchpad:db-devel

2021-04-09 Thread William Grant
Review: Approve db


-- 
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/393579
Your team Launchpad code reviewers is subscribed to branch 
~pappacena/launchpad:oci-bug-add-oci-columns.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~cjwatson/launchpad:archive-subscriptions-query-count into launchpad:master

2021-04-09 Thread Colin Watson
Colin Watson has proposed merging 
~cjwatson/launchpad:archive-subscriptions-query-count into launchpad:master.

Commit message:
Fix Archive:+subscriptions timeouts with many existing subscriptions

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1851834 in Launchpad itself: "Timeout error when managing access of the 
fips-updates  PPA"
  https://bugs.launchpad.net/launchpad/+bug/1851834

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/400914

Archive:+subscriptions could easily time out when the archive had many existing 
subscriptions, especially if there were subscriptions for private teams, 
because it did permission checks individually on each subscriber.  We know 
up-front that users viewing this page have sufficient privilege that they 
should be able to at least see the identity of all the existing subscribers, so 
preload the necessary permissions.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/launchpad:archive-subscriptions-query-count into launchpad:master.
diff --git a/lib/lp/security.py b/lib/lp/security.py
index 03b35bd..412f497 100644
--- a/lib/lp/security.py
+++ b/lib/lp/security.py
@@ -2912,7 +2912,7 @@ class ViewPersonalArchiveSubscription(DelegatedAuthorization):
 class ViewArchiveSubscriber(DelegatedAuthorization):
 """Restrict viewing of archive subscribers.
 
-The user should be the subscriber, have edit privilege to the
+The user should be the subscriber, have append privilege to the
 archive or be an admin.
 """
 permission = "launchpad.View"
diff --git a/lib/lp/soyuz/browser/archivesubscription.py b/lib/lp/soyuz/browser/archivesubscription.py
index 47ab800..f05a506 100644
--- a/lib/lp/soyuz/browser/archivesubscription.py
+++ b/lib/lp/soyuz/browser/archivesubscription.py
@@ -14,7 +14,6 @@ __all__ = [
 ]
 
 import datetime
-from operator import attrgetter
 
 import pytz
 from zope.component import getUtility
@@ -44,6 +43,7 @@ from lp.services.propertycache import (
 cachedproperty,
 get_property_cache,
 )
+from lp.services.webapp.authorization import precache_permission_for_objects
 from lp.services.webapp.batching import (
 BatchNavigator,
 StormRangeFactory,
@@ -164,9 +164,18 @@ class ArchiveSubscribersView(LaunchpadFormView):
 Bulk loads the related Person records.
 """
 batch = list(self.batchnav.currentBatch())
+# If the user can see this view, then they must have Append
+# permission on the archive, which grants View permission on all its
+# subscriptions.  Skip slow privacy checks.
+precache_permission_for_objects(self.request, 'launchpad.View', batch)
 ids = [subscription.subscriber_id for subscription in batch]
-list(getUtility(IPersonSet).getPrecachedPersonsFromIDs(ids,
-need_validity=True))
+subscribers = list(
+getUtility(IPersonSet).getPrecachedPersonsFromIDs(
+ids, need_validity=True))
+# People who can manage subscriptions to this archive are entitled
+# to at least limited visibility of its existing subscribers.
+precache_permission_for_objects(
+self.request, 'launchpad.LimitedView', subscribers)
 return batch
 
 @cachedproperty
diff --git a/lib/lp/soyuz/tests/test_archivesubscriptionview.py b/lib/lp/soyuz/browser/tests/test_archivesubscription.py
similarity index 79%
rename from lib/lp/soyuz/tests/test_archivesubscriptionview.py
rename to lib/lp/soyuz/browser/tests/test_archivesubscription.py
index 5634fc7..73d771b 100644
--- a/lib/lp/soyuz/tests/test_archivesubscriptionview.py
+++ b/lib/lp/soyuz/browser/tests/test_archivesubscription.py
@@ -13,12 +13,17 @@ from soupmatchers import (
 )
 from zope.component import getUtility
 
+from lp.registry.enums import PersonVisibility
 from lp.registry.interfaces.person import IPersonSet
+from lp.services.webapp import canonical_url
 from lp.testing import (
+login_person,
 person_logged_in,
+record_two_runs,
 TestCaseWithFactory,
 )
 from lp.testing.layers import LaunchpadFunctionalLayer
+from lp.testing.matchers import HasQueryCount
 from lp.testing.views import create_initialized_view
 
 
@@ -49,3 +54,21 @@ class TestArchiveSubscribersView(TestCaseWithFactory):
 Tag('batch navigation links', 'td',
 attrs={'class': 'batch-navigation-links'}, count=2))
 self.assertThat(html, has_batch_navigation)
+
+def test_constant_query_count(self):
+def create_subscribers():
+self.private_ppa.newSubscription(
+self.factory.makePerson(), self.p3a_owner)
+self.private_ppa.newSubscription(
+self.factory.makeTeam(
+visibility=PersonVisibility.PRIVATE,
+members=[self.p3a_owner]),
+self.p3a_owner)
+
+

[Launchpad-reviewers] [Merge] ~cjwatson/lp-source-dependencies:cleanup-202104 into lp-source-dependencies:master

2021-04-09 Thread Colin Watson
Colin Watson has proposed merging 
~cjwatson/lp-source-dependencies:cleanup-202104 into 
lp-source-dependencies:master.

Commit message:
Remove lots of obsolete dependencies

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/lp-source-dependencies/+git/lp-source-dependencies/+merge/400913

This takes a clean checkout (excluding .git) from 403M to 160M.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/lp-source-dependencies:cleanup-202104 into 
lp-source-dependencies:master.
diff --git a/dist/BTrees-4.5.1.tar.gz b/dist/BTrees-4.5.1.tar.gz
deleted file mode 100644
index f1ec11f..000
Binary files a/dist/BTrees-4.5.1.tar.gz and /dev/null differ
diff --git a/dist/BTrees-4.7.1.tar.gz b/dist/BTrees-4.7.1.tar.gz
deleted file mode 100644
index 6d1ad25..000
Binary files a/dist/BTrees-4.7.1.tar.gz and /dev/null differ
diff --git a/dist/Babel-2.5.1.tar.gz b/dist/Babel-2.5.1.tar.gz
deleted file mode 100644
index 979f44b..000
Binary files a/dist/Babel-2.5.1.tar.gz and /dev/null differ
diff --git a/dist/Babel-2.6.0.tar.gz b/dist/Babel-2.6.0.tar.gz
deleted file mode 100644
index 2735874..000
Binary files a/dist/Babel-2.6.0.tar.gz and /dev/null differ
diff --git a/dist/BeautifulSoup-3.2.1.tar.gz b/dist/BeautifulSoup-3.2.1.tar.gz
deleted file mode 100644
index 777f4f6..000
Binary files a/dist/BeautifulSoup-3.2.1.tar.gz and /dev/null differ
diff --git a/dist/Chameleon-2.11.tar.gz b/dist/Chameleon-2.11.tar.gz
deleted file mode 100644
index 2eb6f77..000
Binary files a/dist/Chameleon-2.11.tar.gz and /dev/null differ
diff --git a/dist/CherryPy-3.1.2.zip b/dist/CherryPy-3.1.2.zip
deleted file mode 100644
index ff7fade..000
Binary files a/dist/CherryPy-3.1.2.zip and /dev/null differ
diff --git a/dist/ClientForm-0.2.10.tar.gz b/dist/ClientForm-0.2.10.tar.gz
deleted file mode 100644
index 8bfd619..000
Binary files a/dist/ClientForm-0.2.10.tar.gz and /dev/null differ
diff --git a/dist/Flask-0.10.1.tar.gz b/dist/Flask-0.10.1.tar.gz
deleted file mode 100644
index f6a60a1..000
Binary files a/dist/Flask-0.10.1.tar.gz and /dev/null differ
diff --git a/dist/FormEncode-1.2.4.tar.gz b/dist/FormEncode-1.2.4.tar.gz
deleted file mode 100644
index 833c831..000
Binary files a/dist/FormEncode-1.2.4.tar.gz and /dev/null differ
diff --git a/dist/Genshi-0.6.tar.gz b/dist/Genshi-0.6.tar.gz
deleted file mode 100644
index 9b7f12d..000
Binary files a/dist/Genshi-0.6.tar.gz and /dev/null differ
diff --git a/dist/Jinja2-2.10.1.tar.gz b/dist/Jinja2-2.10.1.tar.gz
deleted file mode 100644
index ffd1054..000
Binary files a/dist/Jinja2-2.10.1.tar.gz and /dev/null differ
diff --git a/dist/Jinja2-2.11.1.tar.gz b/dist/Jinja2-2.11.1.tar.gz
deleted file mode 100644
index bf72cad..000
Binary files a/dist/Jinja2-2.11.1.tar.gz and /dev/null differ
diff --git a/dist/Jinja2-2.5.5.tar.gz b/dist/Jinja2-2.5.5.tar.gz
deleted file mode 100644
index e1bbd2c..000
Binary files a/dist/Jinja2-2.5.5.tar.gz and /dev/null differ
diff --git a/dist/Mako-1.0.1.tar.gz b/dist/Mako-1.0.1.tar.gz
deleted file mode 100644
index 0052984..000
Binary files a/dist/Mako-1.0.1.tar.gz and /dev/null differ
diff --git a/dist/Paste-1.7.5.1.tar.gz b/dist/Paste-1.7.5.1.tar.gz
deleted file mode 100644
index 3c6223c..000
Binary files a/dist/Paste-1.7.5.1.tar.gz and /dev/null differ
diff --git a/dist/PasteDeploy-1.3.4.tar.gz b/dist/PasteDeploy-1.3.4.tar.gz
deleted file mode 100644
index 10f1b12..000
Binary files a/dist/PasteDeploy-1.3.4.tar.gz and /dev/null differ
diff --git a/dist/PasteDeploy-1.5.2.tar.gz b/dist/PasteDeploy-1.5.2.tar.gz
deleted file mode 100644
index fd4f9e1..000
Binary files a/dist/PasteDeploy-1.5.2.tar.gz and /dev/null differ
diff --git a/dist/PasteScript-1.7.5.tar.gz b/dist/PasteScript-1.7.5.tar.gz
deleted file mode 100644
index 3c6a5c8..000
Binary files a/dist/PasteScript-1.7.5.tar.gz and /dev/null differ
diff --git a/dist/PasteScript-3.2.0.tar.gz b/dist/PasteScript-3.2.0.tar.gz
deleted file mode 100644
index b2b95c6..000
Binary files a/dist/PasteScript-3.2.0.tar.gz and /dev/null differ
diff --git a/dist/PyMeta-0.5.0.tar.gz b/dist/PyMeta-0.5.0.tar.gz
deleted file mode 100644
index 9d0e05b..000
Binary files a/dist/PyMeta-0.5.0.tar.gz and /dev/null differ
diff --git a/dist/PyNaCl-1.0.1.tar.gz b/dist/PyNaCl-1.0.1.tar.gz
deleted file mode 100644
index 21a1e4e..000
Binary files a/dist/PyNaCl-1.0.1.tar.gz and /dev/null differ
diff --git a/dist/PyYAML-3.10.tar.gz b/dist/PyYAML-3.10.tar.gz
deleted file mode 100644
index 21c26dc..000
Binary files a/dist/PyYAML-3.10.tar.gz and /dev/null differ
diff --git a/dist/PyYAML-3.11.zip b/dist/PyYAML-3.11.zip
deleted file mode 100644
index c361e86..000
Binary files a/dist/PyYAML-3.11.zip and /dev/null differ
diff --git a/dist/Pygments-1.6.tar.gz b/dist/Pygments-1.6.tar.gz
deleted file mode 100644
index 71ddbcf..000
Binary files 

Re: [Launchpad-reviewers] [Merge] ~pappacena/launchpad:oci-bug-indexes into launchpad:db-devel

2021-04-09 Thread Colin Watson
Review: Approve db



Diff comments:

> diff --git a/database/schema/patch-2210-22-1.sql 
> b/database/schema/patch-2210-22-1.sql
> new file mode 100644
> index 000..4a00207
> --- /dev/null
> +++ b/database/schema/patch-2210-22-1.sql
> @@ -0,0 +1,135 @@
> +-- Copyright 2020 Canonical Ltd.  This software is licensed under the
> +-- GNU Affero General Public License version 3 (see the file LICENSE).
> +
> +SET client_min_messages=ERROR;
> +
> +-- Validate check constraint.
> +ALTER TABLE BugTask VALIDATE CONSTRAINT bugtask_assignment_checks;
> +
> +ALTER TABLE BugSummary VALIDATE CONSTRAINT bugtask_assignment_checks;
> +
> +-- BugTask indexes.
> +CREATE UNIQUE INDEX bugtask__ociproject__bug__idx
> +ON BugTask (ociproject, bug)
> +WHERE ociproject IS NOT NULL;
> +CREATE UNIQUE INDEX bugtask__ociprojectseries__bug__idx
> +ON BugTask (ociprojectseries, bug)
> +WHERE ociprojectseries IS NOT NULL;

The names of these two should end with "__key" rather than "__idx", matching 
our usual practice for unique indexes.

> +
> +-- BugTaskFlat indexes.
> +CREATE INDEX bugtaskflat__ociproject__bug__idx
> +ON BugTaskFlat (ociproject, bug)
> +WHERE ociproject IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociproject__date_closed__bug__idx
> +ON BugTaskFlat (ociproject, date_closed, bug DESC)
> +WHERE ociproject IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociproject__date_last_updated__idx
> +ON BugTaskFlat (ociproject, date_last_updated)
> +WHERE ociproject IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociproject__datecreated__idx
> +ON BugTaskFlat (ociproject, datecreated)
> +WHERE ociproject IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociproject__heat__bug__idx
> +ON BugTaskFlat (ociproject, heat, bug DESC)
> +WHERE ociproject IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociproject__importance__bug__idx
> +ON BugTaskFlat (ociproject, importance, bug DESC)
> +WHERE ociproject IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociproject__latest_patch_uploaded__bug__idx
> +ON BugTaskFlat (ociproject, latest_patch_uploaded, bug DESC)
> +WHERE ociproject IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociproject__status__bug__idx
> +ON BugTaskFlat (ociproject, status, bug DESC)
> +WHERE ociproject IS NOT NULL;
> +
> +CREATE INDEX bugtaskflat__ociprojectseries__bug__idx
> +ON BugTaskFlat (ociprojectseries, bug)
> +WHERE ociprojectseries IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociprojectseries__date_closed__bug__idx
> +ON BugTaskFlat (ociprojectseries, date_closed, bug DESC)
> +WHERE ociprojectseries IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociprojectseries__date_last_updated__idx
> +ON BugTaskFlat (ociprojectseries, date_last_updated)
> +WHERE ociprojectseries IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociprojectseries__datecreated__idx
> +ON BugTaskFlat (ociprojectseries, datecreated)
> +WHERE ociprojectseries IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociprojectseries__heat__bug__idx
> +ON BugTaskFlat (ociprojectseries, heat, bug DESC)
> +WHERE ociprojectseries IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociprojectseries__importance__bug__idx
> +ON BugTaskFlat (ociprojectseries, importance, bug DESC)
> +WHERE ociprojectseries IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociprojectseries__latest_patch_uploaded__bug__idx
> +ON BugTaskFlat (ociprojectseries, latest_patch_uploaded, bug DESC)
> +WHERE ociprojectseries IS NOT NULL;
> +CREATE INDEX bugtaskflat__ociprojectseries__status__bug__idx
> +ON BugTaskFlat (ociprojectseries, status, bug DESC)
> +WHERE ociprojectseries IS NOT NULL;
> +
> +
> +-- BugSummary indexes.
> +CREATE INDEX bugsummary__ociproject__idx
> +ON BugSummary (ociproject)
> +WHERE ociproject IS NOT NULL;
> +CREATE INDEX bugsummary__ociprojectseries__idx
> +ON BugSummary (ociprojectseries)
> +WHERE ociprojectseries IS NOT NULL;
> +
> +
> +-- Replacing previously renamed indexes.
> +CREATE UNIQUE INDEX bugtask_distinct_sourcepackage_assignment
> +ON BugTask (
> +bug,
> +COALESCE(sourcepackagename, -1),
> +COALESCE(distroseries, -1),
> +COALESCE(distribution, -1)
> +)
> +WHERE
> +product IS NULL
> +AND productseries IS NULL
> +AND ociproject IS NULL
> +AND ociprojectseries IS NULL;
> +DROP INDEX old__bugtask_distinct_sourcepackage_assignment;
> +
> +
> +CREATE UNIQUE INDEX bugtask__product__bug__key
> +ON BugTask (product, bug)
> +WHERE
> +product IS NOT NULL
> +AND ociproject IS NULL
> +AND ociprojectseries IS NULL;
> +DROP INDEX old__bugtask__product__bug__key;
> +
> +
> +CREATE UNIQUE INDEX bugsummary__unique
> +ON BugSummary (
> +COALESCE(product, -1),
> +COALESCE(productseries, -1),
> +COALESCE(distribution, -1),
> +COALESCE(distroseries, -1),
> +COALESCE(sourcepackagename, -1),
> +COALESCE(ociproject, -1),
> +

Re: [Launchpad-reviewers] [Merge] ~pappacena/launchpad:ocirecipe-sharing-lists into launchpad:master

2021-04-09 Thread Colin Watson
Review: Approve

Much better, thanks!
-- 
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/400059
Your team Launchpad code reviewers is subscribed to branch 
~pappacena/launchpad:ocirecipe-edit-info-type-ui.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~cjwatson/launchpad:avoid-pristine-ppas-optimize into launchpad:master

2021-04-09 Thread Colin Watson
Colin Watson has proposed merging 
~cjwatson/launchpad:avoid-pristine-ppas-optimize into launchpad:master.

Commit message:
Optimize getArchivesForDistribution(exclude_pristine=True)

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/400911

The previous approach of joining SourcePackagePublishingHistory was extremely 
expensive.  An EXISTS subselect is much quicker (and lets us drop the DISTINCT 
as a bonus).
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/launchpad:avoid-pristine-ppas-optimize into launchpad:master.
diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py
index 5d77a81..0fbca87 100644
--- a/lib/lp/soyuz/model/archive.py
+++ b/lib/lp/soyuz/model/archive.py
@@ -30,6 +30,7 @@ from storm.expr import (
 Cast,
 Count,
 Desc,
+Exists,
 Join,
 Not,
 Or,
@@ -2954,13 +2955,14 @@ class ArchiveSet:
 extra_exprs.append(Archive._enabled == True)
 
 if exclude_pristine:
-extra_exprs.append(
-SourcePackagePublishingHistory.archive == Archive.id)
+extra_exprs.append(Exists(Select(
+1, tables=[SourcePackagePublishingHistory],
+where=(SourcePackagePublishingHistory.archive == Archive.id
 
 query = Store.of(distribution).find(
 Archive,
 Archive.distribution == distribution,
-*extra_exprs).config(distinct=True)
+*extra_exprs)
 
 return query.order_by(Archive.name)
 
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~pappacena/launchpad:ocirecipe-sharing-lists into launchpad:master

2021-04-09 Thread Thiago F. Pappacena
Pushed text and style fixes, and a pre-existing bug on team members count.

Diff comments:

> diff --git a/lib/lp/registry/javascript/sharing/sharingdetails.js 
> b/lib/lp/registry/javascript/sharing/sharingdetails.js
> index 0ac4f32..22db012 100644
> --- a/lib/lp/registry/javascript/sharing/sharingdetails.js
> +++ b/lib/lp/registry/javascript/sharing/sharingdetails.js
> @@ -232,7 +304,7 @@ ns.SharingDetailsTable = 
> Y.Base.create('sharingDetailsTable', Y.Widget, [], {
>  .appendChild('')
>  .setContent(
>  "There are no shared bugs, Bazaar branches, " +
> -"Git repositories, or blueprints.");
> +"Git repositories, Snaps, OCI recipes or 
> blueprints.");

Done.

>  }
>  };
>  var anim_duration = this.get('anim_duration');
> diff --git a/lib/lp/registry/templates/pillar-sharing-details.pt 
> b/lib/lp/registry/templates/pillar-sharing-details.pt
> index dc907dd..8a9a2fe 100644
> --- a/lib/lp/registry/templates/pillar-sharing-details.pt
> +++ b/lib/lp/registry/templates/pillar-sharing-details.pt
> @@ -26,21 +26,32 @@
>
>  
>  
> -  
> -  0 bugs,
> -  0 
> Bazaar branches,
> -   replace="view/shared_gitrepositories_count">0 Git 
> repositories,
> -  0 snaps,
> -  and   -  replace="view/shared_specifications_count">0
> -  blueprints shared with 
> -  grantee.
> -
>
>  3 team members can view these bugs,
> -Bazaar branches, Git repositories, and blueprints.
> +Bazaar branches, Git repositories, snaps recipes, OCI recipes and

Even looking at the code, I missed that hardcoded number.

Replaced the text and added a fix for the count, using 
`team.active_member_count`.

> +blueprints.
>
> -  
> +  Shared with  replace="view/person/displayname">grantee:
> +  

There is another CSS class that better suites this. After using that one, it 
looks like this: 
https://private-fileshare.canonical.com/~pappacena/screenshots/private-oci-recipe/bullet-sharing.png

> +
> +   bugs
> +
> +
> +   Bazaar branches
> +
> +
> +   Git 
> repositories
> +
> +
> +   OCI recipes
> +
> +
> +   snap recipes
> +
> +
> +   blueprints
> +
> +  
>  
>  
>  


-- 
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/400059
Your team Launchpad code reviewers is subscribed to branch 
~pappacena/launchpad:ocirecipe-edit-info-type-ui.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pappacena/launchpad:oci-recipes-link-for-teams into launchpad:master

2021-04-09 Thread noreply
The proposal to merge ~pappacena/launchpad:oci-recipes-link-for-teams into 
launchpad:master has been updated.

Status: Approved => Merged

For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/400897
-- 
Your team Launchpad code reviewers is subscribed to branch 
~pappacena/launchpad:oci-recipes-link-for-teams.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pappacena/launchpad:oci-recipes-link-for-teams into launchpad:master

2021-04-09 Thread Thiago F. Pappacena
The proposal to merge ~pappacena/launchpad:oci-recipes-link-for-teams into 
launchpad:master has been updated.

Status: Needs review => Approved

For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/400897
-- 
Your team Launchpad code reviewers is subscribed to branch 
~pappacena/launchpad:oci-recipes-link-for-teams.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~pappacena/launchpad:oci-recipes-link-for-teams into launchpad:master

2021-04-09 Thread Colin Watson
Review: Approve


-- 
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/400897
Your team Launchpad code reviewers is subscribed to branch 
~pappacena/launchpad:oci-recipes-link-for-teams.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pappacena/launchpad:oci-recipes-link-for-teams into launchpad:master

2021-04-09 Thread Thiago F. Pappacena
Thiago F. Pappacena has proposed merging 
~pappacena/launchpad:oci-recipes-link-for-teams into launchpad:master.

Commit message:
Moving "View OCI recipe" link to correct place and adding it to team page

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/400897
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pappacena/launchpad:oci-recipes-link-for-teams into launchpad:master.
diff --git a/lib/lp/oci/browser/hasocirecipes.py b/lib/lp/oci/browser/hasocirecipes.py
new file mode 100644
index 000..2df4148
--- /dev/null
+++ b/lib/lp/oci/browser/hasocirecipes.py
@@ -0,0 +1,27 @@
+# Copyright 2021 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Mixins for browser classes for objects related to OCI recipe."""
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+'HasOCIRecipesMenuMixin',
+]
+
+from lp.oci.interfaces.ocirecipe import IOCIRecipeSet
+from zope.component import getUtility
+
+from lp.services.webapp import Link
+
+
+class HasOCIRecipesMenuMixin:
+"""A mixin for context menus for objects that has OCI recipes."""
+
+def view_oci_recipes(self):
+target = '+oci-recipes'
+text = 'View OCI recipes'
+enabled = not getUtility(IOCIRecipeSet).findByContext(
+self.context, visible_by_user=self.user).is_empty()
+return Link(target, text, enabled=enabled, icon='info')
diff --git a/lib/lp/registry/browser/person.py b/lib/lp/registry/browser/person.py
index 6d5d8da..2b71694 100644
--- a/lib/lp/registry/browser/person.py
+++ b/lib/lp/registry/browser/person.py
@@ -138,11 +138,9 @@ from lp.code.browser.sourcepackagerecipelisting import HasRecipesMenuMixin
 from lp.code.errors import InvalidNamespace
 from lp.code.interfaces.branchnamespace import IBranchNamespaceSet
 from lp.code.interfaces.gitlookup import IGitTraverser
+from lp.oci.browser.hasocirecipes import HasOCIRecipesMenuMixin
 from lp.oci.interfaces.ocipushrule import IOCIPushRuleSet
-from lp.oci.interfaces.ocirecipe import (
-IOCIRecipe,
-IOCIRecipeSet,
-)
+from lp.oci.interfaces.ocirecipe import IOCIRecipe
 from lp.oci.interfaces.ociregistrycredentials import (
 IOCIRegistryCredentialsSet,
 OCIRegistryCredentialsAlreadyExist,
@@ -777,13 +775,6 @@ class CommonMenuLinks:
 enabled = user_can_edit_credentials_for_owner(self.context, self.user)
 return Link(target, text, enabled=enabled, icon='info')
 
-def oci_recipes(self):
-target = '+oci-recipes'
-text = 'OCI recipes'
-enabled = not getUtility(IOCIRecipeSet).findByContext(
-self.context, visible_by_user=self.user).is_empty()
-return Link(target, text, enabled=enabled, icon='info')
-
 
 class PersonMenuMixin(CommonMenuLinks):
 
@@ -818,8 +809,8 @@ class PersonMenuMixin(CommonMenuLinks):
 return Link(target, text, icon='edit')
 
 
-class PersonOverviewMenu(ApplicationMenu, PersonMenuMixin,
- HasRecipesMenuMixin, HasSnapsMenuMixin):
+class PersonOverviewMenu(ApplicationMenu, PersonMenuMixin, HasRecipesMenuMixin,
+ HasSnapsMenuMixin, HasOCIRecipesMenuMixin):
 
 usedfor = IPerson
 facet = 'overview'
@@ -848,10 +839,10 @@ class PersonOverviewMenu(ApplicationMenu, PersonMenuMixin,
 'ppa',
 'oauth_tokens',
 'oci_registry_credentials',
-'oci_recipes',
 'related_software_summary',
 'view_recipes',
 'view_snaps',
+'view_oci_recipes',
 'subscriptions',
 'structural_subscriptions',
 ]
diff --git a/lib/lp/registry/browser/team.py b/lib/lp/registry/browser/team.py
index 93f121c..d419603 100644
--- a/lib/lp/registry/browser/team.py
+++ b/lib/lp/registry/browser/team.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2020 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2021 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 __metaclass__ = type
@@ -94,6 +94,7 @@ from lp.app.widgets.itemswidgets import (
 from lp.app.widgets.owner import HiddenUserWidget
 from lp.app.widgets.popup import PersonPickerWidget
 from lp.code.browser.sourcepackagerecipelisting import HasRecipesMenuMixin
+from lp.oci.browser.hasocirecipes import HasOCIRecipesMenuMixin
 from lp.registry.browser.branding import BrandingChangeView
 from lp.registry.browser.mailinglists import enabled_with_active_mailing_list
 from lp.registry.browser.objectreassignment import ObjectReassignmentView
@@ -1623,7 +1624,7 @@ class TeamMenuMixin(PPANavigationMenuMixIn, CommonMenuLinks):
 
 
 class TeamOverviewMenu(ApplicationMenu, TeamMenuMixin, HasRecipesMenuMixin,
-   HasSnapsMenuMixin):
+

[Launchpad-reviewers] [Merge] ~ilasc/launchpad:close-account-celery-job into launchpad:master

2021-04-09 Thread Ioana Lasc
Ioana Lasc has proposed merging ~ilasc/launchpad:close-account-celery-job into 
launchpad:master.

Commit message:
Add a close account celery job

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/400878
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ilasc/launchpad:close-account-celery-job into launchpad:master.
diff --git a/lib/lp/registry/configure.zcml b/lib/lp/registry/configure.zcml
index 7a7a396..ac3d82b 100644
--- a/lib/lp/registry/configure.zcml
+++ b/lib/lp/registry/configure.zcml
@@ -105,6 +105,12 @@
 
 
 
+  
+
+
+
   
diff --git a/lib/lp/registry/enums.py b/lib/lp/registry/enums.py
index b71dec6..0ca6af9 100644
--- a/lib/lp/registry/enums.py
+++ b/lib/lp/registry/enums.py
@@ -380,6 +380,11 @@ class PersonTransferJobType(DBEnumeratedType):
 Notify team admins that a member renewed their own membership.
 """)
 
+CLOSE_ACCOUNT = DBItem(7, """Close account.
+
+Close account for a given username.
+""")
+
 
 class ProductJobType(DBEnumeratedType):
 """Values that IProductJob.job_type can take."""
diff --git a/lib/lp/registry/interfaces/persontransferjob.py b/lib/lp/registry/interfaces/persontransferjob.py
index 3e80aed..e445553 100644
--- a/lib/lp/registry/interfaces/persontransferjob.py
+++ b/lib/lp/registry/interfaces/persontransferjob.py
@@ -9,6 +9,8 @@ __all__ = [
 'IExpiringMembershipNotificationJobSource',
 'IMembershipNotificationJob',
 'IMembershipNotificationJobSource',
+'IPersonCloseAccountJob',
+'IPersonCloseAccountJobSource',
 'IPersonDeactivateJob',
 'IPersonDeactivateJobSource',
 'IPersonMergeJob',
@@ -171,6 +173,34 @@ class IPersonDeactivateJobSource(IJobSource):
 """
 
 
+class IPersonCloseAccountJob(IPersonTransferJob):
+"""A Job that closes the account for a person."""
+
+person = PublicPersonChoice(
+title=_('Alias for person attribute'), vocabulary='ValidPersonOrTeam',
+required=True)
+
+def getErrorRecipients(self):
+"""See `BaseRunnableJob`."""
+
+
+class IPersonCloseAccountJobSource(IJobSource):
+"""An interface for acquiring ICloseAccountJobs."""
+
+def create(person):
+"""Create a new IPersonCloseAccountJob.
+
+:param person: A `IPerson` to close the account for.
+"""
+
+def find(person=None):
+"""Finds pending close account jobs.
+
+:param person: Match jobs on `person`, or `None` to ignore.
+:return: A `ResultSet` yielding `IPersonCloseAccountJob`.
+"""
+
+
 class ITeamInvitationNotificationJob(IPersonTransferJob):
 """A Job to notify about team joining invitations."""
 
diff --git a/lib/lp/registry/model/persontransferjob.py b/lib/lp/registry/model/persontransferjob.py
index 60ec767..5cef604 100644
--- a/lib/lp/registry/model/persontransferjob.py
+++ b/lib/lp/registry/model/persontransferjob.py
@@ -6,6 +6,7 @@
 __metaclass__ = type
 __all__ = [
 'MembershipNotificationJob',
+'PersonCloseAccountJob',
 'PersonTransferJob',
 ]
 
@@ -15,8 +16,11 @@ from lazr.delegates import delegate_to
 import pytz
 import simplejson
 import six
+from storm.exceptions import IntegrityError
 from storm.expr import (
 And,
+LeftJoin,
+Lower,
 Or,
 )
 from storm.locals import (
@@ -24,24 +28,32 @@ from storm.locals import (
 Reference,
 Unicode,
 )
+import transaction
 from zope.component import getUtility
 from zope.interface import (
 implementer,
 provider,
 )
+from zope.security.proxy import removeSecurityProxy
 
+from lp.answers.enums import QuestionStatus
+from lp.answers.model.question import Question
 from lp.app.interfaces.launchpad import ILaunchpadCelebrities
+from lp.bugs.model.bugtask import BugTask
 from lp.registry.enums import PersonTransferJobType
 from lp.registry.interfaces.person import (
 IPerson,
 IPersonSet,
 ITeam,
+PersonCreationRationale,
 )
 from lp.registry.interfaces.persontransferjob import (
 IExpiringMembershipNotificationJob,
 IExpiringMembershipNotificationJobSource,
 IMembershipNotificationJob,
 IMembershipNotificationJobSource,
+IPersonCloseAccountJob,
+IPersonCloseAccountJobSource,
 IPersonDeactivateJob,
 IPersonDeactivateJobSource,
 IPersonMergeJob,
@@ -57,23 +69,45 @@ from lp.registry.interfaces.persontransferjob import (
 )
 from lp.registry.interfaces.teammembership import TeamMembershipStatus
 from lp.registry.mail.teammembership import TeamMembershipMailer
-from lp.registry.model.person import Person
+from lp.registry.model.person import (
+Person,
+PersonSettings,
+)
+from lp.registry.model.product import Product
+from lp.registry.model.productseries import ProductSeries
 from lp.registry.personmerge import merge_people
 from lp.services.config import config
+from 

Re: [Launchpad-reviewers] [Merge] ~pappacena/launchpad:ocirecipe-sharing-lists into launchpad:master

2021-04-09 Thread Colin Watson
Review: Approve



Diff comments:

> diff --git a/lib/lp/registry/javascript/sharing/sharingdetails.js 
> b/lib/lp/registry/javascript/sharing/sharingdetails.js
> index 0ac4f32..22db012 100644
> --- a/lib/lp/registry/javascript/sharing/sharingdetails.js
> +++ b/lib/lp/registry/javascript/sharing/sharingdetails.js
> @@ -232,7 +304,7 @@ ns.SharingDetailsTable = 
> Y.Base.create('sharingDetailsTable', Y.Widget, [], {
>  .appendChild('')
>  .setContent(
>  "There are no shared bugs, Bazaar branches, " +
> -"Git repositories, or blueprints.");
> +"Git repositories, Snaps, OCI recipes or 
> blueprints.");

This text should be synced with that in pillar-sharing-details.pt.

>  }
>  };
>  var anim_duration = this.get('anim_duration');
> diff --git a/lib/lp/registry/templates/pillar-sharing-details.pt 
> b/lib/lp/registry/templates/pillar-sharing-details.pt
> index dc907dd..8a9a2fe 100644
> --- a/lib/lp/registry/templates/pillar-sharing-details.pt
> +++ b/lib/lp/registry/templates/pillar-sharing-details.pt
> @@ -26,21 +26,32 @@
>
>  
>  
> -  
> -  0 bugs,
> -  0 
> Bazaar branches,
> -   replace="view/shared_gitrepositories_count">0 Git 
> repositories,
> -  0 snaps,
> -  and   -  replace="view/shared_specifications_count">0
> -  blueprints shared with 
> -  grantee.
> -
>
>  3 team members can view these bugs,
> -Bazaar branches, Git repositories, and blueprints.
> +Bazaar branches, Git repositories, snaps recipes, OCI recipes and

"snap recipes", not "snaps recipes".

On second reading, I also wonder whether this summary text should be replaced 
with "... team members can view these artifacts", since spelling it all out is 
getting rather unwieldy.

Finally, I wonder how apparently nobody has previously noticed that "3" is 
hardcoded here, and is presumably untested.  Feel free to file a bug about that 
if it isn't trivial to fix in this branch, though.

> +blueprints.
>
> -  
> +  Shared with  replace="view/person/displayname">grantee:
> +  

In your screenshot, this doesn't seem to be styled as a list (with bullet 
points or similar).  Can you find out why that is?

> +
> +   bugs
> +
> +
> +   Bazaar branches
> +
> +
> +   Git 
> repositories
> +
> +
> +   OCI recipes
> +
> +
> +   snap recipes
> +
> +
> +   blueprints
> +
> +  
>  
>  
>  


-- 
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/400059
Your team Launchpad code reviewers is subscribed to branch 
~pappacena/launchpad:ocirecipe-edit-info-type-ui.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] lp:~ilasc/lp-production-crontabs/reschedule-repack-cron into lp:~launchpad-pqm/lp-production-crontabs/staging

2021-04-09 Thread Ioana Lasc
Thank Colin, that is the precise type of input I was looking for. 

Agreed on moving to a more frequent schedule and adjusted to running 6 times a 
day; a good idea indeed to pick the minute part of my current time when 
altering the cron schedule - went with 35 passed the hour on this case, looking 
at the rest of the jobs it didn't seem to collide with other ones either.

MP ready for another look. 
-- 
https://code.launchpad.net/~ilasc/lp-production-crontabs/reschedule-repack-cron/+merge/400686
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~ilasc/lp-production-crontabs/reschedule-repack-cron into 
lp:~launchpad-pqm/lp-production-crontabs/staging.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~ilasc/launchpad:skip-bug-watch-owner-close-account into launchpad:master

2021-04-09 Thread Ioana Lasc
Ioana Lasc has proposed merging 
~ilasc/launchpad:skip-bug-watch-owner-close-account into launchpad:master.

Commit message:
Skip bugwatch owner when closing account

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/400856

Ran into this issue yesterday evening while attempting to delete a user in 
dogfood:

INFOClosing username-deactivatedaccount's account
ERROR   User username-deactivatedaccount is still referenced by 5 
bugwatch.owner values
ERROR   User username-deactivatedaccount is still referenced


Running the unit test locally without the corresponding addition to the close 
account script fails with the same:

ERROR User person-name-10 is still referenced by 2 bugwatch.owner values
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ilasc/launchpad:skip-bug-watch-owner-close-account into launchpad:master.
diff --git a/lib/lp/registry/scripts/closeaccount.py b/lib/lp/registry/scripts/closeaccount.py
index af667a7..6fa8585 100644
--- a/lib/lp/registry/scripts/closeaccount.py
+++ b/lib/lp/registry/scripts/closeaccount.py
@@ -111,6 +111,7 @@ def close_account(username, log):
 ('bugnomination', 'owner'),
 ('bugtask', 'owner'),
 ('bugsubscription', 'subscribed_by'),
+('bugwatch', 'owner'),
 ('codeimport', 'owner'),
 ('codeimport', 'registrant'),
 ('codeimportjob', 'requesting_user'),
diff --git a/lib/lp/registry/scripts/tests/test_closeaccount.py b/lib/lp/registry/scripts/tests/test_closeaccount.py
index c366539..33ccd7a 100644
--- a/lib/lp/registry/scripts/tests/test_closeaccount.py
+++ b/lib/lp/registry/scripts/tests/test_closeaccount.py
@@ -344,6 +344,17 @@ class TestCloseAccount(TestCaseWithFactory):
 self.assertEqual(person, bug.owner)
 self.assertEqual(person, bugtask.owner)
 
+def test_skips_bug_watch_owner(self):
+person = self.factory.makePerson()
+self.factory.makeBugWatch(owner=person)
+self.factory.makeBugWatch(owner=person)
+person_id = person.id
+account_id = person.account.id
+script = self.makeScript([six.ensure_str(person.name)])
+with dbuser('launchpad'):
+self.runScript(script)
+self.assertRemoved(account_id, person_id)
+
 def test_handles_bug_affects_person(self):
 person = self.factory.makePerson()
 bug = self.factory.makeBug()
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp