← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/bug-1175212 into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/bug-1175212 into lp:launchpad.

Commit message:
Rework Archive:+packages/DistributionSourcePackage:+index expanders to always use absolute URLs, and grab the URL from the node rather than calculating it.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1175212 in Launchpad itself: "The version box on the "heat" source package page tries to load a non-existing source publication page"
  https://bugs.launchpad.net/launchpad/+bug/1175212

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-1175212/+merge/161893

DSP.latest_overall_publication doesn't count -proposed publications, so it's None if the package exists only in -proposed (common now that everything in Ubuntu goes through -proposed). This isn't a problem for most of the callsites, as they only care about its component and cope if it's None, but DSP:+index used the archive URL in its expanders. This branch fixes DSP:+index to always use the row's publication's archive URL, rather than the global DSP archive URL, unbreaking the expanders for packages that are only in -proposed.
-- 
https://code.launchpad.net/~wgrant/launchpad/bug-1175212/+merge/161893
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-1175212 into lp:launchpad.
=== modified file 'lib/lp/registry/browser/distributionsourcepackage.py'
--- lib/lp/registry/browser/distributionsourcepackage.py	2012-11-26 08:33:03 +0000
+++ lib/lp/registry/browser/distributionsourcepackage.py	2013-05-01 17:26:27 +0000
@@ -21,7 +21,6 @@
 import operator
 
 from lazr.delegates import delegates
-from lazr.restful.interfaces import IJSONRequestCache
 from lazr.restful.utils import smartquote
 from zope.component import (
     adapter,
@@ -328,11 +327,6 @@
         expose_structural_subscription_data_to_js(
             self.context, self.request, self.user)
 
-        pub = self.context.latest_overall_publication
-        if pub:
-            IJSONRequestCache(self.request).objects['archive_context_url'] = (
-                canonical_url(pub.archive, path_only_if_possible=True))
-
     @property
     def label(self):
         return self.context.title

=== modified file 'lib/lp/registry/templates/distributionsourcepackage-index.pt'
--- lib/lp/registry/templates/distributionsourcepackage-index.pt	2012-08-06 07:02:03 +0000
+++ lib/lp/registry/templates/distributionsourcepackage-index.pt	2013-05-01 17:26:27 +0000
@@ -116,8 +116,7 @@
   </div><!--yui-g -->
 
 
-  <div class="yui-u"
-       tal:define="archive context/latest_overall_publication/archive|nothing">
+  <div class="yui-u">
 
     <table class="listing" id="packages_list">
       <tal:rows repeat="row view/version_table">
@@ -144,13 +143,13 @@
       </tal:title_row>
 
       <tal:package_row condition="row/data_row">
-      <tal:define define="pubid row/publication/id">
+      <tal:define define="pub row/publication">
 
       <tr class="archive_package_row">
         <td style="white-space: nowrap">
           <a class="expander"
-             tal:attributes="id string:pub${pubid}-expander;
-                             href string:${archive/fmt:url}/+sourcepub/${pubid}/+listing-archive-extra"></a>
+             tal:attributes="id string:pub${pub/id}-expander;
+                             href string:${pub/archive/fmt:url}/+sourcepub/${pub/id}/+listing-archive-extra"></a>
           <a tal:attributes="href row/version">
             <img src="/@@/package-source" />
             <tal:version content="row/version"/>
@@ -169,10 +168,10 @@
                content="string:(not published)"/>
         </td>
       </tr>
-      <tr tal:attributes="id string:pub${pubid}">
+      <tr tal:attributes="id string:pub${pub/id}">
         <td colspan="3">
           <div class="package-details"
-               tal:attributes="id string:pub${pubid}-container"></div>
+               tal:attributes="id string:pub${pub/id}-container"></div>
         </td>
       </tr>
 
@@ -185,7 +184,7 @@
 
       </tal:rows>
     </table>
-    <metal:js use-macro="archive/@@+macros/expandable-table-js"/>
+    <metal:js use-macro="context/distribution/main_archive/@@+macros/expandable-table-js"/>
 
   </div>
 

=== modified file 'lib/lp/soyuz/templates/archive-macros.pt'
--- lib/lp/soyuz/templates/archive-macros.pt	2013-03-07 00:51:01 +0000
+++ lib/lp/soyuz/templates/archive-macros.pt	2013-05-01 17:26:27 +0000
@@ -56,23 +56,7 @@
         }
     };
 
-    /**
-     * If a page wants to use this outside of an archive context then it
-     * can define LP.cache['archive_context'], which should be a
-     * full or relative URL to the context archive page required.
-     */
-    var base_url = (
-        typeof(LP.cache['archive_context_url']) != "undefined")
-            ? LP.cache['archive_context_url']
-            : '';
-    if (base_url !== '') {
-        base_url += '/';
-    }
-    var pub_id = expander.content_node.get('id')
-                   .replace('pub', '')
-                   .replace('-container', '');
-    var uri = base_url + '+sourcepub/' + pub_id + '/+listing-archive-extra';
-    Y.io(uri, config);
+    Y.io(expander.icon_node.get('href'), config);
 }
 
 /**