Skip to content

Commit

Permalink
drop version in config.py and added to template
Browse files Browse the repository at this point in the history
  • Loading branch information
chase committed Mar 10, 2015
1 parent 5471f8b commit 24e42da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions master/buildbot/test/unit/test_www_config.py
Expand Up @@ -40,7 +40,7 @@ def test_render(self):
rsrc.jinja.get_template = lambda x: template
template.render = lambda configjson, config: configjson

vjson = json.dumps([] + rsrc.env_versions + custom_versions)
vjson = json.dumps(rsrc.getEnvironmentVersions() + custom_versions)

res = yield self.render_resource(rsrc, '/')
_auth.maybeAutoLogin.assert_called_with(mock.ANY)
Expand All @@ -54,9 +54,9 @@ def test_render(self):
exp = exp % vjson
self.assertIn(res, exp)

master = self.make_master(url='h:/a/c/', auth=_auth)
master = self.make_master(url='h:/a/c/', auth=_auth, versions=custom_versions)
rsrc.reconfigResource(master.config)
res = yield self.render_resource(rsrc, '/')
exp = '{"titleURL": "http://buildbot.net", "title": "Buildbot", "versions": %s, "auth": {"name": "NoAuth"}, "user": {"anonymous": true}, "buildbotURL": "h:/a/b/", "multiMaster": false, "port": null}'
exp = '{"titleURL": "http://buildbot.net", "versions": %s, "title": "Buildbot", "auth": {"name": "NoAuth"}, "user": {"anonymous": true}, "buildbotURL": "h:/a/b/", "multiMaster": false, "port": null}'
exp = exp % vjson
self.assertIn(res, exp)
22 changes: 10 additions & 12 deletions master/buildbot/www/config.py
Expand Up @@ -30,11 +30,17 @@ def __init__(self, master, staticdir):
resource.Resource.__init__(self, master)
loader = jinja2.FileSystemLoader(staticdir)
self.jinja = jinja2.Environment(loader=loader, undefined=jinja2.StrictUndefined)
self.env_versions = self.getEnvironmentVersions()

def reconfigResource(self, new_config):
self.config = new_config.www

versions = self.getEnvironmentVersions()

if isinstance(self.config.get('versions'), list):
versions += self.config['versions']

self.config['versions'] = versions

def render_GET(self, request):
return self.asyncRenderHelper(request, self.renderIndex)

Expand All @@ -51,9 +57,9 @@ def getEnvironmentVersions(self):
txversion = '.'.join(map(str, tx_version_info))

return [
('Python version', pyversion),
('Buildbot version', bbversion),
('Twisted version', txversion),
('Python', pyversion),
('Buildbot', bbversion),
('Twisted', txversion),
]

@defer.inlineCallbacks
Expand All @@ -73,19 +79,11 @@ def renderIndex(self, request):
else:
config.update({"user": {"anonymous": True}})

www = self.master.config.www
versions = []
versions += self.env_versions

if isinstance(www.get('versions'), list):
versions += www['versions']

config.update(self.config)
config['buildbotURL'] = self.master.config.buildbotURL
config['title'] = self.master.config.title
config['titleURL'] = self.master.config.titleURL
config['multiMaster'] = self.master.config.multiMaster
config['versions'] = versions

def toJson(obj):
obj = IConfigured(obj).getConfigDict()
Expand Down
2 changes: 1 addition & 1 deletion www/base/src/app/about/about.tpl.jade
Expand Up @@ -7,7 +7,7 @@
ul
li Project Infos:
a(ng-href="{{config.titleURL}}") {{config.title}}
li(ng-repeat="v in config.versions" ng-bind-template="{{v[0]}}: {{v[1]}}")
li(ng-repeat="v in config.versions" ng-bind-template="{{v[0]}} version: {{v[1]}}")
.row
small

Expand Down

0 comments on commit 24e42da

Please sign in to comment.