diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py
--- a/rhodecode/lib/helpers.py
+++ b/rhodecode/lib/helpers.py
@@ -387,6 +387,10 @@ def get_changeset_safe(repo, rev):
return cs
+def is_following_repo(repo_name, user_id):
+ from rhodecode.model.scm import ScmModel
+ return ScmModel().is_following_repo(repo_name, user_id)
+
flash = _Flash()
diff --git a/rhodecode/model/scm.py b/rhodecode/model/scm.py
--- a/rhodecode/model/scm.py
+++ b/rhodecode/model/scm.py
@@ -319,7 +319,7 @@ class ScmModel(BaseModel):
self.sa.rollback()
raise
- def is_following_repo(self, repo_name, user_id):
+ def is_following_repo(self, repo_name, user_id, cache=False):
r = self.sa.query(Repository)\
.filter(Repository.repo_name == repo_name).scalar()
@@ -329,7 +329,7 @@ class ScmModel(BaseModel):
return f is not None
- def is_following_user(self, username, user_id):
+ def is_following_user(self, username, user_id, cache=False):
u = UserModel(self.sa).get_by_username(username)
f = self.sa.query(UserFollowing)\
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
@@ -348,9 +348,9 @@ var YUC = YAHOO.util.Connect;
var YUD = YAHOO.util.Dom;
var YUE = YAHOO.util.Event;
-function onSuccess(){
+function onSuccess(target){
- var f = YUD.get('follow_toggle');
+ var f = YUD.get(target.id);
if(f.getAttribute('class')=='follow'){
f.setAttribute('class','following');
f.setAttribute('title',"${_('Stop following this repository')}");
@@ -371,12 +371,13 @@ function toggleFollowingUser(fallows_use
},args); return false;
}
-function toggleFollowingRepo(fallows_repo_id,token){
+function toggleFollowingRepo(target,fallows_repo_id,token){
+
args = 'follows_repo_id='+fallows_repo_id;
args+= '&auth_token='+token;
YUC.asyncRequest('POST',base_url,{
success:function(o){
- onSuccess();
+ onSuccess(target);
}
},args); return false;
}
diff --git a/rhodecode/templates/summary/summary.html b/rhodecode/templates/summary/summary.html
--- a/rhodecode/templates/summary/summary.html
+++ b/rhodecode/templates/summary/summary.html
@@ -47,11 +47,11 @@
%if c.rhodecode_user.username != 'default':
%if c.following:
+ onclick="javascript:toggleFollowingRepo(this,${c.repo_info.dbrepo.repo_id},'${str(h.get_token())}')">
%else:
+ onclick="javascript:toggleFollowingRepo(this,${c.repo_info.dbrepo.repo_id},'${str(h.get_token())}')">
%endif
%endif: