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
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2013-03-07 00:51:01 +0000
+++ lib/lp/soyuz/browser/archive.py 2013-03-11 04:19:22 +0000
@@ -1042,13 +1042,20 @@
1042 # Pre-load related source archives.1042 # Pre-load related source archives.
1043 load_related(Archive, pcjs, ['source_archive_id'])1043 load_related(Archive, pcjs, ['source_archive_id'])
10441044
1045 return ppcjs1045 return ppcjs.config(limit=5)
10461046
1047 @cachedproperty1047 @cachedproperty
1048 def has_pending_copy_jobs(self):1048 def has_pending_copy_jobs(self):
1049 return self.package_copy_jobs.any()1049 return self.package_copy_jobs.any()
10501050
1051 @cachedproperty1051 @cachedproperty
1052 def pending_copy_jobs_text(self):
1053 job_source = getUtility(IPlainPackageCopyJobSource)
1054 count = job_source.getIncompleteJobsForArchive(self.context).count()
1055 if count > 5:
1056 return 'Showing 5 of %s' % count
1057
1058 @cachedproperty
1052 def has_append_perm(self):1059 def has_append_perm(self):
1053 return check_permission('launchpad.Append', self.context)1060 return check_permission('launchpad.Append', self.context)
10541061
10551062
=== modified file 'lib/lp/soyuz/browser/tests/test_archive_packages.py'
--- lib/lp/soyuz/browser/tests/test_archive_packages.py 2013-02-18 09:14:26 +0000
+++ lib/lp/soyuz/browser/tests/test_archive_packages.py 2013-03-11 04:19:22 +0000
@@ -11,6 +11,7 @@
1111
12import re12import re
1313
14from BeautifulSoup import BeautifulSoup
14import soupmatchers15import soupmatchers
15from testtools.matchers import (16from testtools.matchers import (
16 Equals,17 Equals,
@@ -382,6 +383,22 @@
382 attrs={'class': 'pending-job', 'job_id': job3.id}),383 attrs={'class': 'pending-job', 'job_id': job3.id}),
383 )384 )
384 self.assertThat(html, packages_matches)385 self.assertThat(html, packages_matches)
386 self.assertEquals(
387 [], BeautifulSoup(html).findAll(
388 'span', text=re.compile('Showing 5 of .')))
389
390 def test_job_notifications_display_multiple_is_capped(self):
391 jobs = [self.makeJob('package%d' % i) for i in range(7)]
392 with person_logged_in(self.archive.owner):
393 view = create_initialized_view(
394 self.archive, "+packages", principal=self.archive.owner)
395 soup = BeautifulSoup(view.render())
396 self.assertEquals([],
397 soup.findAll(
398 'div', attrs={'class': 'pending-job', 'job_id': jobs[-1].id}))
399 self.assertEquals(
400 [u'Showing 5 of 7'],
401 soup.findAll('span', text=re.compile('Showing 5 of .')))
385402
386 def test_job_notifications_display_owner_is_team(self):403 def test_job_notifications_display_owner_is_team(self):
387 team = self.factory.makeTeam()404 team = self.factory.makeTeam()
388405
=== modified file 'lib/lp/soyuz/templates/archive-packages.pt'
--- lib/lp/soyuz/templates/archive-packages.pt 2012-03-10 15:33:33 +0000
+++ lib/lp/soyuz/templates/archive-packages.pt 2013-03-11 04:19:22 +0000
@@ -132,6 +132,8 @@
132132
133 <div tal:condition="view/has_pending_copy_jobs">133 <div tal:condition="view/has_pending_copy_jobs">
134 <div class="copy-job-message">134 <div class="copy-job-message">
135 <span tal:condition="view/pending_copy_jobs_text"
136 tal:content="view/pending_copy_jobs_text"/>
135 <tal:jobs tal:repeat="job view/package_copy_jobs">137 <tal:jobs tal:repeat="job view/package_copy_jobs">
136 <div class="pending-job" tal:attributes="job_id job/id">138 <div class="pending-job" tal:attributes="job_id job/id">
137 <a href="" class="job-summary js-action">139 <a href="" class="job-summary js-action">