← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~julian-edwards/launchpad/link-LCV-bug-783442 into lp:launchpad

 

Julian Edwards has proposed merging lp:~julian-edwards/launchpad/link-LCV-bug-783442 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #783442 in Launchpad itself: "The "last common version" text on +localpackagediffs should link"
  https://bugs.launchpad.net/launchpad/+bug/783442

For more details, see:
https://code.launchpad.net/~julian-edwards/launchpad/link-LCV-bug-783442/+merge/64550

= Summary =
Linkify the "last common version" on the +localpackagediffs page.

== Implementation details ==
The text is linked to the /distro/+source/package/version page in the parent
distribution for the convenience of the users of the page.

== Tests ==
bin/test -cvv test_distroseriesdifference_views test_last_common_version_is_linked
-- 
https://code.launchpad.net/~julian-edwards/launchpad/link-LCV-bug-783442/+merge/64550
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~julian-edwards/launchpad/link-LCV-bug-783442 into lp:launchpad.
=== modified file 'lib/lp/registry/browser/tests/test_distroseriesdifference_views.py'
--- lib/lp/registry/browser/tests/test_distroseriesdifference_views.py	2011-05-23 17:08:06 +0000
+++ lib/lp/registry/browser/tests/test_distroseriesdifference_views.py	2011-06-14 13:58:45 +0000
@@ -15,8 +15,10 @@
     )
 import transaction
 from zope.component import getUtility
+from zope.security.proxy import removeSecurityProxy
 
 from canonical.launchpad.webapp.authorization import check_permission
+from canonical.launchpad.webapp.publisher import canonical_url
 from canonical.launchpad.webapp.servers import LaunchpadTestRequest
 from canonical.launchpad.webapp.testing import verifyObject
 from canonical.testing import LaunchpadFunctionalLayer
@@ -38,6 +40,9 @@
     PackageDiffStatus,
     PackagePublishingStatus,
     )
+from lp.soyuz.model.distributionsourcepackagerelease import (
+    DistributionSourcePackageRelease,
+    )
 from lp.testing import (
     anonymous_logged_in,
     celebrity_logged_in,
@@ -484,6 +489,28 @@
         self.assertEqual(
             1, len(soup.findAll('pre', text="Here's another comment.")))
 
+    def test_last_common_version_is_linked(self):
+        # The "Last Common Version" version text should link to the
+        # parent distro sourcepackagerelease page.
+        ds_diff = removeSecurityProxy(
+            self.factory.makeDistroSeriesDifference(set_base_version=True))
+        view = create_initialized_view(ds_diff, '+listing-distroseries-extra')
+        page = view()
+        #soup = BeautifulSoup(page)
+        #tag = soup.find('last_common_version')
+
+        distro = ds_diff.parent_series.distribution
+        sourcepackagerelease = ds_diff.parent_source_package_release
+        url = canonical_url(
+            DistributionSourcePackageRelease(distro, sourcepackagerelease),
+            force_local_path=True)
+        anchor_matcher = soupmatchers.HTMLContains(
+            soupmatchers.Tag(
+                "VERSION LINK", 'a',
+                attrs=dict(href=url)))
+
+        self.assertThat(page, anchor_matcher) 
+
     def test_blacklist_options(self):
         # Blacklist options are presented to the users who are archive
         # admins.

=== modified file 'lib/lp/registry/interfaces/distroseriesdifference.py'
--- lib/lp/registry/interfaces/distroseriesdifference.py	2011-05-31 13:56:03 +0000
+++ lib/lp/registry/interfaces/distroseriesdifference.py	2011-06-14 13:58:45 +0000
@@ -195,6 +195,10 @@
     parent_packagesets = Attribute("The packagesets for this source package "
                                    "in the parent series.")
 
+    base_distro_source_package_release = Attribute(
+        "The DistributionSourcePackageRelease object for the source release "
+        "in the parent distribution.")
+
     def update(manual=False):
         """Checks that difference type and status matches current publishings.
 

=== modified file 'lib/lp/registry/model/distroseriesdifference.py'
--- lib/lp/registry/model/distroseriesdifference.py	2011-06-10 18:12:43 +0000
+++ lib/lp/registry/model/distroseriesdifference.py	2011-06-14 13:58:45 +0000
@@ -90,6 +90,9 @@
 from lp.soyuz.interfaces.packagediff import IPackageDiffSet
 from lp.soyuz.interfaces.packageset import IPackagesetSet
 from lp.soyuz.model.archive import Archive
+from lp.soyuz.model.distributionsourcepackagerelease import (
+    DistributionSourcePackageRelease,
+    )
 from lp.soyuz.model.distroseriessourcepackagerelease import (
     DistroSeriesSourcePackageRelease,
     )
@@ -653,6 +656,13 @@
             return DistroSeriesSourcePackageRelease(
                 distro_series, pub.sourcepackagerelease)
 
+    @cachedproperty
+    def base_distro_source_package_release(self):
+        """See `IDistroSeriesDifference`."""
+        return DistributionSourcePackageRelease(
+            self.parent_series.distribution,
+            self.parent_source_package_release)
+
     def update(self, manual=False):
         """See `IDistroSeriesDifference`."""
         # Updating is expected to be a heavy operation (not called

=== modified file 'lib/lp/registry/templates/distroseriesdifference-listing-extra.pt'
--- lib/lp/registry/templates/distroseriesdifference-listing-extra.pt	2011-06-10 19:03:53 +0000
+++ lib/lp/registry/templates/distroseriesdifference-listing-extra.pt	2011-06-14 13:58:45 +0000
@@ -39,8 +39,10 @@
       </ul></dd>
     <tal:package-diffs tal:condition="view/can_have_packages_diffs">
     <dt>Last common version:</dt>
-    <dd tal:condition="context/base_version"
-        tal:content="context/base_version">1.2.1</dd>
+    <dd tal:condition="context/base_version">
+        <a id="last_common_version"
+           tal:attributes="href context/base_distro_source_package_release/fmt:url"
+           tal:content="context/base_version"/></dd>
     <dd tal:condition="not: context/base_version">
       Unknown
     </dd>