1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import urllib
17 from twisted.internet import defer
18 from twisted.web.util import redirectTo
19 from buildbot.status.web.base import HtmlResource, path_to_authzfail, \
20 path_to_root, ActionResource
23
25 self.action = "showUsersPage"
26
27 @defer.deferredGenerator
38
41 addSlash = False
45
46 - def getPageTitle (self, req):
47 return "Buildbot User: %s" % self.uid
48
49 - def content(self, request, ctx):
50 status = self.getStatus(request)
51
52 d = status.master.db.users.getUser(self.uid)
53 def cb(usdict):
54 ctx['user_identifier'] = usdict['identifier']
55 user = ctx['user'] = {}
56 for attr in usdict:
57 if attr not in ['uid', 'identifier', 'bb_password']:
58 user[attr] = usdict[attr]
59
60 template = request.site.buildbot_service.templates.get_template("user.html")
61 data = template.render(**ctx)
62 return data
63 d.addCallback(cb)
64 return d
65
68 pageTitle = "Users"
69 addSlash = True
70
73
76
77 @defer.deferredGenerator
78 - def content(self, req, ctx):
79 d = self.getAuthz(req).actionAllowed('showUsersPage', req)
80 wfd = defer.waitForDeferred(d)
81 yield wfd
82 res = wfd.getResult()
83 if not res:
84 yield redirectTo(path_to_authzfail(req), req)
85 return
86
87 s = self.getStatus(req)
88
89 d = s.master.db.users.getUsers()
90 wfd = defer.waitForDeferred(d)
91 yield wfd
92 usdicts = wfd.getResult()
93
94 users = ctx['users'] = usdicts
95 for user in users:
96 user['user_link'] = req.childLink(urllib.quote(str(user['uid']), ''))
97 template = req.site.buildbot_service.templates.get_template(
98 "users.html")
99 yield template.render(**ctx)
100