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.inlineCallbacks
35
38 addSlash = False
42
43 - def getPageTitle (self, req):
44 return "Buildbot User: %s" % self.uid
45
46 - def content(self, request, ctx):
47 status = self.getStatus(request)
48
49 d = status.master.db.users.getUser(self.uid)
50 def cb(usdict):
51 ctx['user_identifier'] = usdict['identifier']
52 user = ctx['user'] = {}
53 for attr in usdict:
54 if attr not in ['uid', 'identifier', 'bb_password']:
55 user[attr] = usdict[attr]
56
57 template = request.site.buildbot_service.templates.get_template("user.html")
58 data = template.render(**ctx)
59 return data
60 d.addCallback(cb)
61 return d
62
65 pageTitle = "Users"
66 addSlash = True
67
70
73
74 @defer.inlineCallbacks
75 - def content(self, req, ctx):
76 res = yield self.getAuthz(req).actionAllowed('showUsersPage', req)
77 if not res:
78 defer.returnValue(redirectTo(path_to_authzfail(req), req))
79 return
80
81 s = self.getStatus(req)
82
83 usdicts = yield s.master.db.users.getUsers()
84 users = ctx['users'] = usdicts
85
86 for user in users:
87 user['user_link'] = req.childLink(urllib.quote(str(user['uid']), ''))
88 template = req.site.buildbot_service.templates.get_template(
89 "users.html")
90 defer.returnValue(template.render(**ctx))
91