Show More
@@ -41,7 +41,6 b' from kallithea.lib.auth import LoginRequ' | |||
|
41 | 41 | HasRepoGroupPermissionAny, HasRepoPermissionAnyDecorator |
|
42 | 42 | from kallithea.lib.base import BaseRepoController, render |
|
43 | 43 | from kallithea.lib.utils import action_logger, repo_name_slug, jsonify |
|
44 | from kallithea.lib.helpers import get_token | |
|
45 | 44 | from kallithea.lib.vcs import RepositoryError |
|
46 | 45 | from kallithea.model.meta import Session |
|
47 | 46 | from kallithea.model.db import User, Repository, UserFollowing, RepoGroup,\ |
@@ -516,9 +515,6 b' class ReposController(BaseRepoController' | |||
|
516 | 515 | :param repo_name: |
|
517 | 516 | """ |
|
518 | 517 | |
|
519 | cur_token = request.POST.get('auth_token') | |
|
520 | token = get_token() | |
|
521 | if cur_token == token: | |
|
522 | 518 |
|
|
523 | 519 |
|
|
524 | 520 |
|
@@ -530,9 +526,6 b' class ReposController(BaseRepoController' | |||
|
530 | 526 |
|
|
531 | 527 |
|
|
532 | 528 |
|
|
533 | ||
|
534 | else: | |
|
535 | h.flash(_('Token mismatch'), category='error') | |
|
536 | 529 | return redirect(url('edit_repo_advanced', repo_name=repo_name)) |
|
537 | 530 | |
|
538 | 531 |
@@ -304,10 +304,6 b' class JournalController(BaseController):' | |||
|
304 | 304 | @LoginRequired() |
|
305 | 305 | @NotAnonymous() |
|
306 | 306 | def toggle_following(self): |
|
307 | cur_token = request.POST.get('auth_token') | |
|
308 | token = h.get_token() | |
|
309 | if cur_token == token: | |
|
310 | ||
|
311 | 307 |
|
|
312 | 308 |
|
|
313 | 309 |
|
@@ -330,7 +326,6 b' class JournalController(BaseController):' | |||
|
330 | 326 |
|
|
331 | 327 |
|
|
332 | 328 | |
|
333 | log.debug('token mismatch %s vs %s' % (cur_token, token)) | |
|
334 | 329 | raise HTTPBadRequest() |
|
335 | 330 | |
|
336 | 331 | @LoginRequired() |
@@ -134,23 +134,6 b' def FID(raw_id, path):' | |||
|
134 | 134 | return 'C-%s-%s' % (short_id(raw_id), md5(safe_str(path)).hexdigest()[:12]) |
|
135 | 135 | |
|
136 | 136 | |
|
137 | def get_token(): | |
|
138 | """Return the current authentication token, creating one if one doesn't | |
|
139 | already exist. | |
|
140 | """ | |
|
141 | token_key = "_authentication_token" | |
|
142 | from pylons import session | |
|
143 | if not token_key in session: | |
|
144 | try: | |
|
145 | token = hashlib.sha1(str(random.getrandbits(128))).hexdigest() | |
|
146 | except AttributeError: # Python < 2.4 | |
|
147 | token = hashlib.sha1(str(random.randrange(2 ** 128))).hexdigest() | |
|
148 | session[token_key] = token | |
|
149 | if hasattr(session, 'save'): | |
|
150 | session.save() | |
|
151 | return session[token_key] | |
|
152 | ||
|
153 | ||
|
154 | 137 | class _GetError(object): |
|
155 | 138 | """Get error from form_errors, and represent it as span wrapped error |
|
156 | 139 | message |
@@ -458,20 +458,16 b' var _onSuccessFollow = function(target){' | |||
|
458 | 458 | } |
|
459 | 459 | } |
|
460 | 460 | |
|
461 |
var toggleFollowingRepo = function(target, follows_repo_id |
|
|
461 | var toggleFollowingRepo = function(target, follows_repo_id){ | |
|
462 | 462 | var args = 'follows_repo_id=' + follows_repo_id; |
|
463 | args += '&auth_token=' + token; | |
|
464 | if(user_id != undefined){ | |
|
465 | args +="&user_id=" + user_id; | |
|
466 | } | |
|
467 | 463 | $.post(TOGGLE_FOLLOW_URL, args, function(data){ |
|
468 | 464 | _onSuccessFollow(target); |
|
469 | 465 | }); |
|
470 | 466 | return false; |
|
471 | 467 | }; |
|
472 | 468 | |
|
473 |
var showRepoSize = function(target, repo_name |
|
|
474 |
var args = ' |
|
|
469 | var showRepoSize = function(target, repo_name){ | |
|
470 | var args = ''; | |
|
475 | 471 | |
|
476 | 472 | if(!$("#" + target).hasClass('loaded')){ |
|
477 | 473 | $("#" + target).html(_TM['Loading ...']); |
@@ -22,7 +22,6 b'' | |||
|
22 | 22 | <h3>${_('Public Journal Visibility')}</h3> |
|
23 | 23 | ${h.form(url('edit_repo_advanced_journal', repo_name=c.repo_info.repo_name), method='put')} |
|
24 | 24 | <div class="form"> |
|
25 | ${h.hidden('auth_token',str(h.get_token()))} | |
|
26 | 25 | <div class="field"> |
|
27 | 26 | %if c.in_public_journal: |
|
28 | 27 | <button class="btn btn-small" type="submit"> |
@@ -176,7 +176,7 b'' | |||
|
176 | 176 | ## also it feels like a job for the controller |
|
177 | 177 | %if c.authuser.username != 'default': |
|
178 | 178 | <li> |
|
179 |
<a class="${follow_class()}" onclick="javascript:toggleFollowingRepo(this,${c.db_repo.repo_id} |
|
|
179 | <a class="${follow_class()}" onclick="javascript:toggleFollowingRepo(this,${c.db_repo.repo_id});"> | |
|
180 | 180 | <span class="show-follow"><i class="icon-heart-empty"></i> ${_('Follow')}</span> |
|
181 | 181 | <span class="show-following"><i class="icon-heart"></i> ${_('Unfollow')}</span> |
|
182 | 182 | </a> |
@@ -212,6 +212,6 b'' | |||
|
212 | 212 | |
|
213 | 213 | <%def name="toggle_follow(repo_id)"> |
|
214 | 214 | <span id="follow_toggle_${repo_id}" class="following" title="${_('Stop following this repository')}" |
|
215 |
onclick="javascript:toggleFollowingRepo(this, ${repo_id} |
|
|
215 | onclick="javascript:toggleFollowingRepo(this, ${repo_id})"> | |
|
216 | 216 | </span> |
|
217 | 217 | </%def> |
@@ -157,7 +157,7 b" summary = lambda n:{False:'summary-short" | |||
|
157 | 157 | |
|
158 | 158 | %if c.authuser.username != 'default': |
|
159 | 159 | <li class="repo_size"> |
|
160 |
<a href="#" onclick="javascript:showRepoSize('repo_size_2','${c.db_repo.repo_name}' |
|
|
160 | <a href="#" onclick="javascript:showRepoSize('repo_size_2','${c.db_repo.repo_name}')"><i class="icon-ruler"></i> ${_('Repository Size')}</a> | |
|
161 | 161 | <span class="stats-bullet" id="repo_size_2"></span> |
|
162 | 162 | </li> |
|
163 | 163 | %endif |
@@ -23,8 +23,7 b' class TestJournalController(TestControll' | |||
|
23 | 23 | # |
|
24 | 24 | # response = self.app.post(url(controller='journal', |
|
25 | 25 | # action='toggle_following'), |
|
26 |
# {' |
|
|
27 | # 'follows_repo_id':repo.repo_id}) | |
|
26 | # {'follows_repo_id':repo.repo_id}) | |
|
28 | 27 | |
|
29 | 28 | def test_start_following_repository(self): |
|
30 | 29 | self.log_user() |
General Comments 0
You need to be logged in to leave comments.
Login now