Merge lp:~cjwatson/launchpad/queue-upload-file-links into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18370
Proposed branch: lp:~cjwatson/launchpad/queue-upload-file-links
Merge into: lp:launchpad
Diff against target: 143 lines (+35/-20)
4 files modified
lib/lp/soyuz/browser/queue.py (+10/-3)
lib/lp/soyuz/browser/tests/test_queue.py (+5/-2)
lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt (+7/-6)
lib/lp/soyuz/templates/distroseries-queue.pt (+13/-9)
To merge this branch: bzr merge lp:~cjwatson/launchpad/queue-upload-file-links
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+323708@code.launchpad.net

Commit message

Make DistroSeries:+queue link to upload files via the webapp, to help dget users.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/browser/queue.py'
2--- lib/lp/soyuz/browser/queue.py 2016-05-26 14:53:06 +0000
3+++ lib/lp/soyuz/browser/queue.py 2017-05-06 09:36:26 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """Browser views for package queue."""
10@@ -27,7 +27,10 @@
11 load_related,
12 )
13 from lp.services.job.model.job import Job
14-from lp.services.librarian.browser import FileNavigationMixin
15+from lp.services.librarian.browser import (
16+ FileNavigationMixin,
17+ ProxiedLibraryFileAlias,
18+ )
19 from lp.services.librarian.model import (
20 LibraryFileAlias,
21 LibraryFileContent,
22@@ -588,7 +591,7 @@
23 else:
24 return structured(
25 '<a href="%s" title="Changes file for %s">%s</a>',
26- self.changesfile.http_url, self.displayname,
27+ self.proxiedFile(self.changesfile).http_url, self.displayname,
28 self.displayname)
29
30 @property
31@@ -601,3 +604,7 @@
32 return structured(
33 """<div id="%s"> %s %s (%s)</div>""",
34 iconlist_id, icon_string, link, self.displayarchs).escapedtext
35+
36+ def proxiedFile(self, libraryfile):
37+ """Return a librarian file proxied in the context of this upload."""
38+ return ProxiedLibraryFileAlias(libraryfile, self.context)
39
40=== modified file 'lib/lp/soyuz/browser/tests/test_queue.py'
41--- lib/lp/soyuz/browser/tests/test_queue.py 2015-10-21 09:37:08 +0000
42+++ lib/lp/soyuz/browser/tests/test_queue.py 2017-05-06 09:36:26 +0000
43@@ -1,4 +1,4 @@
44-# Copyright 2010-2013 Canonical Ltd. This software is licensed under the
45+# Copyright 2010-2017 Canonical Ltd. This software is licensed under the
46 # GNU Affero General Public License version 3 (see the file LICENSE).
47
48 """Unit tests for QueueItemsView."""
49@@ -17,6 +17,7 @@
50
51 from lp.archiveuploader.tests import datadir
52 from lp.registry.interfaces.pocket import PackagePublishingPocket
53+from lp.services.librarian.browser import ProxiedLibraryFileAlias
54 from lp.services.webapp.escaping import html_escape
55 from lp.services.webapp.publisher import canonical_url
56 from lp.services.webapp.servers import LaunchpadTestRequest
57@@ -588,7 +589,9 @@
58 link = html.fromstring(
59 html_escape(complete_upload.composeNameAndChangesLink()))
60 self.assertEqual(
61- complete_upload.changesfile.http_url, link.get("href"))
62+ ProxiedLibraryFileAlias(
63+ complete_upload.changesfile, complete_upload.context).http_url,
64+ link.get("href"))
65
66 def test_composeNameAndChangesLink_escapes_nonlinked_display_name(self):
67 filename = 'name"&name'
68
69=== modified file 'lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt'
70--- lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt 2016-01-26 15:47:37 +0000
71+++ lib/lp/soyuz/stories/soyuz/xx-queue-pages.txt 2017-05-06 09:36:26 +0000
72@@ -80,11 +80,11 @@
73
74 >>> print anon_browser.getLink("netapplet-1.0.0.tar.gz")
75 <Link text='netapplet-1.0.0.tar.gz'
76- url='http://.../1/netapplet-1.0.0.tar.gz'>
77+ url='http://.../+upload/7/+files/netapplet-1.0.0.tar.gz'>
78
79 >>> print anon_browser.getLink("alsa-utils")
80 <Link text='alsa-utils'
81- url='http://.../1/netapplet-1.0.0.tar.gz'>
82+ url='http://.../+upload/4/+files/netapplet-1.0.0.tar.gz'>
83
84 (This link for alsa-utils is pointing at the librarian URL for
85 netapplet, because we have used its changes file for all the
86@@ -227,16 +227,17 @@
87 alsa-utils_1.0.9a-4ubuntu1.diff.gz
88 diff from 1.0.9a-4 to 1.0.9a-4ubuntu1 (11 bytes)
89
90-Each unexpired filename links to its respective librarian URL. Expired
91-files have no link, so we just get None.
92+Each unexpired filename links to its respective proxied librarian URL.
93+Expired files have no link, so we just get None.
94
95 >>> for row in filelist:
96 ... print row.find('a')
97- <a href="http://.../alsa-utils_1.0.9a-4ubuntu1.dsc">
98+ <a href="http://.../+upload/4/+files/alsa-utils_1.0.9a-4ubuntu1.dsc">
99 alsa-utils_1.0.9a-4ubuntu1.dsc
100 </a>
101 None
102- <a href="http://.../alsa-utils.diff.gz">diff from 1.0.9a-4 to 1.0.9a-4ubuntu1</a>
103+ <a href="http://.../alsa-utils.diff.gz">diff from 1.0.9a-4 to
104+ 1.0.9a-4ubuntu1</a>
105
106 On binary queue items we also present the stamp 'NEW' for files never
107 published in the archive (it helps archive admins when reviewing
108
109=== modified file 'lib/lp/soyuz/templates/distroseries-queue.pt'
110--- lib/lp/soyuz/templates/distroseries-queue.pt 2013-05-30 00:32:12 +0000
111+++ lib/lp/soyuz/templates/distroseries-queue.pt 2017-05-06 09:36:26 +0000
112@@ -312,18 +312,22 @@
113 <metal:macro define-macro="package-file">
114 <tal:comment replace="nothing">
115 This macro expects the following variables defined:
116+ :packageupload: A PackageUpload record for which we display files.
117 :libraryfilealias: A LibraryFileAlias to link to. If it is expired,
118 no link will be created.
119 </tal:comment>
120- <tal:unexpired tal:condition="libraryfilealias/content">
121- <a tal:attributes="href libraryfilealias/http_url">
122- <tal:filename replace="libraryfilealias/filename"/>
123- </a>
124- (<span tal:replace="libraryfilealias/content/filesize/fmt:bytes" />)
125- </tal:unexpired>
126- <tal:expired tal:condition="not:libraryfilealias/content">
127- <span tal:content="libraryfilealias/filename"/>
128- </tal:expired>
129+ <tal:proxy
130+ define="proxiedfile python:packageupload.proxiedFile(libraryfilealias)">
131+ <tal:unexpired condition="proxiedfile/content">
132+ <a tal:attributes="href proxiedfile/http_url">
133+ <tal:filename replace="proxiedfile/filename"/>
134+ </a>
135+ (<span tal:replace="proxiedfile/content/filesize/fmt:bytes" />)
136+ </tal:unexpired>
137+ <tal:expired condition="not:proxiedfile/content">
138+ <span tal:content="proxiedfile/filename"/>
139+ </tal:expired>
140+ </tal:proxy>
141 </metal:macro>
142
143 </metal:macros>