← Back to team overview

launchpad-reviewers team mailing list archive

lp:~jcsackett/launchpad/archivesubscriptions-need-iprivacy-adapter into lp:launchpad

 

j.c.sackett has proposed merging lp:~jcsackett/launchpad/archivesubscriptions-need-iprivacy-adapter into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jcsackett/launchpad/archivesubscriptions-need-iprivacy-adapter/+merge/102575

Summary
=======
The privacy banner isn't shown on personal archive subscription views, b/c the
PersonalArchiveSubscription has no private attribute, and cannot adapt to
IPrivacy.

This branch remedies that problem.

Preimp
======
Spoke with Curtis Hovey and the rest of Purple Squad.

Implementation
==============
An adapter has been created for IPersonalArchiveSubscriptions to adapt them to
IPrivacy.

Tests showing this adaption works have also been added.

Tests
=====
bin/test -t personal_archive_subscription

QA
==
Follow a "View" link from a Person:+archivesubscriptions page. The banner
should be displayed.

LoC
===
This is part of the disclosure arc of work, which has the overall effect of
reducing maintenance costs.

Lint
====

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/soyuz/interfaces/archivesubscriber.py
  lib/lp/soyuz/configure.zcml
  lib/lp/soyuz/browser/archivesubscription.py
  lib/lp/soyuz/browser/tests/test_personal_archive_subscription.py
-- 
https://code.launchpad.net/~jcsackett/launchpad/archivesubscriptions-need-iprivacy-adapter/+merge/102575
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jcsackett/launchpad/archivesubscriptions-need-iprivacy-adapter into lp:launchpad.
=== modified file 'lib/lp/soyuz/browser/archivesubscription.py'
--- lib/lp/soyuz/browser/archivesubscription.py	2012-04-12 19:42:09 +0000
+++ lib/lp/soyuz/browser/archivesubscription.py	2012-04-18 19:02:19 +0000
@@ -9,6 +9,7 @@
 
 __all__ = [
     'ArchiveSubscribersView',
+    'PersonalArchiveSubscription',
     'PersonArchiveSubscriptionView',
     'PersonArchiveSubscriptionsView',
     'traverse_archive_subscription_for_subscriber',

=== added file 'lib/lp/soyuz/browser/tests/test_personal_archive_subscription.py'
--- lib/lp/soyuz/browser/tests/test_personal_archive_subscription.py	1970-01-01 00:00:00 +0000
+++ lib/lp/soyuz/browser/tests/test_personal_archive_subscription.py	2012-04-18 19:02:19 +0000
@@ -0,0 +1,30 @@
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Tests for the PersonalArchiveSubscription components and view."""
+
+__metaclass__ = type
+
+from lp.app.interfaces.launchpad import IPrivacy
+from lp.soyuz.browser.archivesubscription import PersonalArchiveSubscription
+from lp.testing import (
+    person_logged_in,
+    TestCaseWithFactory,
+    )
+from lp.testing.layers import DatabaseFunctionalLayer
+
+
+class TestSomething(TestCaseWithFactory):
+
+    layer = DatabaseFunctionalLayer
+
+    def test_personal_archive_subscription_adapts_to_privacy(self):
+        owner = self.factory.makePerson(name='archiveowner')
+        subscriber = self.factory.makePerson(name='subscriber')
+        pppa = self.factory.makeArchive(
+            owner=owner, private=True, name='pppa')
+        with person_logged_in(owner):
+            pppa.newSubscription(subscriber, owner)
+        pas = PersonalArchiveSubscription(subscriber, pppa)
+        privacy = IPrivacy(pas)
+        self.assertTrue(privacy.private)

=== modified file 'lib/lp/soyuz/configure.zcml'
--- lib/lp/soyuz/configure.zcml	2011-12-24 17:49:30 +0000
+++ lib/lp/soyuz/configure.zcml	2012-04-18 19:02:19 +0000
@@ -577,6 +577,10 @@
         for="lp.soyuz.interfaces.archivesubscriber.IPersonalArchiveSubscription"
         factory="lp.services.webapp.breadcrumb.DisplaynameBreadcrumb"
         permission="zope.Public"/>
+    <adapter
+        provides="lp.app.interfaces.launchpad.IPrivacy"
+        for="lp.soyuz.interfaces.archivesubscriber.IPersonalArchiveSubscription"
+        factory="lp.soyuz.interfaces.archivesubscriber.pas_to_privacy"/>
     <subscriber
         for="lp.soyuz.interfaces.archivesubscriber.IArchiveSubscriber
              lazr.lifecycle.interfaces.IObjectCreatedEvent"

=== modified file 'lib/lp/soyuz/interfaces/archivesubscriber.py'
--- lib/lp/soyuz/interfaces/archivesubscriber.py	2011-12-24 16:54:44 +0000
+++ lib/lp/soyuz/interfaces/archivesubscriber.py	2012-04-18 19:02:19 +0000
@@ -178,3 +178,9 @@
 
     title = TextLine(title=_("Subscription title"),
         required=False)
+
+
+def pas_to_privacy(pas):
+    """Converts a PersonalArchiveSubscription to privacy"""
+    from lp.app.interfaces.launchpad import IPrivacy
+    return IPrivacy(pas.archive)


Follow ups