← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~sinzui/launchpad/target-picker-adapters-0 into lp:launchpad

 

Curtis Hovey has proposed merging lp:~sinzui/launchpad/target-picker-adapters-0 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #857782 in Launchpad itself: "View details link in the target picker is broken"
  https://bugs.launchpad.net/launchpad/+bug/857782

For more details, see:
https://code.launchpad.net/~sinzui/launchpad/target-picker-adapters-0/+merge/77044

Add the project link to the target-picker.

    Launchpad bug: https://bugs.launchpad.net/bugs/857782
    Pre-implementation: No one

When viewing a list of projects or packages in the target-picker,
the link to view details is not a link.

--------------------------------------------------------------------

RULES

    * Update the adapter for the pillars and packages to add the
      alt_title_link attributes. When the picker js sees that value,
      it will construct a link with the new-window sprite.

QA

    * Visit https://bugs.qastaging.launchpad.net/
    * Use the choose link and search for 'launchpad'
    * Verify that the real /launchpad project has a link to view details
      that opens a new window/tab.

LINT

    lib/lp/app/browser/vocabulary.py
    lib/lp/app/browser/tests/test_vocabulary.py

TEST

    ./bin/test -vvc lp.app.browser.tests.test_vocabulary


IMPLEMENTATION

Set the alt_title_link that defaulted to None. Added tests for it.
    lib/lp/app/browser/vocabulary.py
    lib/lp/app/browser/tests/test_vocabulary.py
-- 
https://code.launchpad.net/~sinzui/launchpad/target-picker-adapters-0/+merge/77044
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~sinzui/launchpad/target-picker-adapters-0 into lp:launchpad.
=== modified file 'lib/lp/app/browser/tests/test_vocabulary.py'
--- lib/lp/app/browser/tests/test_vocabulary.py	2011-09-20 20:33:47 +0000
+++ lib/lp/app/browser/tests/test_vocabulary.py	2011-09-26 19:55:22 +0000
@@ -224,6 +224,18 @@
             distroarchseries=archseries)
         self.assertEqual("fnord", self.getPickerEntry(dsp).description)
 
+    def test_dsp_provides_alt_title_link(self):
+        distro = self.factory.makeDistribution(name='fnord')
+        series = self.factory.makeDistroSeries(
+            name='pting', distribution=distro)
+        self.factory.makeSourcePackage(
+            sourcepackagename='snarf', distroseries=series, publish=True)
+        dsp = distro.getSourcePackage('snarf')
+        self.assertEqual(
+            'http://launchpad.dev/fnord/+source/snarf',
+            self.getPickerEntry(dsp).alt_title_link)
+
+
 class TestProductPickerEntrySourceAdapter(TestCaseWithFactory):
 
     layer = DatabaseFunctionalLayer
@@ -275,6 +287,12 @@
         self.assertEqual(
             expected_details, entry.details[0])
 
+    def test_product_provides_alt_title_link(self):
+        product = self.factory.makeProduct(name='fnord')
+        self.assertEqual(
+            'http://launchpad.dev/fnord',
+            self.getPickerEntry(product).alt_title_link)
+
 
 class TestProjectGroupPickerEntrySourceAdapter(TestCaseWithFactory):
 
@@ -328,6 +346,13 @@
         self.assertEqual(
             expected_details, entry.details[0])
 
+    def test_projectgroup_provides_alt_title_link(self):
+        projectgroup = self.factory.makeProject(name='fnord')
+        self.assertEqual(
+            'http://launchpad.dev/fnord',
+            self.getPickerEntry(projectgroup).alt_title_link)
+
+
 class TestDistributionPickerEntrySourceAdapter(TestCaseWithFactory):
 
     layer = DatabaseFunctionalLayer
@@ -372,7 +397,7 @@
     def test_distribution_truncates_summary(self):
         summary = ("This is a deliberately, overly long summary. It goes on"
                    "and on and on so as to break things up a good bit.")
-        distribution= self.factory.makeDistribution(summary=summary)
+        distribution = self.factory.makeDistribution(summary=summary)
         index = summary.rfind(' ', 0, 45)
         expected_summary = summary[:index + 1]
         expected_details = summary[index:]
@@ -382,6 +407,13 @@
         self.assertEqual(
             expected_details, entry.details[0])
 
+    def test_distribution_provides_alt_title_link(self):
+        distribution = self.factory.makeDistribution(name='fnord')
+        self.assertEqual(
+            'http://launchpad.dev/fnord',
+            self.getPickerEntry(distribution).alt_title_link)
+
+
 class TestPersonVocabulary:
     implements(IHugeVocabulary)
     test_persons = []

=== modified file 'lib/lp/app/browser/vocabulary.py'
--- lib/lp/app/browser/vocabulary.py	2011-09-20 20:34:30 +0000
+++ lib/lp/app/browser/vocabulary.py	2011-09-26 19:55:22 +0000
@@ -260,7 +260,7 @@
                 picker_entry.details = []
                 summary = picker_entry.description
                 if len(summary) > 45:
-                    index =  summary.rfind(' ', 0, 45)
+                    index = summary.rfind(' ', 0, 45)
                     first_line = summary[0:index + 1]
                     second_line = summary[index:]
                 else:
@@ -268,15 +268,17 @@
                     second_line = ''
 
                 if len(second_line) > 90:
-                    index =  second_line.rfind(' ', 0, 90)
-                    second_line = second_line[0:index+1] 
+                    index = second_line.rfind(' ', 0, 90)
+                    second_line = second_line[0:index + 1]
                 picker_entry.description = first_line
                 picker_entry.details.append(second_line)
                 picker_entry.alt_title = target.name
+                picker_entry.alt_title_link = canonical_url(
+                    target, rootsite='mainsite')
                 picker_entry.target_type = self.target_type
                 maintainer = self.getMaintainer(target)
                 if maintainer is not None:
-                    picker_entry.details.append( 
+                    picker_entry.details.append(
                         'Maintainer: %s' % self.getMaintainer(target))
         return entries