launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26707
[Merge] ~pappacena/launchpad:ocirecipe-privacy-banners-ui into launchpad:master
Thiago F. Pappacena has proposed merging ~pappacena/launchpad:ocirecipe-privacy-banners-ui into launchpad:master with ~pappacena/launchpad:ocirecipe-subscribe-removal-job as a prerequisite.
Commit message:
Showing private top banner on private OCI recipes pages
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/399987
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:ocirecipe-privacy-banners-ui into launchpad:master.
diff --git a/lib/lp/oci/browser/configure.zcml b/lib/lp/oci/browser/configure.zcml
index 53db0d2..31dcbc9 100644
--- a/lib/lp/oci/browser/configure.zcml
+++ b/lib/lp/oci/browser/configure.zcml
@@ -27,6 +27,12 @@
for="lp.oci.interfaces.ocirecipe.IOCIRecipe"
class="lp.oci.browser.ocirecipe.OCIRecipeView"
permission="launchpad.View"
+ name="+portlet-privacy"
+ template="../templates/ocirecipe-portlet-privacy.pt"/>
+ <browser:page
+ for="lp.oci.interfaces.ocirecipe.IOCIRecipe"
+ class="lp.oci.browser.ocirecipe.OCIRecipeView"
+ permission="launchpad.View"
name="+index"
template="../templates/ocirecipe-index.pt" />
<browser:page
diff --git a/lib/lp/oci/browser/ocirecipe.py b/lib/lp/oci/browser/ocirecipe.py
index 5eee7e3..4f0a3d9 100644
--- a/lib/lp/oci/browser/ocirecipe.py
+++ b/lib/lp/oci/browser/ocirecipe.py
@@ -239,6 +239,10 @@ class OCIProjectRecipesView(LaunchpadView):
class OCIRecipeView(LaunchpadView):
"""Default view of an OCI recipe."""
+ @property
+ def private(self):
+ return self.context.private
+
@cachedproperty
def builds(self):
return builds_for_recipe(self.context)
@@ -958,6 +962,10 @@ class BaseOCIRecipeEditView(LaunchpadEditFormView):
schema = IOCIRecipeEditSchema
@property
+ def private(self):
+ return self.context.private
+
+ @property
def cancel_url(self):
"""See `LaunchpadFormView`."""
return canonical_url(self.context)
diff --git a/lib/lp/oci/browser/tests/test_ocirecipe.py b/lib/lp/oci/browser/tests/test_ocirecipe.py
index 143d553..88ec7da 100644
--- a/lib/lp/oci/browser/tests/test_ocirecipe.py
+++ b/lib/lp/oci/browser/tests/test_ocirecipe.py
@@ -89,6 +89,7 @@ from lp.testing.matchers import (
from lp.testing.pages import (
extract_text,
find_main_content,
+ find_tag_by_id,
find_tags_by_class,
)
from lp.testing.publication import test_traverse
@@ -599,6 +600,19 @@ class TestOCIRecipeEditView(OCIConfigHelperMixin, BaseTestOCIRecipeView):
for name in disabled])
self.assertThat(processors_control.controls, MatchesSetwise(*matchers))
+ def test_edit_private_recipe_shows_banner(self):
+ recipe = self.factory.makeOCIRecipe(
+ registrant=self.person, owner=self.person,
+ information_type=InformationType.USERDATA)
+ browser = self.getViewBrowser(recipe, user=self.person)
+ browser.getLink("Edit OCI recipe").click()
+ banners = find_tags_by_class(
+ browser.contents, "private_banner_container")
+ self.assertEqual(1, len(banners))
+ self.assertEqual(
+ 'The information on this page is private.',
+ extract_text(banners[0]))
+
def test_edit_recipe(self):
oci_project = self.factory.makeOCIProject()
oci_project_display = oci_project.display_name
@@ -1187,6 +1201,9 @@ class TestOCIRecipeView(BaseTestOCIRecipeView):
build = self.makeBuild(
recipe=recipe, status=BuildStatus.FULLYBUILT,
duration=timedelta(minutes=30))
+
+ browser = self.getViewBrowser(build.recipe)
+ login_person(self.person)
self.assertTextMatchesExpressionIgnoreWhitespace("""\
%s OCI project
recipe-name
@@ -1204,7 +1221,33 @@ class TestOCIRecipeView(BaseTestOCIRecipeView):
Status When complete Architecture
Successfully built 30 minutes ago 386
""" % (oci_project_name, oci_project_display, recipe.build_path),
- self.getMainText(build.recipe))
+ extract_text(find_main_content(browser.contents)))
+
+ # Check portlet on side menu.
+ privacy_tag = find_tag_by_id(browser.contents, "privacy")
+ self.assertTextMatchesExpressionIgnoreWhitespace(
+ "This OCI recipe contains Public information",
+ extract_text(privacy_tag))
+
+ def test_index_for_private_recipe_shows_banner(self):
+ recipe = self.factory.makeOCIRecipe(
+ registrant=self.person, owner=self.person,
+ information_type=InformationType.USERDATA)
+ browser = self.getViewBrowser(recipe, user=self.person)
+
+ # Check top banner.
+ banners = find_tags_by_class(
+ browser.contents, "private_banner_container")
+ self.assertEqual(1, len(banners))
+ self.assertTextMatchesExpressionIgnoreWhitespace(
+ 'The information on this page is private.',
+ extract_text(banners[0]))
+
+ # Check portlet on side menu.
+ privacy_tag = find_tag_by_id(browser.contents, "privacy")
+ self.assertTextMatchesExpressionIgnoreWhitespace(
+ "This OCI recipe contains Private information",
+ extract_text(privacy_tag))
def test_index_with_build_args(self):
oci_project = self.factory.makeOCIProject(
diff --git a/lib/lp/oci/interfaces/ocirecipe.py b/lib/lp/oci/interfaces/ocirecipe.py
index 3d1fc88..c72394e 100644
--- a/lib/lp/oci/interfaces/ocirecipe.py
+++ b/lib/lp/oci/interfaces/ocirecipe.py
@@ -230,6 +230,11 @@ class IOCIRecipeView(Interface):
description=_("True if this recipe is official for its OCI project."),
readonly=True)
+ private = Bool(
+ title=_("Is this OCI recipe private?"),
+ required=False, readonly=True,
+ description=_("True if this recipe is private. False otherwise."))
+
@call_with(check_permissions=True, user=REQUEST_USER)
@operation_parameters(
processors=List(
diff --git a/lib/lp/oci/model/ocirecipe.py b/lib/lp/oci/model/ocirecipe.py
index 9364383..6128452 100644
--- a/lib/lp/oci/model/ocirecipe.py
+++ b/lib/lp/oci/model/ocirecipe.py
@@ -246,7 +246,7 @@ class OCIRecipe(Storm, WebhookTargetMixin):
@property
def private(self):
- return (self.information_type is None
+ return (self.information_type is not None
and self.information_type not in PUBLIC_INFORMATION_TYPES)
@property
diff --git a/lib/lp/oci/templates/ocirecipe-index.pt b/lib/lp/oci/templates/ocirecipe-index.pt
index 315973c..5a1f3c1 100644
--- a/lib/lp/oci/templates/ocirecipe-index.pt
+++ b/lib/lp/oci/templates/ocirecipe-index.pt
@@ -18,6 +18,7 @@
</metal:registering>
<metal:side fill-slot="side">
+ <div tal:replace="structure context/@@+portlet-privacy" />
<div tal:replace="structure context/@@+global-actions"/>
<tal:subscribers replace="structure context/@@+portlet-subscribers" />
</metal:side>
Follow ups