Show More
@@ -387,6 +387,10 b' def get_changeset_safe(repo, rev):' | |||||
387 | return cs |
|
387 | return cs | |
388 |
|
388 | |||
389 |
|
389 | |||
|
390 | def is_following_repo(repo_name, user_id): | |||
|
391 | from rhodecode.model.scm import ScmModel | |||
|
392 | return ScmModel().is_following_repo(repo_name, user_id) | |||
|
393 | ||||
390 | flash = _Flash() |
|
394 | flash = _Flash() | |
391 |
|
395 | |||
392 |
|
396 |
@@ -319,7 +319,7 b' class ScmModel(BaseModel):' | |||||
319 | self.sa.rollback() |
|
319 | self.sa.rollback() | |
320 | raise |
|
320 | raise | |
321 |
|
321 | |||
322 | def is_following_repo(self, repo_name, user_id): |
|
322 | def is_following_repo(self, repo_name, user_id, cache=False): | |
323 | r = self.sa.query(Repository)\ |
|
323 | r = self.sa.query(Repository)\ | |
324 | .filter(Repository.repo_name == repo_name).scalar() |
|
324 | .filter(Repository.repo_name == repo_name).scalar() | |
325 |
|
325 | |||
@@ -329,7 +329,7 b' class ScmModel(BaseModel):' | |||||
329 |
|
329 | |||
330 | return f is not None |
|
330 | return f is not None | |
331 |
|
331 | |||
332 | def is_following_user(self, username, user_id): |
|
332 | def is_following_user(self, username, user_id, cache=False): | |
333 | u = UserModel(self.sa).get_by_username(username) |
|
333 | u = UserModel(self.sa).get_by_username(username) | |
334 |
|
334 | |||
335 | f = self.sa.query(UserFollowing)\ |
|
335 | f = self.sa.query(UserFollowing)\ |
@@ -348,9 +348,9 b' var YUC = YAHOO.util.Connect;' | |||||
348 | var YUD = YAHOO.util.Dom; |
|
348 | var YUD = YAHOO.util.Dom; | |
349 | var YUE = YAHOO.util.Event; |
|
349 | var YUE = YAHOO.util.Event; | |
350 |
|
350 | |||
351 | function onSuccess(){ |
|
351 | function onSuccess(target){ | |
352 |
|
352 | |||
353 |
var f = YUD.get( |
|
353 | var f = YUD.get(target.id); | |
354 | if(f.getAttribute('class')=='follow'){ |
|
354 | if(f.getAttribute('class')=='follow'){ | |
355 | f.setAttribute('class','following'); |
|
355 | f.setAttribute('class','following'); | |
356 | f.setAttribute('title',"${_('Stop following this repository')}"); |
|
356 | f.setAttribute('title',"${_('Stop following this repository')}"); | |
@@ -371,12 +371,13 b' function toggleFollowingUser(fallows_use' | |||||
371 | },args); return false; |
|
371 | },args); return false; | |
372 | } |
|
372 | } | |
373 |
|
373 | |||
374 | function toggleFollowingRepo(fallows_repo_id,token){ |
|
374 | function toggleFollowingRepo(target,fallows_repo_id,token){ | |
|
375 | ||||
375 | args = 'follows_repo_id='+fallows_repo_id; |
|
376 | args = 'follows_repo_id='+fallows_repo_id; | |
376 | args+= '&auth_token='+token; |
|
377 | args+= '&auth_token='+token; | |
377 | YUC.asyncRequest('POST',base_url,{ |
|
378 | YUC.asyncRequest('POST',base_url,{ | |
378 | success:function(o){ |
|
379 | success:function(o){ | |
379 | onSuccess(); |
|
380 | onSuccess(target); | |
380 | } |
|
381 | } | |
381 | },args); return false; |
|
382 | },args); return false; | |
382 | } |
|
383 | } |
@@ -47,11 +47,11 b'' | |||||
47 | %if c.rhodecode_user.username != 'default': |
|
47 | %if c.rhodecode_user.username != 'default': | |
48 | %if c.following: |
|
48 | %if c.following: | |
49 | <span id="follow_toggle" class="following" title="${_('Stop following this repository')}" |
|
49 | <span id="follow_toggle" class="following" title="${_('Stop following this repository')}" | |
50 | onclick="javascript:toggleFollowingRepo(${c.repo_info.dbrepo.repo_id},'${str(h.get_token())}')"> |
|
50 | onclick="javascript:toggleFollowingRepo(this,${c.repo_info.dbrepo.repo_id},'${str(h.get_token())}')"> | |
51 | </span> |
|
51 | </span> | |
52 | %else: |
|
52 | %else: | |
53 | <span id="follow_toggle" class="follow" title="${_('Start following this repository')}" |
|
53 | <span id="follow_toggle" class="follow" title="${_('Start following this repository')}" | |
54 | onclick="javascript:toggleFollowingRepo(${c.repo_info.dbrepo.repo_id},'${str(h.get_token())}')"> |
|
54 | onclick="javascript:toggleFollowingRepo(this,${c.repo_info.dbrepo.repo_id},'${str(h.get_token())}')"> | |
55 | </span> |
|
55 | </span> | |
56 | %endif |
|
56 | %endif | |
57 | %endif: |
|
57 | %endif: |
General Comments 0
You need to be logged in to leave comments.
Login now