# HG changeset patch # User Marcin Kuzminski # Date 1280276747 -7200 # Node ID 3171614c006793f325f03fe52da9057b509478c1 # Parent 1fa58ca0a77e33fd88011c9d6fc89895500725e8 Added permissions check on repo switcher, and cached that for super short cache. repo switcher css updates diff -r 1fa58ca0a77e -r 3171614c0067 pylons_app/lib/base.py --- a/pylons_app/lib/base.py Wed Jul 28 01:52:12 2010 +0200 +++ b/pylons_app/lib/base.py Wed Jul 28 02:25:47 2010 +0200 @@ -5,11 +5,12 @@ from pylons import config, tmpl_context as c, request, session from pylons.controllers import WSGIController from pylons.templating import render_mako as render +from pylons_app import __version__ from pylons_app.lib import auth from pylons_app.lib.utils import get_repo_slug from pylons_app.model import meta -from pylons_app.model.hg_model import _get_repos_cached -from pylons_app import __version__ +from pylons_app.model.hg_model import _get_repos_cached, \ + _get_repos_switcher_cached class BaseController(WSGIController): @@ -18,6 +19,7 @@ c.hg_app_name = config['hg_app_name'] c.repo_name = get_repo_slug(request) c.cached_repo_list = _get_repos_cached() + c.repo_switcher_list = _get_repos_switcher_cached(c.cached_repo_list) self.sa = meta.Session def __call__(self, environ, start_response): diff -r 1fa58ca0a77e -r 3171614c0067 pylons_app/model/hg_model.py --- a/pylons_app/model/hg_model.py Wed Jul 28 01:52:12 2010 +0200 +++ b/pylons_app/model/hg_model.py Wed Jul 28 02:25:47 2010 +0200 @@ -2,7 +2,7 @@ # encoding: utf-8 # Model for hg app # Copyright (C) 2009-2010 Marcin Kuzminski - +# # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 2 @@ -25,10 +25,12 @@ from beaker.cache import cache_region from mercurial import ui from mercurial.hgweb.hgwebdir_mod import findrepos -from vcs.exceptions import RepositoryError, VCSError +from pylons.i18n.translation import _ +from pylons_app.lib.auth import HasRepoPermissionAny from pylons_app.model import meta from pylons_app.model.db import Repository from sqlalchemy.orm import joinedload +from vcs.exceptions import RepositoryError, VCSError import logging import os import sys @@ -56,6 +58,15 @@ from pylons import app_globals as g return HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui) +@cache_region('super_short_term', 'cached_repos_switcher_list') +def _get_repos_switcher_cached(cached_repo_list): + repos_lst = [] + for repo in sorted(x.name.lower() for x in cached_repo_list.values()): + if HasRepoPermissionAny('repository.write', 'repository.read', 'repository.admin')(repo, 'main page check'): + repos_lst.append(repo) + + return repos_lst + @cache_region('long_term', 'full_changelog') def _full_changelog_cached(repo_name): log.info('getting full changelog for %s', repo_name) diff -r 1fa58ca0a77e -r 3171614c0067 pylons_app/public/css/style.css --- a/pylons_app/public/css/style.css Wed Jul 28 01:52:12 2010 +0200 +++ b/pylons_app/public/css/style.css Wed Jul 28 02:25:47 2010 +0200 @@ -3197,6 +3197,15 @@ } /* ----------------------------------------------------------- + REPO SWITCHER +----------------------------------------------------------- */ + +#switch_repos{ + position: absolute; + height: 25px; + z-index: 1; +} +/* ----------------------------------------------------------- BREADCRUMBS ----------------------------------------------------------- */ diff -r 1fa58ca0a77e -r 3171614c0067 pylons_app/templates/base/base.html --- a/pylons_app/templates/base/base.html Wed Jul 28 01:52:12 2010 +0200 +++ b/pylons_app/templates/base/base.html Wed Jul 28 02:25:47 2010 +0200 @@ -91,15 +91,13 @@ } else{ YAHOO.util.Dom.setStyle('switch_repos','display',''); - //YAHOO.util.Dom.setStyle('repo_switcher','background','#FFFFFF'); - //YAHOO.util.Dom.setStyle('repo_switcher','color','#556CB5'); YAHOO.util.Dom.addClass('repo_switcher','selected'); } }); YAHOO.util.Event.addListener('repos_list','change',function(e){ var wa = YAHOO.util.Dom.get('repos_list').value; - var url = "${h.url('summary_home',repo_name='__REPLACE__')}".replace('__REPLACE__',wa); + var url = "${h.url('summary_home',repo_name='__REPO__')}".replace('__REPO__',wa); window.location = url; }) }); @@ -115,9 +113,9 @@ -