Merge lp:~stevenk/launchpad/show-5-pcj-errors into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 16529
Proposed branch: lp:~stevenk/launchpad/show-5-pcj-errors
Merge into: lp:launchpad
Diff against target: 73 lines (+27/-1)
3 files modified
lib/lp/soyuz/browser/archive.py (+8/-1)
lib/lp/soyuz/browser/tests/test_archive_packages.py (+17/-0)
lib/lp/soyuz/templates/archive-packages.pt (+2/-0)
To merge this branch: bzr merge lp:~stevenk/launchpad/show-5-pcj-errors
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+152609@code.launchpad.net

Commit message

Only show five PCJ notifications in Archive:+packages, also displaying a count if it's greater than 5.

Description of the change

Only show five PCJ notifications in Archive:+packages, also displaying a count if it's greater than 5.

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/archive.py'
2--- lib/lp/soyuz/browser/archive.py 2013-03-07 00:51:01 +0000
3+++ lib/lp/soyuz/browser/archive.py 2013-03-11 04:19:22 +0000
4@@ -1042,13 +1042,20 @@
5 # Pre-load related source archives.
6 load_related(Archive, pcjs, ['source_archive_id'])
7
8- return ppcjs
9+ return ppcjs.config(limit=5)
10
11 @cachedproperty
12 def has_pending_copy_jobs(self):
13 return self.package_copy_jobs.any()
14
15 @cachedproperty
16+ def pending_copy_jobs_text(self):
17+ job_source = getUtility(IPlainPackageCopyJobSource)
18+ count = job_source.getIncompleteJobsForArchive(self.context).count()
19+ if count > 5:
20+ return 'Showing 5 of %s' % count
21+
22+ @cachedproperty
23 def has_append_perm(self):
24 return check_permission('launchpad.Append', self.context)
25
26
27=== modified file 'lib/lp/soyuz/browser/tests/test_archive_packages.py'
28--- lib/lp/soyuz/browser/tests/test_archive_packages.py 2013-02-18 09:14:26 +0000
29+++ lib/lp/soyuz/browser/tests/test_archive_packages.py 2013-03-11 04:19:22 +0000
30@@ -11,6 +11,7 @@
31
32 import re
33
34+from BeautifulSoup import BeautifulSoup
35 import soupmatchers
36 from testtools.matchers import (
37 Equals,
38@@ -382,6 +383,22 @@
39 attrs={'class': 'pending-job', 'job_id': job3.id}),
40 )
41 self.assertThat(html, packages_matches)
42+ self.assertEquals(
43+ [], BeautifulSoup(html).findAll(
44+ 'span', text=re.compile('Showing 5 of .')))
45+
46+ def test_job_notifications_display_multiple_is_capped(self):
47+ jobs = [self.makeJob('package%d' % i) for i in range(7)]
48+ with person_logged_in(self.archive.owner):
49+ view = create_initialized_view(
50+ self.archive, "+packages", principal=self.archive.owner)
51+ soup = BeautifulSoup(view.render())
52+ self.assertEquals([],
53+ soup.findAll(
54+ 'div', attrs={'class': 'pending-job', 'job_id': jobs[-1].id}))
55+ self.assertEquals(
56+ [u'Showing 5 of 7'],
57+ soup.findAll('span', text=re.compile('Showing 5 of .')))
58
59 def test_job_notifications_display_owner_is_team(self):
60 team = self.factory.makeTeam()
61
62=== modified file 'lib/lp/soyuz/templates/archive-packages.pt'
63--- lib/lp/soyuz/templates/archive-packages.pt 2012-03-10 15:33:33 +0000
64+++ lib/lp/soyuz/templates/archive-packages.pt 2013-03-11 04:19:22 +0000
65@@ -132,6 +132,8 @@
66
67 <div tal:condition="view/has_pending_copy_jobs">
68 <div class="copy-job-message">
69+ <span tal:condition="view/pending_copy_jobs_text"
70+ tal:content="view/pending_copy_jobs_text"/>
71 <tal:jobs tal:repeat="job view/package_copy_jobs">
72 <div class="pending-job" tal:attributes="job_id job/id">
73 <a href="" class="job-summary js-action">