Package buildbot :: Package status :: Package web :: Module changes
[frames] | no frames]

Source Code for Module buildbot.status.web.changes

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16   
17  from zope.interface import implements 
18  from twisted.python import components 
19  from twisted.web.error import NoResource 
20   
21  from buildbot.changes.changes import Change 
22  from buildbot.status.web.base import HtmlResource, IBox, Box 
23   
24 -class ChangeResource(HtmlResource):
25 - def __init__(self, changeid):
26 self.changeid = changeid 27 self.pageTitle = "Change #%d" % changeid
28
29 - def content(self, req, cxt):
30 d = self.getStatus(req).getChange(self.changeid) 31 def cb(change): 32 if not change: 33 return "No change number %d" % self.changeid 34 templates = req.site.buildbot_service.templates 35 cxt['c'] = change.asDict() 36 template = templates.get_template("change.html") 37 data = template.render(cxt) 38 return data
39 d.addCallback(cb) 40 return d
41 42 # /changes/NN
43 -class ChangesResource(HtmlResource):
44
45 - def content(self, req, cxt):
46 cxt['sources'] = self.getStatus(req).getChangeSources() 47 template = req.site.buildbot_service.templates.get_template("change_sources.html") 48 return template.render(**cxt)
49
50 - def getChild(self, path, req):
51 try: 52 changeid = int(path) 53 except ValueError: 54 return NoResource("Expected a change number") 55 56 return ChangeResource(changeid)
57
58 -class ChangeBox(components.Adapter):
59 implements(IBox) 60
61 - def getBox(self, req):
62 url = req.childLink("../changes/%d" % self.original.number) 63 template = req.site.buildbot_service.templates.get_template("change_macros.html") 64 text = template.module.box_contents(url=url, 65 who=self.original.getShortAuthor(), 66 pageTitle=self.original.comments) 67 return Box([text], class_="Change")
68 components.registerAdapter(ChangeBox, Change, IBox) 69