Merge ~twom/launchpad:snap-privacy-move-all-the-things-at-once into launchpad:master

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: ce7a616ff69eae4d5400a8570c765c971c5e872e
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:snap-privacy-move-all-the-things-at-once
Merge into: launchpad:master
Diff against target: 55 lines (+33/-0)
2 files modified
lib/lp/snappy/browser/snap.py (+4/-0)
lib/lp/snappy/browser/tests/test_snap.py (+29/-0)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Ioana Lasc Approve
Review via email: mp+402812@code.launchpad.net

Commit message

Set information type before update

Description of the change

Allow setting snap privacy and team ownership at the same time.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) wrote :

Beside the (perhaps) forgotten comment this LGTM.

review: Approve
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/snappy/browser/snap.py b/lib/lp/snappy/browser/snap.py
2index ac7925c..c7b0ea3 100644
3--- a/lib/lp/snappy/browser/snap.py
4+++ b/lib/lp/snappy/browser/snap.py
5@@ -835,6 +835,10 @@ class BaseSnapEditView(SnapAuthorizeMixin, SnapInformationTypeMixin,
6 if 'store_channels' in data:
7 del data['store_channels']
8 need_store_reauth = self._needStoreReauth(data)
9+ info_type = data.get('information_type')
10+ if info_type and info_type != self.context.information_type:
11+ self.context.information_type = info_type
12+ del data['information_type']
13 self.updateContextFromData(data)
14 if need_store_reauth:
15 self.requestAuthorization(self.context)
16diff --git a/lib/lp/snappy/browser/tests/test_snap.py b/lib/lp/snappy/browser/tests/test_snap.py
17index 486e586..8a96e17 100644
18--- a/lib/lp/snappy/browser/tests/test_snap.py
19+++ b/lib/lp/snappy/browser/tests/test_snap.py
20@@ -1150,6 +1150,35 @@ class TestSnapEditView(BaseTestSnapView):
21 "A public snap cannot have a private owner.",
22 extract_text(find_tags_by_class(browser.contents, "message")[1]))
23
24+ def test_edit_public_snap_make_private_in_one_go(self):
25+ # Move a public snap to a private owner and mark it private in one go
26+ series = self.factory.makeUbuntuDistroSeries()
27+ with admin_logged_in():
28+ snappy_series = self.factory.makeSnappySeries(
29+ usable_distro_series=[series])
30+ login_person(self.person)
31+ private_project = self.factory.makeProduct(
32+ name='private-project',
33+ owner=self.person, registrant=self.person,
34+ information_type=InformationType.PROPRIETARY,
35+ branch_sharing_policy=BranchSharingPolicy.PROPRIETARY)
36+ snap = self.factory.makeSnap(
37+ registrant=self.person, owner=self.person, distroseries=series,
38+ store_series=snappy_series, project=private_project)
39+ private_team = self.factory.makeTeam(
40+ owner=self.person, visibility=PersonVisibility.PRIVATE)
41+ private_team_name = private_team.name
42+
43+ browser = self.getViewBrowser(snap, user=self.person)
44+ browser.getLink("Edit snap package").click()
45+ browser.getControl("Owner").value = [private_team_name]
46+ browser.getControl(name="field.information_type").value = (
47+ "PROPRIETARY")
48+ browser.getControl("Update snap package").click()
49+
50+ login_admin()
51+ self.assertEqual(InformationType.PROPRIETARY, snap.information_type)
52+
53 def test_edit_public_snap_private_branch(self):
54 series = self.factory.makeUbuntuDistroSeries()
55 with admin_logged_in():

Subscribers

People subscribed via source and target branches

to status/vote changes: