Merge lp:~thumper/launchpad/fix-recipe-build-title into lp:launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 12205
Proposed branch: lp:~thumper/launchpad/fix-recipe-build-title
Merge into: lp:launchpad
Prerequisite: lp:~thumper/launchpad/fix-recipe-build-oops
Diff against target: 107 lines (+23/-23)
5 files modified
lib/lp/app/browser/configure.zcml (+0/-6)
lib/lp/app/browser/tales.py (+0/-16)
lib/lp/code/browser/configure.zcml (+6/-0)
lib/lp/code/browser/sourcepackagerecipebuild.py (+12/-0)
lib/lp/code/model/sourcepackagerecipebuild.py (+5/-1)
To merge this branch: bzr merge lp:~thumper/launchpad/fix-recipe-build-title
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Steve Kowalik (community) code* Approve
Review via email: mp+45474@code.launchpad.net

Commit message

[r=mwhudson,stevenk][ui=none][bug=697255] Fix the source package recipe build title for deleted recipes.

Description of the change

The title of a source package recipe build referred to the recipe.

It is possible that the recipe has been deleted.

I noticed the commonality with the tales adapter recently changed
(the dependent branch), so I moved that logic from the tales adapter
into the object itself.

I also took the opportunity to move the tales adapter itself into
the lp.code tree from lp.app.browser.tales.

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) wrote :

This looks fine, too.

review: Approve (code*)
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

This seems like a nice simplification.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/browser/configure.zcml'
2--- lib/lp/app/browser/configure.zcml 2010-11-24 03:35:12 +0000
3+++ lib/lp/app/browser/configure.zcml 2011-01-14 10:12:38 +0000
4@@ -457,12 +457,6 @@
5 name="fmt"
6 />
7 <adapter
8- for="lp.code.interfaces.sourcepackagerecipebuild.ISourcePackageRecipeBuild"
9- provides="zope.traversing.interfaces.IPathAdapter"
10- factory="lp.app.browser.tales.SourcePackageRecipeBuildFormatterAPI"
11- name="fmt"
12- />
13- <adapter
14 for="lp.blueprints.interfaces.specification.ISpecification"
15 provides="zope.traversing.interfaces.IPathAdapter"
16 factory="lp.app.browser.tales.SpecificationFormatterAPI"
17
18=== modified file 'lib/lp/app/browser/tales.py'
19--- lib/lp/app/browser/tales.py 2011-01-14 10:12:36 +0000
20+++ lib/lp/app/browser/tales.py 2011-01-14 10:12:38 +0000
21@@ -1648,22 +1648,6 @@
22 'owner': self._context.owner.displayname}
23
24
25-class SourcePackageRecipeBuildFormatterAPI(CustomizableFormatter):
26- """Adapter providing fmt support for ISourcePackageRecipe objects."""
27-
28- _link_summary_template = '%(name)s [%(owner)s/%(archive)s]'
29-
30- def _link_summary_values(self):
31- if self._context.recipe is None:
32- name = 'build for deleted recipe'
33- else:
34- branch_name = self._context.recipe.base_branch.unique_name
35- name = '%s recipe build' % branch_name
36- return {'name': name,
37- 'owner': self._context.archive.owner.name,
38- 'archive': self._context.archive.name}
39-
40-
41 class SpecificationFormatterAPI(CustomizableFormatter):
42 """Adapter providing fmt support for Specification objects"""
43
44
45=== modified file 'lib/lp/code/browser/configure.zcml'
46--- lib/lp/code/browser/configure.zcml 2011-01-14 10:12:36 +0000
47+++ lib/lp/code/browser/configure.zcml 2011-01-14 10:12:38 +0000
48@@ -1198,6 +1198,12 @@
49 attribute_to_parent="archive"
50 path_expression="string:+buildjob/${url_id}"
51 />
52+ <adapter
53+ for="lp.code.interfaces.sourcepackagerecipebuild.ISourcePackageRecipeBuild"
54+ provides="zope.traversing.interfaces.IPathAdapter"
55+ factory="lp.code.browser.sourcepackagerecipebuild.SourcePackageRecipeBuildFormatterAPI"
56+ name="fmt"
57+ />
58 <browser:menus
59 classes="SourcePackageRecipeBuildContextMenu"
60 module="lp.code.browser.sourcepackagerecipebuild"/>
61
62=== modified file 'lib/lp/code/browser/sourcepackagerecipebuild.py'
63--- lib/lp/code/browser/sourcepackagerecipebuild.py 2011-01-14 10:12:36 +0000
64+++ lib/lp/code/browser/sourcepackagerecipebuild.py 2011-01-14 10:12:38 +0000
65@@ -29,6 +29,7 @@
66 action,
67 LaunchpadFormView,
68 )
69+from lp.app.browser.tales import CustomizableFormatter
70 from lp.buildmaster.enums import BuildStatus
71 from lp.code.interfaces.sourcepackagerecipebuild import (
72 ISourcePackageRecipeBuild,
73@@ -44,6 +45,17 @@
74 BuildStatus.FAILEDTOUPLOAD,)
75
76
77+class SourcePackageRecipeBuildFormatterAPI(CustomizableFormatter):
78+ """Adapter providing fmt support for ISourcePackageRecipeBuild objects."""
79+
80+ _link_summary_template = '%(title)s [%(owner)s/%(archive)s]'
81+
82+ def _link_summary_values(self):
83+ return {'title': self._context.title,
84+ 'owner': self._context.archive.owner.name,
85+ 'archive': self._context.archive.name}
86+
87+
88 class SourcePackageRecipeBuildNavigation(Navigation, FileNavigationMixin):
89
90 usedfor = ISourcePackageRecipeBuild
91
92=== modified file 'lib/lp/code/model/sourcepackagerecipebuild.py'
93--- lib/lp/code/model/sourcepackagerecipebuild.py 2011-01-10 03:22:42 +0000
94+++ lib/lp/code/model/sourcepackagerecipebuild.py 2011-01-14 10:12:38 +0000
95@@ -153,7 +153,11 @@
96
97 @property
98 def title(self):
99- return '%s recipe build' % self.recipe.base_branch.unique_name
100+ if self.recipe is None:
101+ return 'build for deleted recipe'
102+ else:
103+ branch_name = self.recipe.base_branch.unique_name
104+ return '%s recipe build' % branch_name
105
106 def __init__(self, package_build, distroseries, recipe, requester):
107 """Construct a SourcePackageRecipeBuild."""