Mercurial > bitten > bitten-test
comparison bitten/web_ui.py @ 562:a8c84285e67a
Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
Moved repos lookup outside of config loop for optimisation
author | dfraser |
---|---|
date | Mon, 11 May 2009 12:11:38 +0000 |
parents | 8ffe90404a8c |
children | bed75f6c3e57 |
comparison
equal
deleted
inserted
replaced
561:8ffe90404a8c | 562:a8c84285e67a |
---|---|
176 show_all = False | 176 show_all = False |
177 if req.args.get('show') == 'all': | 177 if req.args.get('show') == 'all': |
178 show_all = True | 178 show_all = True |
179 data['show_all'] = show_all | 179 data['show_all'] = show_all |
180 | 180 |
181 repos = self.env.get_repository(req.authname) | |
182 if hasattr(repos, 'sync'): | |
183 repos.sync() | |
184 | |
181 configs = [] | 185 configs = [] |
182 for config in BuildConfig.select(self.env, include_inactive=show_all): | 186 for config in BuildConfig.select(self.env, include_inactive=show_all): |
183 | |
184 repos = self.env.get_repository(req.authname) | |
185 if hasattr(repos, 'sync'): | |
186 repos.sync() | |
187 | |
188 if not repos.authz.has_permission(config.path): | 187 if not repos.authz.has_permission(config.path): |
189 continue | 188 continue |
190 | 189 |
191 description = config.description | 190 description = config.description |
192 if description: | 191 if description: |
258 data = {'title': 'In Progress Builds', | 257 data = {'title': 'In Progress Builds', |
259 'page_mode': 'view-inprogress'} | 258 'page_mode': 'view-inprogress'} |
260 | 259 |
261 db = self.env.get_db_cnx() | 260 db = self.env.get_db_cnx() |
262 | 261 |
262 repos = self.env.get_repository(req.authname) | |
263 if hasattr(repos, 'sync'): | |
264 repos.sync() | |
265 | |
263 configs = [] | 266 configs = [] |
264 for config in BuildConfig.select(self.env, include_inactive=False): | 267 for config in BuildConfig.select(self.env, include_inactive=False): |
268 if not repos.authz.has_permission(config.path): | |
269 continue | |
270 | |
265 self.log.debug(config.name) | 271 self.log.debug(config.name) |
266 if not config.active: | 272 if not config.active: |
267 continue | 273 continue |
268 | 274 |
269 in_progress_builds = Build.select(self.env, config=config.name, | 275 in_progress_builds = Build.select(self.env, config=config.name, |
315 | 321 |
316 def _render_config(self, req, config_name): | 322 def _render_config(self, req, config_name): |
317 db = self.env.get_db_cnx() | 323 db = self.env.get_db_cnx() |
318 | 324 |
319 config = BuildConfig.fetch(self.env, config_name, db=db) | 325 config = BuildConfig.fetch(self.env, config_name, db=db) |
326 | |
327 repos = self.env.get_repository(req.authname) | |
328 if hasattr(repos, 'sync'): | |
329 repos.sync() | |
330 repos.authz.assert_permission(config.path) | |
331 | |
320 data = {'title': 'Build Configuration "%s"' \ | 332 data = {'title': 'Build Configuration "%s"' \ |
321 % config.label or config.name, | 333 % config.label or config.name, |
322 'page_mode': 'view_config'} | 334 'page_mode': 'view_config'} |
323 add_link(req, 'up', req.href.build(), 'Build Status') | 335 add_link(req, 'up', req.href.build(), 'Build Status') |
324 description = config.description | 336 description = config.description |
491 }) | 503 }) |
492 data['build']['steps'] = steps | 504 data['build']['steps'] = steps |
493 data['build']['can_delete'] = ('BUILD_DELETE' in req.perm) | 505 data['build']['can_delete'] = ('BUILD_DELETE' in req.perm) |
494 | 506 |
495 repos = self.env.get_repository(req.authname) | 507 repos = self.env.get_repository(req.authname) |
508 repos.authz.assert_permission(config.path) | |
496 chgset = repos.get_changeset(build.rev) | 509 chgset = repos.get_changeset(build.rev) |
497 data['build']['chgset_author'] = chgset.author | 510 data['build']['chgset_author'] = chgset.author |
498 | 511 |
499 add_script(req, 'bitten/tabset.js') | 512 add_script(req, 'bitten/tabset.js') |
500 add_stylesheet(req, 'bitten/bitten.css') | 513 add_stylesheet(req, 'bitten/bitten.css') |
525 " INNER JOIN bitten_platform AS p ON (p.id=b.platform) " | 538 " INNER JOIN bitten_platform AS p ON (p.id=b.platform) " |
526 "WHERE b.stopped>=%s AND b.stopped<=%s " | 539 "WHERE b.stopped>=%s AND b.stopped<=%s " |
527 "AND b.status IN (%s, %s) ORDER BY b.stopped", | 540 "AND b.status IN (%s, %s) ORDER BY b.stopped", |
528 (start, stop, Build.SUCCESS, Build.FAILURE)) | 541 (start, stop, Build.SUCCESS, Build.FAILURE)) |
529 | 542 |
543 repos = self.env.get_repository(req.authname) | |
544 if hasattr(repos, 'sync'): | |
545 repos.sync() | |
546 | |
530 event_kinds = {Build.SUCCESS: 'successbuild', | 547 event_kinds = {Build.SUCCESS: 'successbuild', |
531 Build.FAILURE: 'failedbuild'} | 548 Build.FAILURE: 'failedbuild'} |
532 for id, config, label, rev, platform, stopped, status in cursor: | 549 for id, config, label, rev, platform, stopped, status in cursor: |
533 | 550 |
551 config_object = BuildConfig.fetch(self.env, config, db=db) | |
552 if not repos.authz.has_permission(config_object.path): | |
553 continue | |
554 | |
534 errors = [] | 555 errors = [] |
535 if status == Build.FAILURE: | 556 if status == Build.FAILURE: |
536 for step in BuildStep.select(self.env, build=id, | 557 for step in BuildStep.select(self.env, build=id, |
537 status=BuildStep.FAILURE, | 558 status=BuildStep.FAILURE, |
538 db=db): | 559 db=db): |