diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -22,14 +22,19 @@ class BaseController(WSGIController): c.backends = BACKENDS.keys() if c.repo_name: - cached_repo = ScmModel().get(c.repo_name) + scm_model = ScmModel() + cached_repo = scm_model.get(c.repo_name) if cached_repo: c.repository_tags = cached_repo.tags c.repository_branches = cached_repo.branches + c.repository_followers = scm_model.get_followers(cached_repo.dbrepo.repo_id) + c.repository_forks = scm_model.get_forks(cached_repo.dbrepo.repo_id) else: c.repository_tags = {} c.repository_branches = {} + c.repository_followers = 0 + c.repository_forks = 0 self.sa = meta.Session() diff --git a/rhodecode/model/scm.py b/rhodecode/model/scm.py --- a/rhodecode/model/scm.py +++ b/rhodecode/model/scm.py @@ -52,8 +52,8 @@ class UserTemp(object): class RepoTemp(object): def __init__(self, repo_id): self.repo_id = repo_id - - + + class ScmModel(object): """ Mercurial Model @@ -236,13 +236,13 @@ class ScmModel(object): .filter(UserFollowing.user_id == user_id).scalar() if f is not None: - + try: self.sa.delete(f) self.sa.commit() action_logger(UserTemp(user_id), 'stopped_following_repo', - RepoTemp(follow_repo_id)) + RepoTemp(follow_repo_id)) return except: log.error(traceback.format_exc()) @@ -258,7 +258,7 @@ class ScmModel(object): self.sa.commit() action_logger(UserTemp(user_id), 'started_following_repo', - RepoTemp(follow_repo_id)) + RepoTemp(follow_repo_id)) except: log.error(traceback.format_exc()) self.sa.rollback() @@ -310,6 +310,13 @@ class ScmModel(object): return f is not None + def get_followers(self, repo_id): + return self.sa.query(UserFollowing)\ + .filter(UserFollowing.follows_repo_id == repo_id).count() + + def get_forks(self, repo_id): + return self.sa.query(Repository)\ + .filter(Repository.fork_id == repo_id).count() def _should_invalidate(self, repo_name): """ diff --git a/rhodecode/public/css/style.css b/rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css +++ b/rhodecode/public/css/style.css @@ -302,6 +302,10 @@ background:#369 url("../../images/quick_ padding:0; } +#header #header-inner #quick li span.short { +padding:9px 6px 8px 6px; +} + #header #header-inner #quick li span { top:0; right:0; @@ -328,6 +332,15 @@ border-right:1px solid #2e5c89; padding:8px 8px 4px; } +#header #header-inner #quick li span.icon_short { +top:0; +left:0; +border-left:none; +background:url("../../images/quick_l.png") no-repeat top left; +border-right:1px solid #2e5c89; +padding:9px 4px 4px; +} + #header #header-inner #quick li a:hover { background:#4e4e4e url("../../images/quick_l_selected.png") no-repeat top left; } @@ -337,12 +350,13 @@ border-left:1px solid #545454; background:url("../../images/quick_r_selected.png") no-repeat top right; } -#header #header-inner #quick li a:hover span.icon { +#header #header-inner #quick li a:hover span.icon,#header #header-inner #quick li a:hover span.icon_short { border-left:none; border-right:1px solid #464646; background:url("../../images/quick_l_selected.png") no-repeat top left; } + #header #header-inner #quick ul { top:29px; right:0; diff --git a/rhodecode/templates/base/base.html b/rhodecode/templates/base/base.html --- a/rhodecode/templates/base/base.html +++ b/rhodecode/templates/base/base.html @@ -212,19 +212,30 @@