12293.1.11
by Curtis Hovey
Updated copyright. |
1 |
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
|
8687.15.17
by Karl Fogel
Add the copyright header block to the rest of the files under lib/lp/. |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
2068
by Canonical.com Patch Queue Manager
[r=SteveA/trivial] import fascism, kill translationeffort, kill sshkey browser code, add __all__s to interfaces, other cleanings-up |
3 |
|
4436.2.5
by Curtis Hovey
Fixed long lines. |
4 |
"""Browser views for sourcepackages."""
|
5 |
||
1706
by Canonical.com Patch Queue Manager
fixrosettatemplateviews |
6 |
__metaclass__ = type |
1042
by Canonical.com Patch Queue Manager
Removing deprecated AppComponent Classes |
7 |
|
2071
by Canonical.com Patch Queue Manager
[trivial] add more __all__ statements, other minor tidyings-up |
8 |
__all__ = [ |
11869.10.5
by Curtis Hovey
Added PackageUpstreamTracking to summarise the state between the package and upstream versions. |
9 |
'PackageUpstreamTracking', |
10212.1.1
by Brad Crittenden
Checkpoint |
10 |
'SourcePackageAssociationPortletView', |
9209.4.5
by Guilherme Salgado
Update all existing breadcrumb adapters to use Breadcrumb rather than BreadcrumbBuilder. Also rename them all |
11 |
'SourcePackageBreadcrumb', |
8879.4.4
by Edwin Grubbs
Make +edit-packaging use the picker widget. |
12 |
'SourcePackageChangeUpstreamView', |
6767.6.5
by Maris Fogels
Migrated the Sourcepackage breadcrumb to the new system interface. |
13 |
'SourcePackageFacets', |
1716.1.190
by Christian Reis
Merge from RF, again, this time for real |
14 |
'SourcePackageNavigation', |
12811.1.1
by Steve Kowalik
Fix two import violations |
15 |
'SourcePackageOverviewMenu', |
10374.2.1
by Edwin Grubbs
Added sourcepackage/+remove-packaging view. |
16 |
'SourcePackageRemoveUpstreamView', |
10374.2.9
by Edwin Grubbs
Added the ability to hide the edit buttons on $sourcepackage/+upstream-connections. |
17 |
'SourcePackageUpstreamConnectionsView', |
2071
by Canonical.com Patch Queue Manager
[trivial] add more __all__ statements, other minor tidyings-up |
18 |
'SourcePackageView', |
3024.1.60
by Christian Reis
Whitespace fixes |
19 |
]
|
2071
by Canonical.com Patch Queue Manager
[trivial] add more __all__ statements, other minor tidyings-up |
20 |
|
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
21 |
import string |
22 |
import urllib |
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
23 |
|
11869.10.4
by Curtis Hovey
Use apt_pkg.CompareVersion to compare upstream to the spr version. |
24 |
from apt_pkg import ( |
25 |
ParseSrcDepends, |
|
11869.10.10
by Curtis Hovey
Use a proven utility to extract the upstream_version. |
26 |
upstream_version, |
11869.10.4
by Curtis Hovey
Use apt_pkg.CompareVersion to compare upstream to the spr version. |
27 |
VersionCompare, |
28 |
)
|
|
11869.10.5
by Curtis Hovey
Added PackageUpstreamTracking to summarise the state between the package and upstream versions. |
29 |
from lazr.enum import ( |
30 |
EnumeratedType, |
|
31 |
Item, |
|
32 |
)
|
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
33 |
from lazr.restful.interface import copy_field |
10304.4.1
by Edwin Grubbs
2 step form. |
34 |
from z3c.ptcompat import ViewPageTemplateFile |
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
35 |
from zope.app.form.browser import DropdownWidget |
36 |
from zope.app.form.interfaces import IInputWidget |
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
37 |
from zope.component import ( |
11664.3.2
by Edwin Grubbs
IService adapters and disable Report Bug button and bug listing in buglisting-default.pt for objects that do not use LP. |
38 |
adapter, |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
39 |
getMultiAdapter, |
40 |
getUtility, |
|
41 |
)
|
|
10304.4.1
by Edwin Grubbs
2 step form. |
42 |
from zope.formlib.form import Fields |
11664.3.2
by Edwin Grubbs
IService adapters and disable Report Bug button and bug listing in buglisting-default.pt for objects that do not use LP. |
43 |
from zope.interface import ( |
44 |
implements, |
|
45 |
Interface, |
|
46 |
)
|
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
47 |
from zope.schema import ( |
48 |
Choice, |
|
49 |
TextLine, |
|
50 |
)
|
|
10212.1.2
by Brad Crittenden
Add upstream associations portlet to display upstream info or give the user a chance to make the connection. |
51 |
from zope.schema.vocabulary import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
52 |
getVocabularyRegistry, |
53 |
SimpleTerm, |
|
54 |
SimpleVocabulary, |
|
55 |
)
|
|
56 |
||
57 |
from canonical.launchpad import ( |
|
58 |
_, |
|
59 |
helpers, |
|
60 |
)
|
|
61 |
from canonical.launchpad.browser.multistep import ( |
|
62 |
MultiStepView, |
|
63 |
StepView, |
|
64 |
)
|
|
65 |
from canonical.launchpad.webapp import ( |
|
66 |
ApplicationMenu, |
|
67 |
canonical_url, |
|
68 |
GetitemNavigation, |
|
69 |
Link, |
|
70 |
StandardLaunchpadFacets, |
|
71 |
stepto, |
|
72 |
)
|
|
73 |
from canonical.launchpad.webapp.breadcrumb import Breadcrumb |
|
12293.1.10
by Curtis Hovey
Formatted imports. |
74 |
from canonical.launchpad.webapp.interfaces import IBreadcrumb |
11929.9.1
by Tim Penhey
Move launchpadform into lp.app.browser. |
75 |
from canonical.launchpad.webapp.menu import structured |
76 |
from canonical.launchpad.webapp.publisher import LaunchpadView |
|
77 |
from canonical.lazr.utils import smartquote |
|
78 |
from lp.app.browser.launchpadform import ( |
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
79 |
action, |
80 |
custom_widget, |
|
81 |
LaunchpadFormView, |
|
82 |
ReturnToReferrerMixin, |
|
83 |
)
|
|
12293.1.10
by Curtis Hovey
Formatted imports. |
84 |
from lp.app.browser.tales import CustomizableFormatter |
11411.7.1
by j.c.sackett
Fixed majority of official_malone calls in code-space. Still need to fix templates. |
85 |
from lp.app.enums import ServiceUsage |
12293.1.10
by Curtis Hovey
Formatted imports. |
86 |
from lp.app.widgets.itemswidgets import LaunchpadRadioWidget |
8523.3.1
by Gavin Panella
Bugs tree reorg after automated migration. |
87 |
from lp.bugs.browser.bugtask import BugTargetTraversalMixin |
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
88 |
from lp.registry.browser.product import ProjectAddStepOne |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
89 |
from lp.registry.interfaces.packaging import ( |
90 |
IPackaging, |
|
91 |
IPackagingUtil, |
|
92 |
)
|
|
9113.7.4
by Jonathan Lange
Update many imports of pocket. |
93 |
from lp.registry.interfaces.pocket import PackagePublishingPocket |
10304.4.1
by Edwin Grubbs
2 step form. |
94 |
from lp.registry.interfaces.product import IProductSet |
95 |
from lp.registry.interfaces.productseries import IProductSeries |
|
96 |
from lp.registry.interfaces.series import SeriesStatus |
|
7675.110.3
by Curtis Hovey
Ran the migration script to move registry code to lp.registry. |
97 |
from lp.registry.interfaces.sourcepackage import ISourcePackage |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
98 |
from lp.services.worlddata.interfaces.country import ICountry |
13130.1.12
by Curtis Hovey
Sorted imports. |
99 |
from lp.soyuz.browser.packagerelationship import relationship_builder |
8777.6.1
by Danilo Šegan
Move SourcePackage translation views out of registry and into translations. |
100 |
from lp.translations.interfaces.potemplate import IPOTemplateSet |
6476.1.7
by Matthew Paul Thomas
Fixes distribution series source package pages. |
101 |
|
2457
by Canonical.com Patch Queue Manager
[r=lifeless] Launchpad Auto Build System User Interface Prototype (buildfarm UI) also minor fixes for buildd infrastructure, still needing mpt love. |
102 |
|
11275.1.14
by Edwin Grubbs
Autolink source package to newly created project. |
103 |
def get_register_upstream_url(source_package): |
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
104 |
displayname = string.capwords(source_package.name.replace('-', ' ')) |
11275.1.14
by Edwin Grubbs
Autolink source package to newly created project. |
105 |
distroseries_string = "%s/%s" % ( |
106 |
source_package.distroseries.distribution.name, |
|
107 |
source_package.distroseries.name) |
|
11954.5.1
by Curtis Hovey
Prefill homepageurl when registering a project for a package. |
108 |
current_release = source_package.currentrelease |
109 |
if current_release is not None and current_release.homepage is not None: |
|
110 |
homepage = current_release.homepage |
|
111 |
else: |
|
112 |
homepage = '' |
|
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
113 |
params = { |
11275.1.14
by Edwin Grubbs
Autolink source package to newly created project. |
114 |
'_return_url': canonical_url(source_package), |
11275.1.13
by Edwin Grubbs
Pass in source_package_name from source package page. Fixed tests. |
115 |
'field.source_package_name': source_package.sourcepackagename.name, |
11275.1.14
by Edwin Grubbs
Autolink source package to newly created project. |
116 |
'field.distroseries': distroseries_string, |
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
117 |
'field.name': source_package.name, |
118 |
'field.displayname': displayname, |
|
119 |
'field.title': displayname, |
|
11954.5.1
by Curtis Hovey
Prefill homepageurl when registering a project for a package. |
120 |
'field.homepageurl': homepage, |
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
121 |
'field.__visited_steps__': ProjectAddStepOne.step_name, |
122 |
'field.actions.continue': 'Continue', |
|
123 |
}
|
|
11275.1.11
by Edwin Grubbs
Removed binary.name from auto filled project summary. |
124 |
if len(source_package.releases) == 0: |
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
125 |
params['field.summary'] = '' |
126 |
else: |
|
11275.1.11
by Edwin Grubbs
Removed binary.name from auto filled project summary. |
127 |
# This is based on the SourcePackageName.summary attribute, but
|
128 |
# it eliminates the binary.name and duplicate summary lines.
|
|
129 |
summary_set = set() |
|
130 |
for binary in source_package.releases[0].sample_binary_packages: |
|
131 |
summary_set.add(binary.summary) |
|
132 |
params['field.summary'] = '\n'.join(sorted(summary_set)) |
|
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
133 |
query_string = urllib.urlencode( |
134 |
sorted(params.items()), doseq=True) |
|
135 |
return '/projects/+new?%s' % query_string |
|
136 |
||
137 |
||
11551.8.16
by j.c.sackett
Moved SourcePackageFormatterAPI into browser.sourcepackage and changed permission to public. |
138 |
class SourcePackageFormatterAPI(CustomizableFormatter): |
139 |
"""Adapter for ISourcePackage objects to a formatted string."""
|
|
140 |
||
141 |
_link_permission = 'zope.Public' |
|
142 |
||
143 |
_link_summary_template = '%(displayname)s' |
|
144 |
||
145 |
def _link_summary_values(self): |
|
146 |
displayname = self._context.displayname |
|
147 |
return {'displayname': displayname} |
|
148 |
||
149 |
||
2705
by Canonical.com Patch Queue Manager
r=spiv, mark's soyuz loving. |
150 |
class SourcePackageNavigation(GetitemNavigation, BugTargetTraversalMixin): |
1716.1.190
by Christian Reis
Merge from RF, again, this time for real |
151 |
|
152 |
usedfor = ISourcePackage |
|
153 |
||
154 |
@stepto('+pots') |
|
155 |
def pots(self): |
|
156 |
potemplateset = getUtility(IPOTemplateSet) |
|
4200.4.17
by Carlos Perello Marin
Applied review comments |
157 |
sourcepackage_pots = potemplateset.getSubset( |
4285.2.1
by Mark Shuttleworth
Massive renaming of distrorelease to distroseries |
158 |
distroseries=self.context.distroseries, |
4200.4.4
by Carlos Perello Marin
Added a new exception 'AccessDisabledError' raised when we should hide translations to non admin users |
159 |
sourcepackagename=self.context.sourcepackagename) |
160 |
||
10326.5.1
by Adi Roiban
Refactor checkTranslationsViewable(), merge the model and view logic and move it to a view helper. Make the security check in only one place. |
161 |
# If we are able to view the translations for distribution series
|
162 |
# we should also be allowed to see them for a distribution
|
|
10326.5.2
by Adi Roiban
Merge distroseries view permission tests. |
163 |
# source package.
|
164 |
# If not, raise TranslationUnavailable.
|
|
10326.5.5
by Adi Roiban
Merge devel. Fix circular import problem. |
165 |
from lp.translations.browser.distroseries import ( |
166 |
check_distroseries_translations_viewable) |
|
10326.5.1
by Adi Roiban
Refactor checkTranslationsViewable(), merge the model and view logic and move it to a view helper. Make the security check in only one place. |
167 |
check_distroseries_translations_viewable(self.context.distroseries) |
4200.4.4
by Carlos Perello Marin
Added a new exception 'AccessDisabledError' raised when we should hide translations to non admin users |
168 |
|
4200.4.17
by Carlos Perello Marin
Applied review comments |
169 |
return sourcepackage_pots |
1716.1.190
by Christian Reis
Merge from RF, again, this time for real |
170 |
|
2764.2.1
by Brad Bollenbach
apply my +filebug patch on a fresh new bzr branch |
171 |
@stepto('+filebug') |
172 |
def filebug(self): |
|
173 |
"""Redirect to the IDistributionSourcePackage +filebug page."""
|
|
13014.2.2
by Curtis Hovey
Remove IQuestionTarget from ISourcePackage. |
174 |
distro_sourcepackage = self.context.distribution_sourcepackage |
2764.2.1
by Brad Bollenbach
apply my +filebug patch on a fresh new bzr branch |
175 |
|
9558.3.1
by Tom Berger
carry on the no-redirect parameter when redirecting to a new filebug view |
176 |
redirection_url = canonical_url( |
177 |
distro_sourcepackage, view_name='+filebug') |
|
178 |
if self.request.form.get('no-redirect') is not None: |
|
179 |
redirection_url += '?no-redirect' |
|
13031.1.1
by William Grant
Fix redirect status code for SourcePackage:+filebug. |
180 |
return self.redirectSubTree(redirection_url, status=303) |
1716.1.190
by Christian Reis
Merge from RF, again, this time for real |
181 |
|
13014.2.2
by Curtis Hovey
Remove IQuestionTarget from ISourcePackage. |
182 |
@stepto('+gethelp') |
183 |
def gethelp(self): |
|
184 |
"""Redirect to the IDistributionSourcePackage +gethelp page."""
|
|
185 |
dsp = self.context.distribution_sourcepackage |
|
186 |
redirection_url = canonical_url(dsp, view_name='+gethelp') |
|
13014.2.10
by Curtis Hovey
Merged devel an resolve a conflict. |
187 |
return self.redirectSubTree(redirection_url, status=303) |
13014.2.2
by Curtis Hovey
Remove IQuestionTarget from ISourcePackage. |
188 |
|
2630
by Canonical.com Patch Queue Manager
[trivial] lots of tidying up. converting all database classes to use NotFoundError consistently, and to import it from launchpad.interfaces in preparation for the move to a new zope3. Also, introduced a NameNotAvailable error. removed browser:traverse rdirective. commented out shipit test that fails sometimes. |
189 |
|
11664.3.2
by Edwin Grubbs
IService adapters and disable Report Bug button and bug listing in buglisting-default.pt for objects that do not use LP. |
190 |
@adapter(ISourcePackage) |
9209.4.5
by Guilherme Salgado
Update all existing breadcrumb adapters to use Breadcrumb rather than BreadcrumbBuilder. Also rename them all |
191 |
class SourcePackageBreadcrumb(Breadcrumb): |
6767.6.26
by Maris Fogels
Rework based on reviewer feedback. |
192 |
"""Builds a breadcrumb for an `ISourcePackage`."""
|
11664.3.2
by Edwin Grubbs
IService adapters and disable Report Bug button and bug listing in buglisting-default.pt for objects that do not use LP. |
193 |
implements(IBreadcrumb) |
10326.5.1
by Adi Roiban
Refactor checkTranslationsViewable(), merge the model and view logic and move it to a view helper. Make the security check in only one place. |
194 |
|
6767.6.5
by Maris Fogels
Migrated the Sourcepackage breadcrumb to the new system interface. |
195 |
@property
|
196 |
def text(self): |
|
9514.1.3
by Julian Edwards
Fix a load of page headings |
197 |
return smartquote('"%s" source package') % (self.context.name) |
6767.6.5
by Maris Fogels
Migrated the Sourcepackage breadcrumb to the new system interface. |
198 |
|
199 |
||
13014.2.2
by Curtis Hovey
Remove IQuestionTarget from ISourcePackage. |
200 |
class SourcePackageFacets(StandardLaunchpadFacets): |
2396
by Canonical.com Patch Queue Manager
[r=spiv] launchpad support tracker |
201 |
|
202 |
usedfor = ISourcePackage |
|
13014.2.2
by Curtis Hovey
Remove IQuestionTarget from ISourcePackage. |
203 |
enable_only = ['overview', 'bugs', 'branches', 'translations'] |
2423
by Canonical.com Patch Queue Manager
r=bjornt plus some [trivial] extra refactorings. more consistent facet menus across the whole of launchpad. improvements in the API. |
204 |
|
13324.9.1
by Jonathan Riddell
add hover text for distro package pages |
205 |
def overview(self): |
206 |
text = 'Overview' |
|
13303.11.22
by Aaron Bentley
Fix lint. |
207 |
summary = 'General information about {0}'.format( |
208 |
self.context.displayname) |
|
13324.9.1
by Jonathan Riddell
add hover text for distro package pages |
209 |
return Link('', text, summary) |
210 |
||
211 |
def bugs(self): |
|
212 |
text = 'Bugs' |
|
213 |
summary = 'Bugs reported about {0}'.format(self.context.displayname) |
|
214 |
return Link('', text, summary) |
|
215 |
||
216 |
def branches(self): |
|
217 |
text = 'Code' |
|
218 |
summary = 'Branches for {0}'.format(self.context.displayname) |
|
219 |
return Link('', text, summary) |
|
220 |
||
221 |
def translations(self): |
|
222 |
text = 'Translations' |
|
13303.11.22
by Aaron Bentley
Fix lint. |
223 |
summary = 'Translations of {0} in Launchpad'.format( |
224 |
self.context.displayname) |
|
13324.9.1
by Jonathan Riddell
add hover text for distro package pages |
225 |
return Link('', text, summary) |
226 |
||
2396
by Canonical.com Patch Queue Manager
[r=spiv] launchpad support tracker |
227 |
|
2488
by Canonical.com Patch Queue Manager
r=SteveA, mpt's mpt@canonical.com/launchpad--menus--0509 adding menus to source packages |
228 |
class SourcePackageOverviewMenu(ApplicationMenu): |
229 |
||
230 |
usedfor = ISourcePackage |
|
231 |
facet = 'overview' |
|
9150.6.10
by Julian Edwards
fix packaging links |
232 |
links = [ |
10374.2.1
by Edwin Grubbs
Added sourcepackage/+remove-packaging view. |
233 |
'distribution_source_package', 'edit_packaging', 'remove_packaging', |
11078.4.3
by Curtis Hovey
Added sourcepackage +copyright. |
234 |
'changelog', 'copyright', 'builds', 'set_upstream', |
9742.9.1
by Edwin Grubbs
Added "All source package in Ubuntu for $sourcepackagename" link. |
235 |
]
|
236 |
||
237 |
def distribution_source_package(self): |
|
238 |
target = canonical_url(self.context.distribution_sourcepackage) |
|
9742.9.3
by Edwin Grubbs
Rephrased links and put in top-right corner of portlet. |
239 |
text = 'All versions of %s source in %s' % ( |
240 |
self.context.name, self.context.distribution.displayname) |
|
9742.9.1
by Edwin Grubbs
Added "All source package in Ubuntu for $sourcepackagename" link. |
241 |
return Link(target, text, icon='package-source') |
2488
by Canonical.com Patch Queue Manager
r=SteveA, mpt's mpt@canonical.com/launchpad--menus--0509 adding menus to source packages |
242 |
|
243 |
def changelog(self): |
|
3847.2.21
by Mark Shuttleworth
Fix Soyuz and Malone page tests for menu capitalisation |
244 |
return Link('+changelog', 'View changelog', icon='list') |
2488
by Canonical.com Patch Queue Manager
r=SteveA, mpt's mpt@canonical.com/launchpad--menus--0509 adding menus to source packages |
245 |
|
11078.4.3
by Curtis Hovey
Added sourcepackage +copyright. |
246 |
def copyright(self): |
247 |
return Link('+copyright', 'View copyright', icon='info') |
|
248 |
||
3691.421.1
by David Allouche
Remove references to HCT across the Launchpad UI. Improve the wording of some package-upstream linking pages. |
249 |
def edit_packaging(self): |
12769.1.3
by Abel Deuring
Enable the packaging related links for source package views only if the user has sufficent permissions. |
250 |
return Link( |
251 |
'+edit-packaging', 'Change upstream link', icon='edit', |
|
252 |
enabled=self.userCanDeletePackaging()) |
|
2488
by Canonical.com Patch Queue Manager
r=SteveA, mpt's mpt@canonical.com/launchpad--menus--0509 adding menus to source packages |
253 |
|
10374.2.1
by Edwin Grubbs
Added sourcepackage/+remove-packaging view. |
254 |
def remove_packaging(self): |
255 |
return Link( |
|
12769.1.3
by Abel Deuring
Enable the packaging related links for source package views only if the user has sufficent permissions. |
256 |
'+remove-packaging', 'Remove upstream link', icon='remove', |
257 |
enabled=self.userCanDeletePackaging()) |
|
10374.2.1
by Edwin Grubbs
Added sourcepackage/+remove-packaging view. |
258 |
|
9150.6.10
by Julian Edwards
fix packaging links |
259 |
def set_upstream(self): |
12769.1.3
by Abel Deuring
Enable the packaging related links for source package views only if the user has sufficent permissions. |
260 |
return Link( |
261 |
"+edit-packaging", "Set upstream link", icon="add", |
|
262 |
enabled=self.userCanDeletePackaging()) |
|
9150.6.10
by Julian Edwards
fix packaging links |
263 |
|
2772.1.15
by Celso Providelo
Unify +builds pages using the same template, macro usage still grumgy, fixed tests |
264 |
def builds(self): |
3847.2.21
by Mark Shuttleworth
Fix Soyuz and Malone page tests for menu capitalisation |
265 |
text = 'Show builds' |
3054.1.13
by Celso Providelo
Fix bug # 31039 on unescaped regexp when likifying sourcepackage changelog, added tests for sourcepackage view class and new sampledata |
266 |
return Link('+builds', text, icon='info') |
2772.1.15
by Celso Providelo
Unify +builds pages using the same template, macro usage still grumgy, fixed tests |
267 |
|
12769.1.3
by Abel Deuring
Enable the packaging related links for source package views only if the user has sufficent permissions. |
268 |
def userCanDeletePackaging(self): |
269 |
packaging = self.context.direct_packaging |
|
270 |
if packaging is None: |
|
271 |
return True |
|
272 |
return packaging.userCanDelete() |
|
273 |
||
2488
by Canonical.com Patch Queue Manager
r=SteveA, mpt's mpt@canonical.com/launchpad--menus--0509 adding menus to source packages |
274 |
|
10374.2.8
by Edwin Grubbs
Replace renderDeletePackagingAction with a link to the $sourcepackage/+remove-packaging. |
275 |
class SourcePackageChangeUpstreamStepOne(ReturnToReferrerMixin, StepView): |
10304.4.1
by Edwin Grubbs
2 step form. |
276 |
"""A view to set the `IProductSeries` of a sourcepackage."""
|
10304.4.8
by Edwin Grubbs
Fixed tests. |
277 |
schema = Interface |
278 |
_field_names = [] |
|
10304.4.1
by Edwin Grubbs
2 step form. |
279 |
|
280 |
step_name = 'sourcepackage_change_upstream_step1' |
|
281 |
template = ViewPageTemplateFile( |
|
282 |
'../templates/sourcepackage-edit-packaging.pt') |
|
283 |
label = 'Link to an upstream project' |
|
284 |
page_title = label |
|
285 |
step_description = 'Choose project' |
|
286 |
product = None |
|
287 |
||
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
288 |
def setUpFields(self): |
289 |
super(SourcePackageChangeUpstreamStepOne, self).setUpFields() |
|
290 |
series = self.context.productseries |
|
291 |
if series is not None: |
|
10304.4.8
by Edwin Grubbs
Fixed tests. |
292 |
default = series.product |
293 |
else: |
|
294 |
default = None |
|
295 |
product_field = copy_field( |
|
296 |
IProductSeries['product'], default=default) |
|
297 |
self.form_fields += Fields(product_field) |
|
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
298 |
|
10374.2.8
by Edwin Grubbs
Replace renderDeletePackagingAction with a link to the $sourcepackage/+remove-packaging. |
299 |
# Override ReturnToReferrerMixin.next_url.
|
300 |
next_url = None |
|
10304.4.1
by Edwin Grubbs
2 step form. |
301 |
|
302 |
def main_action(self, data): |
|
303 |
"""See `MultiStepView`."""
|
|
304 |
self.next_step = SourcePackageChangeUpstreamStepTwo |
|
305 |
self.request.form['product'] = data['product'] |
|
306 |
||
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
307 |
@property
|
308 |
def register_upstream_url(self): |
|
11275.1.14
by Edwin Grubbs
Autolink source package to newly created project. |
309 |
return get_register_upstream_url(self.context) |
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
310 |
|
10304.4.1
by Edwin Grubbs
2 step form. |
311 |
|
10374.2.8
by Edwin Grubbs
Replace renderDeletePackagingAction with a link to the $sourcepackage/+remove-packaging. |
312 |
class SourcePackageChangeUpstreamStepTwo(ReturnToReferrerMixin, StepView): |
10304.4.1
by Edwin Grubbs
2 step form. |
313 |
"""A view to set the `IProductSeries` of a sourcepackage."""
|
314 |
schema = IProductSeries |
|
315 |
_field_names = ['product'] |
|
316 |
||
317 |
step_name = 'sourcepackage_change_upstream_step2' |
|
318 |
template = ViewPageTemplateFile( |
|
319 |
'../templates/sourcepackage-edit-packaging.pt') |
|
320 |
label = 'Link to an upstream project' |
|
321 |
page_title = label |
|
322 |
step_description = 'Choose project series' |
|
323 |
product = None |
|
324 |
||
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
325 |
# The DropdownWidget is used, since the VocabularyPickerWidget
|
326 |
# does not support visible=False to turn it into a hidden input
|
|
327 |
# to continue passing the variable in the form.
|
|
328 |
custom_widget('product', DropdownWidget, visible=False) |
|
10304.4.1
by Edwin Grubbs
2 step form. |
329 |
custom_widget('productseries', LaunchpadRadioWidget) |
330 |
||
331 |
def setUpFields(self): |
|
332 |
super(SourcePackageChangeUpstreamStepTwo, self).setUpFields() |
|
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
333 |
|
334 |
# The vocabulary for the product series is overridden to just
|
|
335 |
# include active series from the product selected in the
|
|
336 |
# previous step.
|
|
10304.4.1
by Edwin Grubbs
2 step form. |
337 |
product_name = self.request.form['field.product'] |
338 |
self.product = getUtility(IProductSet)[product_name] |
|
339 |
series_list = [ |
|
340 |
series for series in self.product.series |
|
11411.7.33
by j.c.sackett
Lint fixes. |
341 |
if series.status != SeriesStatus.OBSOLETE] |
10374.1.1
by Edwin Grubbs
Fixed bug. |
342 |
|
343 |
# If the product is not being changed, then the current
|
|
344 |
# productseries can be the default choice. Otherwise,
|
|
345 |
# it will not exist in the vocabulary.
|
|
346 |
if (self.context.productseries is not None |
|
347 |
and self.context.productseries.product == self.product): |
|
348 |
series_default = self.context.productseries |
|
349 |
# This only happens for obsolete series, since they aren't
|
|
350 |
# added to the vocabulary normally.
|
|
351 |
if series_default not in series_list: |
|
352 |
series_list.append(series_default) |
|
353 |
else: |
|
354 |
series_default = None |
|
355 |
||
356 |
# Put the development focus at the top of the list and create
|
|
357 |
# the vocabulary.
|
|
10304.4.1
by Edwin Grubbs
2 step form. |
358 |
dev_focus = self.product.development_focus |
359 |
if dev_focus in series_list: |
|
360 |
series_list.remove(dev_focus) |
|
361 |
vocab_terms = [ |
|
362 |
SimpleTerm(series, series.name, series.name) |
|
11411.7.33
by j.c.sackett
Lint fixes. |
363 |
for series in series_list] |
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
364 |
dev_focus_term = SimpleTerm( |
365 |
dev_focus, dev_focus.name, "%s (Recommended)" % dev_focus.name) |
|
366 |
vocab_terms.insert(0, dev_focus_term) |
|
367 |
||
368 |
productseries_choice = Choice( |
|
10304.4.1
by Edwin Grubbs
2 step form. |
369 |
__name__='productseries', |
370 |
title=_("Series"), |
|
371 |
description=_("The series in this project."), |
|
372 |
vocabulary=SimpleVocabulary(vocab_terms), |
|
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
373 |
default=series_default, |
10304.4.1
by Edwin Grubbs
2 step form. |
374 |
required=True) |
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
375 |
|
376 |
# The product selected in the previous step should be displayed,
|
|
377 |
# but a widget can't be readonly and pass its value with the
|
|
378 |
# form, so the real product field passes the value, and this fake
|
|
379 |
# product field displays it.
|
|
380 |
display_product_field = TextLine( |
|
381 |
__name__='fake_product', |
|
382 |
title=_("Project"), |
|
383 |
default=self.product.displayname, |
|
384 |
readonly=True) |
|
385 |
||
386 |
self.form_fields = ( |
|
387 |
Fields(display_product_field, productseries_choice) |
|
388 |
+ self.form_fields) |
|
389 |
||
10374.2.8
by Edwin Grubbs
Replace renderDeletePackagingAction with a link to the $sourcepackage/+remove-packaging. |
390 |
# Override ReturnToReferrerMixin.next_url until the main_action()
|
391 |
# is called.
|
|
392 |
next_url = None |
|
393 |
||
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
394 |
main_action_label = u'Change' |
11551.8.25
by j.c.sackett
Lint fixes. |
395 |
|
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
396 |
def main_action(self, data): |
10304.4.1
by Edwin Grubbs
2 step form. |
397 |
productseries = data['productseries'] |
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
398 |
# Because it is part of a multistep view, the next_url can't
|
399 |
# be set until the action is called, or it will skip the step.
|
|
10374.2.8
by Edwin Grubbs
Replace renderDeletePackagingAction with a link to the $sourcepackage/+remove-packaging. |
400 |
self.next_url = self._return_url |
10304.4.1
by Edwin Grubbs
2 step form. |
401 |
if self.context.productseries == productseries: |
402 |
# There is nothing to do.
|
|
403 |
return
|
|
404 |
self.context.setPackaging(productseries, self.user) |
|
405 |
self.request.response.addNotification('Upstream link updated.') |
|
406 |
||
407 |
||
408 |
class SourcePackageChangeUpstreamView(MultiStepView): |
|
409 |
"""A view to set the `IProductSeries` of a sourcepackage."""
|
|
410 |
page_title = SourcePackageChangeUpstreamStepOne.page_title |
|
10304.4.2
by Edwin Grubbs
Working two-step $sourcepackage/+edit-packaging view. |
411 |
label = SourcePackageChangeUpstreamStepOne.label |
10304.4.1
by Edwin Grubbs
2 step form. |
412 |
total_steps = 2 |
413 |
first_step = SourcePackageChangeUpstreamStepOne |
|
414 |
||
415 |
||
10374.2.8
by Edwin Grubbs
Replace renderDeletePackagingAction with a link to the $sourcepackage/+remove-packaging. |
416 |
class SourcePackageRemoveUpstreamView(ReturnToReferrerMixin, |
417 |
LaunchpadFormView): |
|
10374.2.1
by Edwin Grubbs
Added sourcepackage/+remove-packaging view. |
418 |
"""A view for removing the link to an upstream package."""
|
419 |
||
420 |
schema = Interface |
|
421 |
field_names = [] |
|
10374.2.6
by Edwin Grubbs
Added test for removing packaging. |
422 |
label = 'Unlink an upstream project' |
423 |
page_title = label |
|
10374.2.1
by Edwin Grubbs
Added sourcepackage/+remove-packaging view. |
424 |
|
425 |
@action('Unlink') |
|
426 |
def unlink(self, action, data): |
|
427 |
old_series = self.context.productseries |
|
12818.1.1
by Abel Deuring
avoid an OOPS when somebody tries to delete a packaging link more than once. |
428 |
if self.context.direct_packaging is not None: |
429 |
getUtility(IPackagingUtil).deletePackaging( |
|
430 |
self.context.productseries, |
|
431 |
self.context.sourcepackagename, |
|
432 |
self.context.distroseries) |
|
433 |
self.request.response.addInfoNotification( |
|
434 |
'Removed upstream association between %s and %s.' % ( |
|
435 |
old_series.title, self.context.distroseries.displayname)) |
|
436 |
else: |
|
437 |
self.request.response.addInfoNotification( |
|
438 |
'The packaging link has already been deleted.') |
|
10374.2.3
by Edwin Grubbs
Changed info message. |
439 |
|
10374.2.1
by Edwin Grubbs
Added sourcepackage/+remove-packaging view. |
440 |
|
13303.11.10
by Aaron Bentley
Fix pages broken by assuming LaunchpadView. |
441 |
class SourcePackageView(LaunchpadView): |
9331.2.1
by Julian Edwards
Convert source package builds page to 3.0 |
442 |
"""A view for (distro series) source packages."""
|
1558
by Canonical.com Patch Queue Manager
revamp rosetta url schema, traversals and template listings |
443 |
|
2810.1.15
by Celso Providelo
Review comments applied, using LaunchpadView base class, fixing batching list setup |
444 |
def initialize(self): |
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
445 |
# lets add a widget for the product series to which this package is
|
446 |
# mapped in the Packaging table
|
|
447 |
raw_field = IPackaging['productseries'] |
|
448 |
bound_field = raw_field.bind(self.context) |
|
6061.2.22
by Gary Poster
use new API |
449 |
self.productseries_widget = getMultiAdapter( |
450 |
(bound_field, self.request), IInputWidget) |
|
2810.1.15
by Celso Providelo
Review comments applied, using LaunchpadView base class, fixing batching list setup |
451 |
self.productseries_widget.setRenderedValue(self.context.productseries) |
1558
by Canonical.com Patch Queue Manager
revamp rosetta url schema, traversals and template listings |
452 |
# List of languages the user is interested on based on their browser,
|
453 |
# IP address and launchpad preferences.
|
|
454 |
self.status_message = None |
|
5099.2.1
by Christian Robottom Reis
Fix silly message style problem in edit-packaging |
455 |
self.error_message = None |
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
456 |
self.processForm() |
457 |
||
8908.1.2
by Edwin Grubbs
Fixes bug 395038. |
458 |
@property
|
7675.298.204
by Edwin Grubbs
Fixed page titles and labels. |
459 |
def label(self): |
460 |
return self.context.title |
|
9425.4.3
by Curtis Hovey
Update source package +index to UI 3.0 |
461 |
|
462 |
@property
|
|
8908.1.2
by Edwin Grubbs
Fixes bug 395038. |
463 |
def cancel_url(self): |
464 |
return canonical_url(self.context) |
|
465 |
||
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
466 |
def processForm(self): |
467 |
# look for an update to any of the things we track
|
|
468 |
form = self.request.form |
|
11275.1.7
by Edwin Grubbs
Fixed lint errors. |
469 |
if 'packaging' in form: |
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
470 |
if self.productseries_widget.hasValidInput(): |
471 |
new_ps = self.productseries_widget.getInputValue() |
|
472 |
# we need to create or update the packaging
|
|
473 |
self.context.setPackaging(new_ps, self.user) |
|
474 |
self.productseries_widget.setRenderedValue(new_ps) |
|
8908.1.2
by Edwin Grubbs
Fixes bug 395038. |
475 |
self.request.response.addInfoNotification( |
476 |
'Upstream link updated, thank you!') |
|
477 |
self.request.response.redirect(canonical_url(self.context)) |
|
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
478 |
else: |
6845.2.1
by Tom Berger
Make LaunchpadView enfore structured() for error and info messages |
479 |
self.error_message = structured('Invalid series given.') |
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
480 |
|
2225
by Canonical.com Patch Queue Manager
SMASH bug page fixes into rocketfuel [r=stevea] |
481 |
def published_by_pocket(self): |
482 |
"""This morfs the results of ISourcePackage.published_by_pocket into
|
|
483 |
something easier to parse from a page template. It becomes a list of
|
|
484 |
dictionaries, sorted in dbschema item order, each representing a
|
|
485 |
pocket and the packages in it."""
|
|
486 |
result = [] |
|
487 |
thedict = self.context.published_by_pocket |
|
488 |
for pocket in PackagePublishingPocket.items: |
|
489 |
newdict = {'pocketdetails': pocket} |
|
490 |
newdict['packages'] = thedict[pocket] |
|
491 |
result.append(newdict) |
|
492 |
return result |
|
1547
by Canonical.com Patch Queue Manager
NUKE SOURCE PACKAGE... and launch the MagicSourcePackage |
493 |
|
494 |
def binaries(self): |
|
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
495 |
"""Format binary packages into binarypackagename and archtags"""
|
1547
by Canonical.com Patch Queue Manager
NUKE SOURCE PACKAGE... and launch the MagicSourcePackage |
496 |
results = {} |
3024.1.47
by Christian Reis
Merciful refactoring of browser.sourcepackage.binaries |
497 |
all_arch = sorted([arch.architecturetag for arch in |
4285.2.1
by Mark Shuttleworth
Massive renaming of distrorelease to distroseries |
498 |
self.context.distroseries.architectures]) |
4285.2.3
by Mark Shuttleworth
Test fixes for renamed DistroSeries |
499 |
for bin in self.context.currentrelease.binaries: |
7675.687.115
by Michael Nelson
xx-distroseries-sources.txt |
500 |
distroarchseries = bin.build.distro_arch_series |
3024.1.47
by Christian Reis
Merciful refactoring of browser.sourcepackage.binaries |
501 |
if bin.name not in results: |
502 |
results[bin.name] = [] |
|
1547
by Canonical.com Patch Queue Manager
NUKE SOURCE PACKAGE... and launch the MagicSourcePackage |
503 |
|
3024.1.47
by Christian Reis
Merciful refactoring of browser.sourcepackage.binaries |
504 |
if bin.architecturespecific: |
4285.2.1
by Mark Shuttleworth
Massive renaming of distrorelease to distroseries |
505 |
results[bin.name].append(distroarchseries.architecturetag) |
1547
by Canonical.com Patch Queue Manager
NUKE SOURCE PACKAGE... and launch the MagicSourcePackage |
506 |
else: |
3024.1.47
by Christian Reis
Merciful refactoring of browser.sourcepackage.binaries |
507 |
results[bin.name] = all_arch |
508 |
results[bin.name].sort() |
|
1547
by Canonical.com Patch Queue Manager
NUKE SOURCE PACKAGE... and launch the MagicSourcePackage |
509 |
|
510 |
return results |
|
511 |
||
3147.5.59
by Celso Providelo
Improve and test IPackageRelationship features. |
512 |
def _relationship_parser(self, content): |
513 |
"""Wrap the relationship_builder for SourcePackages.
|
|
514 |
||
515 |
Define apt_pkg.ParseSrcDep as a relationship 'parser' and
|
|
4285.2.1
by Mark Shuttleworth
Massive renaming of distrorelease to distroseries |
516 |
IDistroSeries.getBinaryPackage as 'getter'.
|
3147.5.59
by Celso Providelo
Improve and test IPackageRelationship features. |
517 |
"""
|
4285.2.1
by Mark Shuttleworth
Massive renaming of distrorelease to distroseries |
518 |
getter = self.context.distroseries.getBinaryPackage |
3147.5.59
by Celso Providelo
Improve and test IPackageRelationship features. |
519 |
parser = ParseSrcDepends |
520 |
return relationship_builder(content, parser=parser, getter=getter) |
|
521 |
||
5226.1.19
by Celso Providelo
UI changes to present the new SPR/BPR fields (package relationships). |
522 |
@property
|
1547
by Canonical.com Patch Queue Manager
NUKE SOURCE PACKAGE... and launch the MagicSourcePackage |
523 |
def builddepends(self): |
3147.5.59
by Celso Providelo
Improve and test IPackageRelationship features. |
524 |
return self._relationship_parser( |
4285.2.3
by Mark Shuttleworth
Test fixes for renamed DistroSeries |
525 |
self.context.currentrelease.builddepends) |
1547
by Canonical.com Patch Queue Manager
NUKE SOURCE PACKAGE... and launch the MagicSourcePackage |
526 |
|
5226.1.19
by Celso Providelo
UI changes to present the new SPR/BPR fields (package relationships). |
527 |
@property
|
1547
by Canonical.com Patch Queue Manager
NUKE SOURCE PACKAGE... and launch the MagicSourcePackage |
528 |
def builddependsindep(self): |
3147.5.59
by Celso Providelo
Improve and test IPackageRelationship features. |
529 |
return self._relationship_parser( |
4285.2.3
by Mark Shuttleworth
Test fixes for renamed DistroSeries |
530 |
self.context.currentrelease.builddependsindep) |
1547
by Canonical.com Patch Queue Manager
NUKE SOURCE PACKAGE... and launch the MagicSourcePackage |
531 |
|
5226.1.19
by Celso Providelo
UI changes to present the new SPR/BPR fields (package relationships). |
532 |
@property
|
533 |
def build_conflicts(self): |
|
534 |
return self._relationship_parser( |
|
535 |
self.context.currentrelease.build_conflicts) |
|
536 |
||
537 |
@property
|
|
538 |
def build_conflicts_indep(self): |
|
539 |
return self._relationship_parser( |
|
540 |
self.context.currentrelease.build_conflicts_indep) |
|
2705
by Canonical.com Patch Queue Manager
r=spiv, mark's soyuz loving. |
541 |
|
1561
by Canonical.com Patch Queue Manager
Rosetta Polish about portlets and URLs |
542 |
def requestCountry(self): |
1977
by Canonical.com Patch Queue Manager
[r=Bjorn] some clean up of helpers.py |
543 |
return ICountry(self.request, None) |
1561
by Canonical.com Patch Queue Manager
Rosetta Polish about portlets and URLs |
544 |
|
545 |
def browserLanguages(self): |
|
546 |
return helpers.browserLanguages(self.request) |
|
1558
by Canonical.com Patch Queue Manager
revamp rosetta url schema, traversals and template listings |
547 |
|
5703.1.11
by Celso Providelo
Presenting NEEDSBUILD build records by default in the PPA-builds page, it will save some clicks when visiting this page. |
548 |
@property
|
8690.7.3
by Danilo Šegan
Do not let Storm construct all POFile and/or POTemplate objects for every file it's exporting. |
549 |
def potemplates(self): |
550 |
return list(self.context.getCurrentTranslationTemplates()) |
|
9425.4.1
by Curtis Hovey
Updated source package +gethelp to UI 3.0. Moved the template to lp/answers. |
551 |
|
552 |
||
10212.1.6
by Brad Crittenden
Fixes from code review. |
553 |
class SourcePackageAssociationPortletView(LaunchpadFormView): |
10212.1.1
by Brad Crittenden
Checkpoint |
554 |
"""A view for linking to an upstream package."""
|
555 |
||
556 |
schema = Interface |
|
557 |
custom_widget( |
|
558 |
'upstream', LaunchpadRadioWidget, orientation='vertical') |
|
559 |
product_suggestions = None |
|
10850.6.2
by Curtis Hovey
Update the SP upstream project suggestions to look like the project package suggestions. |
560 |
initial_focus_widget = None |
561 |
max_suggestions = 9 |
|
562 |
other_upstream = object() |
|
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
563 |
register_upstream = object() |
10212.1.1
by Brad Crittenden
Checkpoint |
564 |
|
565 |
def setUpFields(self): |
|
566 |
"""See `LaunchpadFormView`."""
|
|
567 |
super(SourcePackageAssociationPortletView, self).setUpFields() |
|
10374.2.9
by Edwin Grubbs
Added the ability to hide the edit buttons on $sourcepackage/+upstream-connections. |
568 |
self.request.annotations['show_edit_buttons'] = True |
10212.1.1
by Brad Crittenden
Checkpoint |
569 |
# Find registered products that are similarly named to the source
|
570 |
# package.
|
|
571 |
product_vocab = getVocabularyRegistry().get(None, 'Product') |
|
572 |
matches = product_vocab.searchForTerms(self.context.name) |
|
10212.1.2
by Brad Crittenden
Add upstream associations portlet to display upstream info or give the user a chance to make the connection. |
573 |
# Based upon the matching products, create a new vocabulary with
|
574 |
# term descriptions that include a link to the product.
|
|
10212.1.1
by Brad Crittenden
Checkpoint |
575 |
self.product_suggestions = [] |
576 |
vocab_terms = [] |
|
10850.6.2
by Curtis Hovey
Update the SP upstream project suggestions to look like the project package suggestions. |
577 |
for item in matches[:self.max_suggestions]: |
10212.1.1
by Brad Crittenden
Checkpoint |
578 |
product = item.value |
579 |
self.product_suggestions.append(product) |
|
580 |
item_url = canonical_url(product) |
|
12293.2.17
by Curtis Hovey
Use structured when constructing markup in widgets. |
581 |
description = structured( |
582 |
'<a href="%s">%s</a>', item_url, product.displayname) |
|
10212.1.1
by Brad Crittenden
Checkpoint |
583 |
vocab_terms.append(SimpleTerm(product, product.name, description)) |
10850.6.2
by Curtis Hovey
Update the SP upstream project suggestions to look like the project package suggestions. |
584 |
# Add an option to represent the user's decision to choose a
|
585 |
# different project. Note that project names cannot be uppercase.
|
|
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
586 |
vocab_terms.append( |
587 |
SimpleTerm(self.other_upstream, 'OTHER_UPSTREAM', |
|
588 |
'Choose another upstream project')) |
|
589 |
vocab_terms.append( |
|
590 |
SimpleTerm(self.register_upstream, 'REGISTER_UPSTREAM', |
|
591 |
'Register the upstream project')) |
|
10212.1.1
by Brad Crittenden
Checkpoint |
592 |
upstream_vocabulary = SimpleVocabulary(vocab_terms) |
593 |
||
594 |
self.form_fields = Fields( |
|
595 |
Choice(__name__='upstream', |
|
10212.1.6
by Brad Crittenden
Fixes from code review. |
596 |
title=_('Registered upstream project'), |
11411.7.24
by j.c.sackett
Merged from devel. |
597 |
default=self.other_upstream, |
10212.1.1
by Brad Crittenden
Checkpoint |
598 |
vocabulary=upstream_vocabulary, |
599 |
required=True)) |
|
600 |
||
601 |
@action('Link to Upstream Project', name='link') |
|
602 |
def link(self, action, data): |
|
10212.1.2
by Brad Crittenden
Add upstream associations portlet to display upstream info or give the user a chance to make the connection. |
603 |
upstream = data.get('upstream') |
10850.6.2
by Curtis Hovey
Update the SP upstream project suggestions to look like the project package suggestions. |
604 |
if upstream is self.other_upstream: |
605 |
# The user wants to link to an alternate upstream project.
|
|
606 |
self.next_url = canonical_url( |
|
607 |
self.context, view_name="+edit-packaging") |
|
608 |
return
|
|
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
609 |
elif upstream is self.register_upstream: |
610 |
# The user wants to create a new project.
|
|
11275.1.14
by Edwin Grubbs
Autolink source package to newly created project. |
611 |
url = get_register_upstream_url(self.context) |
11275.1.5
by Edwin Grubbs
Working test. |
612 |
self.request.response.redirect(url) |
11275.1.1
by Edwin Grubbs
Added path to create projects from source packages. |
613 |
return
|
10212.1.2
by Brad Crittenden
Add upstream associations portlet to display upstream info or give the user a chance to make the connection. |
614 |
self.context.setPackaging(upstream.development_focus, self.user) |
10212.1.1
by Brad Crittenden
Checkpoint |
615 |
self.request.response.addInfoNotification( |
10212.1.2
by Brad Crittenden
Add upstream associations portlet to display upstream info or give the user a chance to make the connection. |
616 |
'The project %s was linked to this source package.' % |
617 |
upstream.displayname) |
|
618 |
self.next_url = self.request.getURL() |
|
10304.2.2
by Brad Crittenden
Update upstream connections portlet to show the configuration status for various properties. |
619 |
|
10374.2.9
by Edwin Grubbs
Added the ability to hide the edit buttons on $sourcepackage/+upstream-connections. |
620 |
|
11869.10.5
by Curtis Hovey
Added PackageUpstreamTracking to summarise the state between the package and upstream versions. |
621 |
class PackageUpstreamTracking(EnumeratedType): |
622 |
"""The state of the package's tracking of the upstream version."""
|
|
623 |
||
624 |
NONE = Item(""" |
|
625 |
None
|
|
626 |
||
627 |
There is not enough information to compare the current package version
|
|
628 |
to the upstream version.
|
|
629 |
""") |
|
630 |
||
631 |
CURRENT = Item(""" |
|
632 |
Current version
|
|
633 |
||
634 |
The package version is the current upstream version.
|
|
635 |
""") |
|
636 |
||
637 |
OLDER = Item(""" |
|
11869.10.8
by Curtis Hovey
Revise enum names and markup ids so that they are in agreement. |
638 |
Older upstream version
|
639 |
||
640 |
The upstream version is older than the package version. Launchpad
|
|
641 |
Launchpad is missing upstream data.
|
|
642 |
""") |
|
643 |
||
644 |
NEWER = Item(""" |
|
645 |
Newer upstream version
|
|
646 |
||
647 |
The upstream version is newer than the package version. The package
|
|
11869.10.5
by Curtis Hovey
Added PackageUpstreamTracking to summarise the state between the package and upstream versions. |
648 |
can be updated to the upstream version.
|
649 |
""") |
|
650 |
||
651 |
||
10374.2.9
by Edwin Grubbs
Added the ability to hide the edit buttons on $sourcepackage/+upstream-connections. |
652 |
class SourcePackageUpstreamConnectionsView(LaunchpadView): |
653 |
"""A shared view with upstream connection info."""
|
|
654 |
||
10304.2.2
by Brad Crittenden
Update upstream connections portlet to show the configuration status for various properties. |
655 |
@property
|
656 |
def has_bugtracker(self): |
|
657 |
"""Does the product have a bugtracker set?"""
|
|
10304.2.4
by Brad Crittenden
Changes from review. Added link to edit product series. Added test for the new view property 'has_bugtracker'. |
658 |
if self.context.productseries is None: |
659 |
return False |
|
10304.2.2
by Brad Crittenden
Update upstream connections portlet to show the configuration status for various properties. |
660 |
product = self.context.productseries.product |
11411.7.1
by j.c.sackett
Fixed majority of official_malone calls in code-space. Still need to fix templates. |
661 |
if product.bug_tracking_usage == ServiceUsage.LAUNCHPAD: |
10304.2.2
by Brad Crittenden
Update upstream connections portlet to show the configuration status for various properties. |
662 |
return True |
663 |
bugtracker = product.bugtracker |
|
664 |
if bugtracker is None: |
|
665 |
if product.project is not None: |
|
666 |
bugtracker = product.project.bugtracker |
|
667 |
if bugtracker is None: |
|
668 |
return False |
|
669 |
return True |
|
11869.10.3
by Curtis Hovey
Added a rudimentary current_release_tracking. It cannot say if the version is |
670 |
|
671 |
@property
|
|
672 |
def current_release_tracking(self): |
|
11869.10.5
by Curtis Hovey
Added PackageUpstreamTracking to summarise the state between the package and upstream versions. |
673 |
"""The PackageUpstreamTracking state for the current release."""
|
11869.10.3
by Curtis Hovey
Added a rudimentary current_release_tracking. It cannot say if the version is |
674 |
upstream_release = self.context.productseries.getLatestRelease() |
675 |
current_release = self.context.currentrelease |
|
676 |
if upstream_release is None or current_release is None: |
|
11869.10.4
by Curtis Hovey
Use apt_pkg.CompareVersion to compare upstream to the spr version. |
677 |
# Launchpad is missing data. There is not enough information to
|
678 |
# track releases.
|
|
11869.10.5
by Curtis Hovey
Added PackageUpstreamTracking to summarise the state between the package and upstream versions. |
679 |
return PackageUpstreamTracking.NONE |
11869.10.9
by Curtis Hovey
Extract the base version from the debian version to ensure a sane comparison to |
680 |
# Compare the base version contained in the full debian version
|
681 |
# to upstream release's version.
|
|
11869.10.10
by Curtis Hovey
Use a proven utility to extract the upstream_version. |
682 |
base_version = upstream_version(current_release.version) |
11869.10.9
by Curtis Hovey
Extract the base version from the debian version to ensure a sane comparison to |
683 |
age = VersionCompare(upstream_release.version, base_version) |
11869.10.5
by Curtis Hovey
Added PackageUpstreamTracking to summarise the state between the package and upstream versions. |
684 |
if age > 0: |
685 |
return PackageUpstreamTracking.NEWER |
|
686 |
elif age < 0: |
|
687 |
return PackageUpstreamTracking.OLDER |
|
11869.10.4
by Curtis Hovey
Use apt_pkg.CompareVersion to compare upstream to the spr version. |
688 |
else: |
11869.10.5
by Curtis Hovey
Added PackageUpstreamTracking to summarise the state between the package and upstream versions. |
689 |
# age == 0:
|
690 |
return PackageUpstreamTracking.CURRENT |