182
176
# Listify to avoid repeated queries.
183
177
return list(old_binary_packages)
185
def getPackagesetsFor(self, source_package_releases):
186
"""Find associated `Packagesets`.
188
:param source_package_releases: A sequence of `SourcePackageRelease`s.
190
sprs = [spr for spr in source_package_releases if spr is not None]
191
return getUtility(IPackagesetSet).getForPackages(
192
self.context, set(spr.sourcepackagenameID for spr in sprs))
194
179
def decoratedQueueBatch(self):
195
180
"""Return the current batch, converted to decorated objects.
214
196
upload.status != PackageUploadStatus.DONE)]
215
197
binary_file_set = getUtility(IBinaryPackageFileSet)
216
198
binary_files = binary_file_set.getByPackageUploadIDs(upload_ids)
217
packageuploadsources = load_referencing(
218
PackageUploadSource, uploads, ['packageuploadID'])
219
199
source_file_set = getUtility(ISourcePackageReleaseFileSet)
220
200
source_files = source_file_set.getByPackageUploadIDs(upload_ids)
222
source_sprs = load_related(
223
SourcePackageRelease, packageuploadsources,
224
['sourcepackagereleaseID'])
226
202
# Get a dictionary of lists of binary files keyed by upload ID.
227
203
package_upload_builds_dict = self.builds_dict(
228
204
upload_ids, binary_files)
511
478
return self.context.changesfile
514
def display_package_sets(self):
515
"""Package sets, if any, for display on the +queue page."""
516
if self.contains_source:
517
return ' '.join(sorted(
518
packageset.name for packageset in self.package_sets))
523
def display_component(self):
524
"""Component name, if any, for display on the +queue page."""
525
if self.contains_source:
526
return self.component_name.lower()
531
def display_section(self):
532
"""Section name, if any, for display on the +queue page."""
533
if self.contains_source:
534
return self.section_name.lower()
539
def display_priority(self):
540
"""Priority name, if any, for display on the +queue page."""
541
if self.contains_source:
542
return self.sourcepackagerelease.urgency.name.lower()
546
def composeIcon(self, alt, icon, title=None):
547
"""Compose an icon for the package's icon list."""
548
# These should really be sprites!
551
return '<img alt="[%s]" src="/@@/%s" title="%s" />' % (
552
cgi.escape(alt, quote=True),
554
cgi.escape(title, quote=True),
557
def composeIconList(self):
558
"""List icons that should be shown for this upload."""
559
ddtp = "Debian Description Translation Project Indexes"
561
(self.contains_source, ("Source", 'package-source')),
562
(self.contains_build, ("Build", 'package-binary', "Binary")),
563
(self.contains_translation, ("Translation", 'translation-file')),
564
(self.contains_installer, ("Installer", 'ubuntu-icon')),
565
(self.contains_upgrader, ("Upgrader", 'ubuntu-icon')),
566
(self.contains_ddtp, (ddtp, 'ubuntu-icon')),
569
self.composeIcon(*details)
570
for condition, details in potential_icons
573
def composeNameAndChangesLink(self):
574
"""Compose HTML: upload name and link to changes file."""
575
raw_displayname = self.displayname
576
displayname = cgi.escape(raw_displayname)
577
if self.pending_delayed_copy or self.changesfile is None:
580
return '<a href="%s" title="Changes file for %s">%s</a>' % (
581
self.changesfile.http_url,
582
cgi.escape(self.displayname, quote=True),
586
def icons_and_name(self):
587
"""Icon list and name, linked to changes file if appropriate."""
588
iconlist_id = "queue%d-iconlist" % self.id
589
icons = self.composeIconList()
590
link = self.composeNameAndChangesLink()
597
""" % (iconlist_id, '\n'.join(icons), link, self.displayarchs)
481
def package_sets(self):
482
assert self.sourcepackagerelease, \
483
"Can only be used on a source upload."
484
return ' '.join(sorted(ps.name for ps in
485
getUtility(IPackagesetSet).setsIncludingSource(
486
self.sourcepackagerelease.sourcepackagename,
487
distroseries=self.distroseries,
488
direct_inclusion=True)))