← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/dspr+files into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/dspr+files into lp:launchpad.

Commit message:
Drop SourcePackageRelease:+files (used only by SourcePackage:+index and DistroSeriesSourcePackageRelease:+index), replacing it with a new DistributionSourcePackageRelease:+files extracted from DistributionSourcePackageRelease:+index.

Requested reviews:
  William Grant (wgrant): code

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/dspr+files/+merge/241193
-- 
https://code.launchpad.net/~wgrant/launchpad/dspr+files/+merge/241193
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'lib/lp/registry/templates/sourcepackage-index.pt'
--- lib/lp/registry/templates/sourcepackage-index.pt	2010-10-10 21:54:16 +0000
+++ lib/lp/registry/templates/sourcepackage-index.pt	2014-11-09 01:58:00 +0000
@@ -106,7 +106,7 @@
         <h2>Download files from current release (<span
           tal:replace="current/version">2.1.3-4</span>)</h2>
 
-        <div id="files" tal:content="structure current/@@+files" />
+        <div id="files" tal:content="structure current/distributionsourcepackagerelease/@@+files" />
 
         <h2>Package relationships</h2>
 

=== modified file 'lib/lp/soyuz/browser/configure.zcml'
--- lib/lp/soyuz/browser/configure.zcml	2014-08-07 06:32:54 +0000
+++ lib/lp/soyuz/browser/configure.zcml	2014-11-09 01:58:00 +0000
@@ -112,9 +112,6 @@
         <browser:page
             name="+copyright"
             template="../templates/sourcepackagerelease-copyright.pt"/>
-        <browser:page
-            name="+files"
-            template="../templates/sourcepackagerelease-files.pt"/>
     </browser:pages>
         <browser:pages
             for="lp.soyuz.interfaces.publishing.ISourcePackagePublishingHistory"
@@ -461,6 +458,9 @@
         <browser:page
             name="+changes"
             template="../templates/distributionsourcepackagerelease-changes.pt"/>
+        <browser:page
+            name="+files"
+            template="../templates/distributionsourcepackagerelease-files.pt"/>
     </browser:pages>
     <browser:page
         for="lp.soyuz.interfaces.distributionsourcepackagerelease.IDistributionSourcePackageRelease"

=== added file 'lib/lp/soyuz/browser/tests/test_distributionsourcepackagerelease.py'
--- lib/lp/soyuz/browser/tests/test_distributionsourcepackagerelease.py	1970-01-01 00:00:00 +0000
+++ lib/lp/soyuz/browser/tests/test_distributionsourcepackagerelease.py	2014-11-09 01:58:00 +0000
@@ -0,0 +1,58 @@
+# Copyright 2010 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Unit tests for TestSourcePackageReleaseFiles."""
+
+__metaclass__ = type
+__all__ = [
+    'TestDistributionSourcePackageReleaseFiles',
+    ]
+
+from zope.security.proxy import removeSecurityProxy
+
+from lp.testing import TestCaseWithFactory
+from lp.testing.layers import LaunchpadFunctionalLayer
+from lp.testing.views import create_initialized_view
+
+
+class TestDistributionSourcePackageReleaseFiles(TestCaseWithFactory):
+    """Source package release files are rendered correctly."""
+
+    layer = LaunchpadFunctionalLayer
+
+    def setUp(self):
+        super(TestDistributionSourcePackageReleaseFiles, self).setUp()
+        # SourcePackageRelease itself is contextless, so wrap it in DSPR
+        # to give it a URL.
+        spr = self.factory.makeSourcePackageRelease()
+        distroseries = self.factory.makeDistroSeries()
+        self.factory.makeSourcePackagePublishingHistory(
+            archive=distroseries.main_archive, distroseries=distroseries,
+            sourcepackagerelease=spr)
+        self.source_package_release = (
+            distroseries.distribution.getSourcePackageRelease(spr))
+
+    def test_spr_files_none(self):
+        # The snippet renders appropriately when there are no files.
+        view = create_initialized_view(self.source_package_release, "+files")
+        html = view.__call__()
+        self.failUnless('No files available for download.' in html)
+
+    def test_spr_files_one(self):
+        # The snippet links to the file when present.
+        library_file = self.factory.makeLibraryFileAlias(
+            filename='test_file.dsc', content='0123456789')
+        self.source_package_release.addFile(library_file)
+        view = create_initialized_view(self.source_package_release, "+files")
+        html = view.__call__()
+        self.failUnless('test_file.dsc' in html)
+
+    def test_spr_files_deleted(self):
+        # The snippet handles deleted files too.
+        library_file = self.factory.makeLibraryFileAlias(
+            filename='test_file.dsc', content='0123456789')
+        self.source_package_release.addFile(library_file)
+        removeSecurityProxy(library_file).content = None
+        view = create_initialized_view(self.source_package_release, "+files")
+        html = view.__call__()
+        self.failUnless('test_file.dsc (deleted)' in html)

=== modified file 'lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py'
--- lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py	2014-04-24 06:45:51 +0000
+++ lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py	2014-11-09 01:58:00 +0000
@@ -5,60 +5,15 @@
 
 __metaclass__ = type
 __all__ = [
-    'TestSourcePackageReleaseFiles',
     'TestSourcePackageReleaseView',
     ]
 
-from zope.security.proxy import removeSecurityProxy
-
 from lp.testing import TestCaseWithFactory
 from lp.testing.factory import remove_security_proxy_and_shout_at_engineer
-from lp.testing.layers import (
-    DatabaseFunctionalLayer,
-    LaunchpadFunctionalLayer,
-    )
+from lp.testing.layers import DatabaseFunctionalLayer
 from lp.testing.views import create_initialized_view
 
 
-class TestSourcePackageReleaseFiles(TestCaseWithFactory):
-    """Source package release files are rendered correctly."""
-
-    layer = LaunchpadFunctionalLayer
-
-    def setUp(self):
-        super(TestSourcePackageReleaseFiles, self).setUp()
-        # SourcePackageRelease itself is contextless, so wrap it in DSPR
-        # to give it a URL.
-        self.source_package_release = (
-            self.factory.makeDistroSeries().getSourcePackageRelease(
-                self.factory.makeSourcePackageRelease()))
-
-    def test_spr_files_none(self):
-        # The snippet renders appropriately when there are no files.
-        view = create_initialized_view(self.source_package_release, "+files")
-        html = view.__call__()
-        self.failUnless('No files available for download.' in html)
-
-    def test_spr_files_one(self):
-        # The snippet links to the file when present.
-        library_file = self.factory.makeLibraryFileAlias(
-            filename='test_file.dsc', content='0123456789')
-        self.source_package_release.addFile(library_file)
-        view = create_initialized_view(self.source_package_release, "+files")
-        html = view.__call__()
-        self.failUnless('test_file.dsc' in html)
-
-    def test_spr_files_deleted(self):
-        # The snippet handles deleted files too.
-        library_file = self.factory.makeLibraryFileAlias(
-            filename='test_file.dsc', content='0123456789')
-        self.source_package_release.addFile(library_file)
-        removeSecurityProxy(library_file).content = None
-        view = create_initialized_view(self.source_package_release, "+files")
-        html = view.__call__()
-        self.failUnless('test_file.dsc (deleted)' in html)
-
-
 class TestSourcePackageReleaseView(TestCaseWithFactory):
 
     layer = DatabaseFunctionalLayer

=== modified file 'lib/lp/soyuz/interfaces/distroseriessourcepackagerelease.py'
--- lib/lp/soyuz/interfaces/distroseriessourcepackagerelease.py	2013-01-07 02:40:55 +0000
+++ lib/lp/soyuz/interfaces/distroseriessourcepackagerelease.py	2014-11-09 01:58:00 +0000
@@ -30,6 +30,8 @@
 
     distroseries = Attribute("The distro series.")
     sourcepackage = Attribute("The distribution series source package.")
+    distributionsourcepackagerelease = Attribute(
+        "The distribution source package release.")
     sourcepackagerelease = Attribute("The source package release.")
 
     name = Attribute("The source package name as text")

=== modified file 'lib/lp/soyuz/model/distroseriessourcepackagerelease.py'
--- lib/lp/soyuz/model/distroseriessourcepackagerelease.py	2013-01-07 02:40:55 +0000
+++ lib/lp/soyuz/model/distroseriessourcepackagerelease.py	2014-11-09 01:58:00 +0000
@@ -61,6 +61,12 @@
         return self.distroseries.getSourcePackage(self.sourcepackagename)
 
     @property
+    def distributionsourcepackagerelease(self):
+        """See `IDistroSeriesSourcePackageRelease`."""
+        return self.distribution.getSourcePackageRelease(
+            self.sourcepackagerelease)
+
+    @property
     def displayname(self):
         """See `IDistroSeriesSourcePackageRelease`."""
         return '%s %s' % (self.name, self.version)

=== modified file 'lib/lp/soyuz/stories/soyuz/xx-distro-package-pages.txt'
--- lib/lp/soyuz/stories/soyuz/xx-distro-package-pages.txt	2010-12-22 14:50:08 +0000
+++ lib/lp/soyuz/stories/soyuz/xx-distro-package-pages.txt	2014-11-09 01:58:00 +0000
@@ -26,9 +26,10 @@
   ...     'http://launchpad.dev/ubuntu/breezy-autotest/+source/'
   ...     'commercialpackage/1.0-1')
   >>> print extract_text(find_tag_by_id(browser.contents, 'files'))
-  commercialpackage_1.0.orig.tar.gz (179 bytes)
-  commercialpackage_1.0-1.diff.gz (610 bytes)
-  commercialpackage_1.0-1.dsc (567 bytes)
+  File Size MD5 Checksum
+  commercialpackage_1.0.orig.tar.gz 179 bytes ...
+  commercialpackage_1.0-1.diff.gz 610 bytes ...
+  commercialpackage_1.0-1.dsc 567 bytes ...
 
 If you check out the URL for the DSC, you'll see it's in the +files
 virtual directory:

=== modified file 'lib/lp/soyuz/stories/soyuz/xx-distroseries-sources.txt'
--- lib/lp/soyuz/stories/soyuz/xx-distroseries-sources.txt	2013-02-13 14:22:07 +0000
+++ lib/lp/soyuz/stories/soyuz/xx-distroseries-sources.txt	2014-11-09 01:58:00 +0000
@@ -84,10 +84,11 @@
 published version) if they are available:
 
   >>> print extract_text(find_tag_by_id(content, 'files'))
-  firefox_0.9.2.orig.tar.gz (9.5 MiB)
+  File Size MD5 Checksum
+  firefox_0.9.2.orig.tar.gz 9.5 MiB ...
 
   >>> print browser.getLink("firefox_0.9.2.orig.tar.gz").url
-  http://launchpad.dev/ubuntu/warty/+source/mozilla-firefox/0.9/+files/firefox_0.9.2.orig.tar.gz
+  http://launchpad.dev/ubuntu/+archive/primary/+files/firefox_0.9.2.orig.tar.gz
 
 This page also provides links to the binary packages generated by this
 source in a specfic architecture:
@@ -251,10 +252,11 @@
 '.diff' and the DSC:
 
   >>> print extract_text(find_tag_by_id(browser.contents, 'files'))
-  firefox_0.9.2.orig.tar.gz (9.5 MiB)
+  File Size MD5 Checksum
+  firefox_0.9.2.orig.tar.gz 9.5 MiB ...
 
   >>> print browser.getLink("firefox_0.9.2.orig.tar.gz").url
-  http://launchpad.dev/ubuntu/warty/+source/mozilla-firefox/0.9/+files/firefox_0.9.2.orig.tar.gz
+  http://launchpad.dev/ubuntu/+archive/primary/+files/firefox_0.9.2.orig.tar.gz
 
 If we go to the same page for alsa-utils, the changelog has text that is
 linkified.
@@ -318,16 +320,17 @@
 published version) if they are available:
 
     >>> print extract_text(find_tag_by_id(browser.contents, 'files'))
-    commercialpackage_1.0.orig.tar.gz (179 bytes)
-    commercialpackage_1.0-1.diff.gz (610 bytes)
-    commercialpackage_1.0-1.dsc (567 bytes)
+    File Size MD5 Checksum
+    commercialpackage_1.0.orig.tar.gz 179 bytes ...
+    commercialpackage_1.0-1.diff.gz 610 bytes ...
+    commercialpackage_1.0-1.dsc 567 bytes ...
 
     >>> print browser.getLink("commercialpackage_1.0.orig.tar.gz").url
-    http://launchpad.dev/ubuntu/breezy-autotest/+source/commercialpackage/1.0-1/+files/commercialpackage_1.0.orig.tar.gz
+    http://launchpad.dev/ubuntu/+archive/partner/+files/commercialpackage_1.0.orig.tar.gz
     >>> print browser.getLink("commercialpackage_1.0-1.diff.gz").url
-    http://launchpad.dev/ubuntu/breezy-autotest/+source/commercialpackage/1.0-1/+files/commercialpackage_1.0-1.diff.gz
+    http://launchpad.dev/ubuntu/+archive/partner/+files/commercialpackage_1.0-1.diff.gz
     >>> print browser.getLink("commercialpackage_1.0-1.dsc").url
-    http://launchpad.dev/ubuntu/breezy-autotest/+source/commercialpackage/1.0-1/+files/commercialpackage_1.0-1.dsc
+    http://launchpad.dev/ubuntu/+archive/partner/+files/commercialpackage_1.0-1.dsc
 
 This page also provides links to the binary packages generated by this
 source in a specfic architecture:
@@ -396,16 +399,17 @@
 '.diff' and the DSC:
 
     >>> print extract_text(find_tag_by_id(browser.contents, 'files'))
-    commercialpackage_1.0.orig.tar.gz (179 bytes)
-    commercialpackage_1.0-1.diff.gz (610 bytes)
-    commercialpackage_1.0-1.dsc (567 bytes)
+    File Size MD5 Checksum
+    commercialpackage_1.0.orig.tar.gz 179 bytes ...
+    commercialpackage_1.0-1.diff.gz 610 bytes ...
+    commercialpackage_1.0-1.dsc 567 bytes ...
 
     >>> print browser.getLink("commercialpackage_1.0.orig.tar.gz").url
-    http://launchpad.dev/ubuntu/breezy-autotest/+source/commercialpackage/1.0-1/+files/commercialpackage_1.0.orig.tar.gz
+    http://launchpad.dev/ubuntu/+archive/partner/+files/commercialpackage_1.0.orig.tar.gz
     >>> print browser.getLink("commercialpackage_1.0-1.diff.gz").url
-    http://launchpad.dev/ubuntu/breezy-autotest/+source/commercialpackage/1.0-1/+files/commercialpackage_1.0-1.diff.gz
+    http://launchpad.dev/ubuntu/+archive/partner/+files/commercialpackage_1.0-1.diff.gz
     >>> print browser.getLink("commercialpackage_1.0-1.dsc").url
-    http://launchpad.dev/ubuntu/breezy-autotest/+source/commercialpackage/1.0-1/+files/commercialpackage_1.0-1.dsc
+    http://launchpad.dev/ubuntu/+archive/partner/+files/commercialpackage_1.0-1.dsc
 
 
 Tracing copied sources

=== renamed file 'lib/lp/soyuz/templates/sourcepackagerelease-files.pt' => 'lib/lp/soyuz/templates/distributionsourcepackagerelease-files.pt'
--- lib/lp/soyuz/templates/sourcepackagerelease-files.pt	2010-05-28 16:16:50 +0000
+++ lib/lp/soyuz/templates/distributionsourcepackagerelease-files.pt	2014-11-09 01:58:00 +0000
@@ -3,18 +3,32 @@
   xmlns:metal="http://xml.zope.org/namespaces/metal";
   xmlns:i18n="http://xml.zope.org/namespaces/i18n";
   omit-tag="">
- <ul tal:condition="context/files">
-    <li tal:repeat="file context/files">
-      <tal:file_available condition="not:file/libraryfile/deleted">
-      <a class="sprite download"
-         tal:content="file/libraryfile/filename"
-         tal:attributes="href string:${context/fmt:url}/+files/${file/libraryfile/filename}" />
-      (<span tal:replace="file/libraryfile/content/filesize/fmt:bytes" />)
+  <table tal:condition="view/files" class="narrow listing">
+  <thead>
+    <tr>
+    <th>File</th>
+    <th>Size</th>
+    <th>MD5 Checksum</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr tal:repeat="file view/files">
+      <tal:file_available condition="not:file/deleted">
+        <td>
+          <a class="sprite download"
+            tal:attributes="href file/http_url"
+            tal:content="file/filename">foo_1.0.dsc</a>
+        </td>
+        <td tal:content="file/content/filesize/fmt:bytes">10 bytes</td>
+        <td tal:content="file/content/md5">DEADBEEF</td>
       </tal:file_available>
-      <tal:file_unavailable condition="file/libraryfile/deleted">
-         <span tal:replace="file/libraryfile/filename">foo.dsc</span> (deleted)
+      <tal:file_unavailable condition="file/deleted">
+        <td span="3">
+          <span tal:replace="file/filename">foo.dsc</span> (deleted)
+        </td>
       </tal:file_unavailable>
-    </li>
- </ul>
- <p tal:condition="not:context/files">No files available for download.</p>
+    </tr>
+  </tbody>
+  </table>
+  <p tal:condition="not:view/files">No files available for download.</p>
 </tal:root>

=== modified file 'lib/lp/soyuz/templates/distributionsourcepackagerelease-index.pt'
--- lib/lp/soyuz/templates/distributionsourcepackagerelease-index.pt	2010-10-10 21:54:16 +0000
+++ lib/lp/soyuz/templates/distributionsourcepackagerelease-index.pt	2014-11-09 01:58:00 +0000
@@ -140,33 +140,8 @@
 
   <div id="source-files" class="portlet">
    <h2>Downloads</h2>
-   <table class="narrow listing">
-    <thead>
-     <tr>
-      <th>File</th>
-      <th>Size</th>
-      <th>MD5 Checksum</th>
-     </tr>
-    </thead>
-    <tbody>
-      <tr tal:repeat="file view/files">
-       <tal:file_available condition="not:file/deleted">
-         <td>
-           <a class="sprite download"
-              tal:attributes="href file/http_url"
-              tal:content="file/filename">foo_1.0.dsc</a>
-         </td>
-         <td tal:content="file/content/filesize/fmt:bytes">10 bytes</td>
-         <td tal:content="file/content/md5">DEADBEEF</td>
-       </tal:file_available>
-       <tal:file_unavailable condition="file/deleted">
-         <td span=3>
-           <span tal:replace="file/filename">foo.dsc</span> (deleted)
-         </td>
-       </tal:file_unavailable>
-      </tr>
-    </tbody>
-   </table>
+   <tal:files replace="structure context/@@+files">Files...</tal:files>
+
    <tal:diffs
      replace="structure context/sourcepackagerelease/@@+diffs"
      >Diffs...</tal:diffs>

=== modified file 'lib/lp/soyuz/templates/distroseriessourcepackagerelease-index.pt'
--- lib/lp/soyuz/templates/distroseriessourcepackagerelease-index.pt	2014-04-24 06:42:52 +0000
+++ lib/lp/soyuz/templates/distroseriessourcepackagerelease-index.pt	2014-11-09 01:58:00 +0000
@@ -33,7 +33,7 @@
       <div class="portlet">
         <h2>Download</h2>
         <div id="files"
-             tal:content="structure context/@@+files" />
+             tal:content="structure context/distributionsourcepackagerelease/@@+files" />
       </div>
     </div>
 


References