Mercurial > bitten > bitten-test
diff 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 |
line wrap: on
line diff
--- a/bitten/web_ui.py +++ b/bitten/web_ui.py @@ -178,13 +178,12 @@ show_all = True data['show_all'] = show_all + repos = self.env.get_repository(req.authname) + if hasattr(repos, 'sync'): + repos.sync() + configs = [] for config in BuildConfig.select(self.env, include_inactive=show_all): - - repos = self.env.get_repository(req.authname) - if hasattr(repos, 'sync'): - repos.sync() - if not repos.authz.has_permission(config.path): continue @@ -260,8 +259,15 @@ db = self.env.get_db_cnx() + repos = self.env.get_repository(req.authname) + if hasattr(repos, 'sync'): + repos.sync() + configs = [] for config in BuildConfig.select(self.env, include_inactive=False): + if not repos.authz.has_permission(config.path): + continue + self.log.debug(config.name) if not config.active: continue @@ -317,6 +323,12 @@ db = self.env.get_db_cnx() config = BuildConfig.fetch(self.env, config_name, db=db) + + repos = self.env.get_repository(req.authname) + if hasattr(repos, 'sync'): + repos.sync() + repos.authz.assert_permission(config.path) + data = {'title': 'Build Configuration "%s"' \ % config.label or config.name, 'page_mode': 'view_config'} @@ -493,6 +505,7 @@ data['build']['can_delete'] = ('BUILD_DELETE' in req.perm) repos = self.env.get_repository(req.authname) + repos.authz.assert_permission(config.path) chgset = repos.get_changeset(build.rev) data['build']['chgset_author'] = chgset.author @@ -527,10 +540,18 @@ "AND b.status IN (%s, %s) ORDER BY b.stopped", (start, stop, Build.SUCCESS, Build.FAILURE)) + repos = self.env.get_repository(req.authname) + if hasattr(repos, 'sync'): + repos.sync() + event_kinds = {Build.SUCCESS: 'successbuild', Build.FAILURE: 'failedbuild'} for id, config, label, rev, platform, stopped, status in cursor: + config_object = BuildConfig.fetch(self.env, config, db=db) + if not repos.authz.has_permission(config_object.path): + continue + errors = [] if status == Build.FAILURE: for step in BuildStep.select(self.env, build=id,