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, change, num):
26 self.change = change 27 self.title = "Change #%d" % num
28
29 - def content(self, req, cxt):
30 cxt['c'] = self.change.asDict() 31 template = req.site.buildbot_service.templates.get_template("change.html") 32 data = template.render(cxt) 33 return data
34 35 # /changes/NN
36 -class ChangesResource(HtmlResource):
37
38 - def content(self, req, cxt):
39 cxt['sources'] = self.getStatus(req).getChangeSources() 40 template = req.site.buildbot_service.templates.get_template("change_sources.html") 41 return template.render(**cxt)
42 43
44 - def getChild(self, path, req):
45 try: 46 num = int(path) 47 c = self.getStatus(req).getChange(num) 48 except ValueError: 49 c = None 50 num = path 51 if not c: 52 return NoResource("No change number '%s'" % path) 53 return ChangeResource(c, num)
54
55 -class ChangeBox(components.Adapter):
56 implements(IBox) 57
58 - def getBox(self, req):
59 url = req.childLink("../changes/%d" % self.original.number) 60 template = req.site.buildbot_service.templates.get_template("change_macros.html") 61 text = template.module.box_contents(url=url, 62 who=self.original.getShortAuthor(), 63 title=self.original.comments) 64 return Box([text], class_="Change")
65 components.registerAdapter(ChangeBox, Change, IBox) 66