8687.15.17
by Karl Fogel
Add the copyright header block to the rest of the files under lib/lp/. |
1 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
2705
by Canonical.com Patch Queue Manager
r=spiv, mark's soyuz loving. |
3 |
|
4 |
__metaclass__ = type |
|
5 |
||
6 |
__all__ = [ |
|
9855.4.5
by William Grant
Add DistributionSourcePackageRelease breadcrumb, and fix tests. |
7 |
'DistributionSourcePackageReleaseBreadcrumb', |
2705
by Canonical.com Patch Queue Manager
r=spiv, mark's soyuz loving. |
8 |
'DistributionSourcePackageReleaseNavigation', |
9855.4.5
by William Grant
Add DistributionSourcePackageRelease breadcrumb, and fix tests. |
9 |
'DistributionSourcePackageReleasePublishingHistoryView', |
9256.2.4
by Celso Providelo
First take on DSPR-3.0. |
10 |
'DistributionSourcePackageReleaseView', |
2705
by Canonical.com Patch Queue Manager
r=spiv, mark's soyuz loving. |
11 |
]
|
12 |
||
9256.2.4
by Celso Providelo
First take on DSPR-3.0. |
13 |
import operator |
14 |
||
13931.2.1
by Steve Kowalik
Chip away at canonical.lazr a little more. |
15 |
from lazr.restful.utils import smartquote |
16 |
||
14612.2.1
by William Grant
format-imports on lib/. So many imports. |
17 |
from lp.archivepublisher.debversion import Version |
18 |
from lp.services.librarian.browser import ProxiedLibraryFileAlias |
|
19 |
from lp.services.propertycache import cachedproperty |
|
14600.2.2
by Curtis Hovey
Moved webapp to lp.services. |
20 |
from lp.services.webapp import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
21 |
LaunchpadView, |
22 |
Navigation, |
|
23 |
)
|
|
14600.2.2
by Curtis Hovey
Moved webapp to lp.services. |
24 |
from lp.services.webapp.breadcrumb import Breadcrumb |
12119.1.23
by Tim Penhey
Refactor the build traversal code to use a mixin. |
25 |
from lp.soyuz.browser.build import BuildNavigationMixin |
11382.6.44
by Gavin Panella
Fix and reformat imports. |
26 |
from lp.soyuz.enums import PackagePublishingStatus |
8447.1.2
by Jonathan Lange
Fix up lots of lint, including removing code that's been disabled forever. |
27 |
from lp.soyuz.interfaces.distributionsourcepackagerelease import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
28 |
IDistributionSourcePackageRelease, |
29 |
)
|
|
2705
by Canonical.com Patch Queue Manager
r=spiv, mark's soyuz loving. |
30 |
|
31 |
||
9855.4.5
by William Grant
Add DistributionSourcePackageRelease breadcrumb, and fix tests. |
32 |
class DistributionSourcePackageReleaseBreadcrumb(Breadcrumb): |
33 |
"""A breadcrumb for `IDistributionSourcePackageRelease`."""
|
|
34 |
||
35 |
@property
|
|
36 |
def text(self): |
|
37 |
return self.context.version |
|
38 |
||
39 |
||
12119.1.23
by Tim Penhey
Refactor the build traversal code to use a mixin. |
40 |
class DistributionSourcePackageReleaseNavigation(Navigation, |
41 |
BuildNavigationMixin): |
|
2705
by Canonical.com Patch Queue Manager
r=spiv, mark's soyuz loving. |
42 |
usedfor = IDistributionSourcePackageRelease |
43 |
||
9256.2.4
by Celso Providelo
First take on DSPR-3.0. |
44 |
|
45 |
class DistributionSourcePackageReleaseView(LaunchpadView): |
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
46 |
"""View logic for `DistributionSourcePackageRelease` objects. """
|
47 |
||
9256.2.4
by Celso Providelo
First take on DSPR-3.0. |
48 |
usedfor = IDistributionSourcePackageRelease |
49 |
||
50 |
@property
|
|
9514.1.3
by Julian Edwards
Fix a load of page headings |
51 |
def label(self): |
52 |
return smartquote(self.context.title) |
|
9256.2.4
by Celso Providelo
First take on DSPR-3.0. |
53 |
|
9514.1.8
by Julian Edwards
fix a bunch of tests |
54 |
@property
|
55 |
def page_title(self): |
|
56 |
return self.label |
|
57 |
||
9256.2.4
by Celso Providelo
First take on DSPR-3.0. |
58 |
@cachedproperty
|
9256.2.5
by Celso Providelo
Adding view tests |
59 |
def _cached_publishing_history(self): |
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
60 |
"""Local copy of the context 'publishing_history' values."""
|
9256.2.5
by Celso Providelo
Adding view tests |
61 |
return list(self.context.publishing_history) |
62 |
||
63 |
@property
|
|
9256.2.4
by Celso Providelo
First take on DSPR-3.0. |
64 |
def currently_published(self): |
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
65 |
"""A list of published publications for this release.
|
9256.2.5
by Celso Providelo
Adding view tests |
66 |
|
67 |
:return: a `list` of `SourcePackagePublishingHistory` currently
|
|
68 |
published in the main archives.
|
|
69 |
"""
|
|
70 |
return [ |
|
71 |
publishing
|
|
72 |
for publishing in self._cached_publishing_history |
|
9256.2.4
by Celso Providelo
First take on DSPR-3.0. |
73 |
if publishing.status == PackagePublishingStatus.PUBLISHED |
74 |
]
|
|
75 |
||
76 |
@property
|
|
77 |
def files(self): |
|
9256.2.5
by Celso Providelo
Adding view tests |
78 |
"""The source package release files as `ProxiedLibraryFileAlias`."""
|
79 |
last_publication = self._cached_publishing_history[0] |
|
9256.2.4
by Celso Providelo
First take on DSPR-3.0. |
80 |
return [ |
81 |
ProxiedLibraryFileAlias( |
|
82 |
source_file.libraryfile, last_publication.archive) |
|
83 |
for source_file in self.context.files] |
|
84 |
||
85 |
@cachedproperty
|
|
86 |
def sponsor(self): |
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
87 |
"""This source package's sponsor.
|
9256.2.5
by Celso Providelo
Adding view tests |
88 |
|
89 |
A source package was sponsored if the owner of the key used to sign
|
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
90 |
its upload is different from its 'creator' (DSC 'Changed-by:')
|
9256.2.5
by Celso Providelo
Adding view tests |
91 |
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
92 |
:return: the sponsor `IPerson`, or none if the upload was not
|
93 |
sponsored.
|
|
9256.2.5
by Celso Providelo
Adding view tests |
94 |
"""
|
9256.2.4
by Celso Providelo
First take on DSPR-3.0. |
95 |
upload = self.context.package_upload |
96 |
if upload is None: |
|
97 |
return None |
|
98 |
signing_key = upload.signing_key |
|
99 |
if signing_key is None: |
|
100 |
return None |
|
101 |
if signing_key.owner.id == self.context.creator.id: |
|
102 |
return None |
|
103 |
return signing_key.owner |
|
104 |
||
105 |
@cachedproperty
|
|
106 |
def grouped_builds(self): |
|
9256.2.5
by Celso Providelo
Adding view tests |
107 |
"""Builds for this source in the primary archive grouped by series.
|
108 |
||
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
109 |
:return: a `list` of dictionaries containing 'distroseries' and its
|
110 |
grouped 'builds' ordered by descending distroseries versions.
|
|
9256.2.5
by Celso Providelo
Adding view tests |
111 |
"""
|
10667.2.2
by Michael Nelson
Mass renaming of imports and references to IBuild/Build/IBuildSet |
112 |
# Build a local list of `IBinaryPackageBuilds` ordered by ascending
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
113 |
# 'architecture_tag'.
|
9256.2.4
by Celso Providelo
First take on DSPR-3.0. |
114 |
cached_builds = sorted( |
115 |
self.context.builds, key=operator.attrgetter('arch_tag')) |
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
116 |
|
117 |
# Build a list of unique `IDistroSeries` related with the local
|
|
118 |
# builds ordered by descending version.
|
|
119 |
def distroseries_sort_key(item): |
|
120 |
return Version(item.version) |
|
121 |
sorted_distroseries = sorted( |
|
7675.687.103
by Michael Nelson
package-pages-navigation.txt |
122 |
set(build.distro_series for build in cached_builds), |
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
123 |
key=distroseries_sort_key, reverse=True) |
124 |
||
125 |
# Group builds as dictionaries.
|
|
126 |
distroseries_builds = [] |
|
127 |
for distroseries in sorted_distroseries: |
|
128 |
builds = [ |
|
129 |
build
|
|
130 |
for build in cached_builds |
|
7675.687.103
by Michael Nelson
package-pages-navigation.txt |
131 |
if build.distro_series == distroseries |
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
132 |
]
|
133 |
distroseries_builds.append( |
|
134 |
{'distroseries': distroseries, 'builds': builds}) |
|
135 |
||
136 |
return distroseries_builds |
|
9558.4.1
by Celso Providelo
Fixing heading and titles for DistributionSourcePackage:+{changelog, publishinghistory} and DistroSeriesSourcePackage:+publishinghistory pages. |
137 |
|
138 |
||
139 |
class DistributionSourcePackageReleasePublishingHistoryView(LaunchpadView): |
|
140 |
"""Presenting `DistributionSourcePackageRelease` publishing history."""
|
|
141 |
||
142 |
usedfor = IDistributionSourcePackageRelease |
|
143 |
||
144 |
page_title = 'Publishing history' |
|
145 |
||
146 |
@property
|
|
147 |
def label(self): |
|
148 |
return 'Publishing history of %s' % smartquote(self.context.title) |