##// END OF EJS Templates
cleanup: replace redirect with WebOb exceptions...
Søren Løvborg -
r5543:d9b78d8f default
parent child Browse files
Show More
@@ -28,8 +28,8 b' import formencode.htmlfill'
28 import traceback
28 import traceback
29
29
30 from pylons import request, tmpl_context as c, url
30 from pylons import request, tmpl_context as c, url
31 from pylons.controllers.util import redirect
32 from pylons.i18n.translation import _
31 from pylons.i18n.translation import _
32 from webob.exc import HTTPFound
33
33
34 from kallithea.lib import helpers as h
34 from kallithea.lib import helpers as h
35 from kallithea.lib.compat import formatted_json
35 from kallithea.lib.compat import formatted_json
@@ -146,4 +146,4 b' class AuthSettingsController(BaseControl'
146 h.flash(_('error occurred during update of auth settings'),
146 h.flash(_('error occurred during update of auth settings'),
147 category='error')
147 category='error')
148
148
149 return redirect(url('auth_home'))
149 raise HTTPFound(location=url('auth_home'))
@@ -31,8 +31,8 b' import formencode'
31 from formencode import htmlfill
31 from formencode import htmlfill
32
32
33 from pylons import request, tmpl_context as c, url
33 from pylons import request, tmpl_context as c, url
34 from pylons.controllers.util import redirect
35 from pylons.i18n.translation import _
34 from pylons.i18n.translation import _
35 from webob.exc import HTTPFound
36
36
37 from kallithea.lib import helpers as h
37 from kallithea.lib import helpers as h
38 from kallithea.lib.auth import LoginRequired, HasPermissionAllDecorator
38 from kallithea.lib.auth import LoginRequired, HasPermissionAllDecorator
@@ -112,7 +112,7 b' class DefaultsController(BaseController)'
112 h.flash(_('Error occurred during update of defaults'),
112 h.flash(_('Error occurred during update of defaults'),
113 category='error')
113 category='error')
114
114
115 return redirect(url('defaults'))
115 raise HTTPFound(location=url('defaults'))
116
116
117 def delete(self, id):
117 def delete(self, id):
118 """DELETE /defaults/id: Delete an existing item"""
118 """DELETE /defaults/id: Delete an existing item"""
@@ -31,8 +31,8 b' import traceback'
31 import formencode.htmlfill
31 import formencode.htmlfill
32
32
33 from pylons import request, response, tmpl_context as c, url
33 from pylons import request, response, tmpl_context as c, url
34 from pylons.controllers.util import redirect
35 from pylons.i18n.translation import _
34 from pylons.i18n.translation import _
35 from webob.exc import HTTPFound, HTTPNotFound, HTTPForbidden
36
36
37 from kallithea.model.forms import GistForm
37 from kallithea.model.forms import GistForm
38 from kallithea.model.gist import GistModel
38 from kallithea.model.gist import GistModel
@@ -44,7 +44,6 b' from kallithea.lib.auth import LoginRequ'
44 from kallithea.lib.utils import jsonify
44 from kallithea.lib.utils import jsonify
45 from kallithea.lib.utils2 import safe_int, time_to_datetime
45 from kallithea.lib.utils2 import safe_int, time_to_datetime
46 from kallithea.lib.helpers import Page
46 from kallithea.lib.helpers import Page
47 from webob.exc import HTTPNotFound, HTTPForbidden
48 from sqlalchemy.sql.expression import or_
47 from sqlalchemy.sql.expression import or_
49 from kallithea.lib.vcs.exceptions import VCSError, NodeNotChangedError
48 from kallithea.lib.vcs.exceptions import VCSError, NodeNotChangedError
50
49
@@ -144,8 +143,8 b' class GistsController(BaseController):'
144 except Exception as e:
143 except Exception as e:
145 log.error(traceback.format_exc())
144 log.error(traceback.format_exc())
146 h.flash(_('Error occurred during gist creation'), category='error')
145 h.flash(_('Error occurred during gist creation'), category='error')
147 return redirect(url('new_gist'))
146 raise HTTPFound(location=url('new_gist'))
148 return redirect(url('gist', gist_id=new_gist_id))
147 raise HTTPFound(location=url('gist', gist_id=new_gist_id))
149
148
150 @LoginRequired()
149 @LoginRequired()
151 @NotAnonymous()
150 @NotAnonymous()
@@ -185,7 +184,7 b' class GistsController(BaseController):'
185 else:
184 else:
186 raise HTTPForbidden()
185 raise HTTPForbidden()
187
186
188 return redirect(url('gists'))
187 raise HTTPFound(location=url('gists'))
189
188
190 @LoginRequired()
189 @LoginRequired()
191 def show(self, gist_id, revision='tip', format='html', f_path=None):
190 def show(self, gist_id, revision='tip', format='html', f_path=None):
@@ -270,7 +269,7 b' class GistsController(BaseController):'
270 h.flash(_('Error occurred during update of gist %s') % gist_id,
269 h.flash(_('Error occurred during update of gist %s') % gist_id,
271 category='error')
270 category='error')
272
271
273 return redirect(url('gist', gist_id=gist_id))
272 raise HTTPFound(location=url('gist', gist_id=gist_id))
274
273
275 return rendered
274 return rendered
276
275
@@ -32,8 +32,8 b' import formencode'
32 from sqlalchemy import func
32 from sqlalchemy import func
33 from formencode import htmlfill
33 from formencode import htmlfill
34 from pylons import request, tmpl_context as c, url
34 from pylons import request, tmpl_context as c, url
35 from pylons.controllers.util import redirect
36 from pylons.i18n.translation import _
35 from pylons.i18n.translation import _
36 from webob.exc import HTTPFound
37
37
38 from kallithea import EXTERN_TYPE_INTERNAL
38 from kallithea import EXTERN_TYPE_INTERNAL
39 from kallithea.lib import helpers as h
39 from kallithea.lib import helpers as h
@@ -69,7 +69,7 b' class MyAccountController(BaseController'
69 if c.user.username == User.DEFAULT_USER:
69 if c.user.username == User.DEFAULT_USER:
70 h.flash(_("You can't edit this user since it's"
70 h.flash(_("You can't edit this user since it's"
71 " crucial for entire application"), category='warning')
71 " crucial for entire application"), category='warning')
72 return redirect(url('users'))
72 raise HTTPFound(location=url('users'))
73 c.EXTERN_TYPE_INTERNAL = EXTERN_TYPE_INTERNAL
73 c.EXTERN_TYPE_INTERNAL = EXTERN_TYPE_INTERNAL
74
74
75 def _load_my_repos_data(self, watched=False):
75 def _load_my_repos_data(self, watched=False):
@@ -144,7 +144,7 b' class MyAccountController(BaseController'
144 h.flash(_('Error occurred during update of user %s') \
144 h.flash(_('Error occurred during update of user %s') \
145 % form_result.get('username'), category='error')
145 % form_result.get('username'), category='error')
146 if update:
146 if update:
147 return redirect('my_account')
147 raise HTTPFound(location='my_account')
148 return htmlfill.render(
148 return htmlfill.render(
149 render('admin/my_account/my_account.html'),
149 render('admin/my_account/my_account.html'),
150 defaults=defaults,
150 defaults=defaults,
@@ -225,7 +225,7 b' class MyAccountController(BaseController'
225 log.error(traceback.format_exc())
225 log.error(traceback.format_exc())
226 h.flash(_('An error occurred during email saving'),
226 h.flash(_('An error occurred during email saving'),
227 category='error')
227 category='error')
228 return redirect(url('my_account_emails'))
228 raise HTTPFound(location=url('my_account_emails'))
229
229
230 def my_account_emails_delete(self):
230 def my_account_emails_delete(self):
231 email_id = request.POST.get('del_email_id')
231 email_id = request.POST.get('del_email_id')
@@ -233,7 +233,7 b' class MyAccountController(BaseController'
233 user_model.delete_extra_email(self.authuser.user_id, email_id)
233 user_model.delete_extra_email(self.authuser.user_id, email_id)
234 Session().commit()
234 Session().commit()
235 h.flash(_("Removed email from user"), category='success')
235 h.flash(_("Removed email from user"), category='success')
236 return redirect(url('my_account_emails'))
236 raise HTTPFound(location=url('my_account_emails'))
237
237
238 def my_account_api_keys(self):
238 def my_account_api_keys(self):
239 c.active = 'api_keys'
239 c.active = 'api_keys'
@@ -257,7 +257,7 b' class MyAccountController(BaseController'
257 ApiKeyModel().create(self.authuser.user_id, description, lifetime)
257 ApiKeyModel().create(self.authuser.user_id, description, lifetime)
258 Session().commit()
258 Session().commit()
259 h.flash(_("API key successfully created"), category='success')
259 h.flash(_("API key successfully created"), category='success')
260 return redirect(url('my_account_api_keys'))
260 raise HTTPFound(location=url('my_account_api_keys'))
261
261
262 def my_account_api_keys_delete(self):
262 def my_account_api_keys_delete(self):
263 api_key = request.POST.get('del_api_key')
263 api_key = request.POST.get('del_api_key')
@@ -274,4 +274,4 b' class MyAccountController(BaseController'
274 Session().commit()
274 Session().commit()
275 h.flash(_("API key successfully deleted"), category='success')
275 h.flash(_("API key successfully deleted"), category='success')
276
276
277 return redirect(url('my_account_api_keys'))
277 raise HTTPFound(location=url('my_account_api_keys'))
@@ -32,8 +32,8 b' import formencode'
32 from formencode import htmlfill
32 from formencode import htmlfill
33
33
34 from pylons import request, tmpl_context as c, url
34 from pylons import request, tmpl_context as c, url
35 from pylons.controllers.util import redirect
36 from pylons.i18n.translation import _
35 from pylons.i18n.translation import _
36 from webob.exc import HTTPFound
37
37
38 from kallithea.lib import helpers as h
38 from kallithea.lib import helpers as h
39 from kallithea.lib.auth import LoginRequired, HasPermissionAllDecorator
39 from kallithea.lib.auth import LoginRequired, HasPermissionAllDecorator
@@ -139,7 +139,7 b' class PermissionsController(BaseControll'
139 h.flash(_('Error occurred during update of permissions'),
139 h.flash(_('Error occurred during update of permissions'),
140 category='error')
140 category='error')
141
141
142 return redirect(url('admin_permissions'))
142 raise HTTPFound(location=url('admin_permissions'))
143
143
144 c.user = User.get_default_user()
144 c.user = User.get_default_user()
145 defaults = {'anonymous': c.user.active}
145 defaults = {'anonymous': c.user.active}
@@ -33,9 +33,8 b' import itertools'
33 from formencode import htmlfill
33 from formencode import htmlfill
34
34
35 from pylons import request, tmpl_context as c, url
35 from pylons import request, tmpl_context as c, url
36 from pylons.controllers.util import redirect
37 from pylons.i18n.translation import _, ungettext
36 from pylons.i18n.translation import _, ungettext
38 from webob.exc import HTTPForbidden, HTTPNotFound, HTTPInternalServerError
37 from webob.exc import HTTPFound, HTTPForbidden, HTTPNotFound, HTTPInternalServerError
39
38
40 import kallithea
39 import kallithea
41 from kallithea.lib import helpers as h
40 from kallithea.lib import helpers as h
@@ -189,10 +188,10 b' class RepoGroupsController(BaseControlle'
189 % request.POST.get('group_name'), category='error')
188 % request.POST.get('group_name'), category='error')
190 parent_group_id = form_result['group_parent_id']
189 parent_group_id = form_result['group_parent_id']
191 #TODO: maybe we should get back to the main view, not the admin one
190 #TODO: maybe we should get back to the main view, not the admin one
192 return redirect(url('repos_groups', parent_group=parent_group_id))
191 raise HTTPFound(location=url('repos_groups', parent_group=parent_group_id))
193 h.flash(_('Created repository group %s') % gr.group_name,
192 h.flash(_('Created repository group %s') % gr.group_name,
194 category='success')
193 category='success')
195 return redirect(url('repos_group_home', group_name=gr.group_name))
194 raise HTTPFound(location=url('repos_group_home', group_name=gr.group_name))
196
195
197 def new(self):
196 def new(self):
198 """GET /repo_groups/new: Form to create a new item"""
197 """GET /repo_groups/new: Form to create a new item"""
@@ -266,7 +265,7 b' class RepoGroupsController(BaseControlle'
266 h.flash(_('Error occurred during update of repository group %s') \
265 h.flash(_('Error occurred during update of repository group %s') \
267 % request.POST.get('group_name'), category='error')
266 % request.POST.get('group_name'), category='error')
268
267
269 return redirect(url('edit_repo_group', group_name=group_name))
268 raise HTTPFound(location=url('edit_repo_group', group_name=group_name))
270
269
271 @HasRepoGroupPermissionAnyDecorator('group.admin')
270 @HasRepoGroupPermissionAnyDecorator('group.admin')
272 def delete(self, group_name):
271 def delete(self, group_name):
@@ -283,13 +282,13 b' class RepoGroupsController(BaseControlle'
283 if repos:
282 if repos:
284 h.flash(_('This group contains %s repositories and cannot be '
283 h.flash(_('This group contains %s repositories and cannot be '
285 'deleted') % len(repos), category='warning')
284 'deleted') % len(repos), category='warning')
286 return redirect(url('repos_groups'))
285 raise HTTPFound(location=url('repos_groups'))
287
286
288 children = gr.children.all()
287 children = gr.children.all()
289 if children:
288 if children:
290 h.flash(_('This group contains %s subgroups and cannot be deleted'
289 h.flash(_('This group contains %s subgroups and cannot be deleted'
291 % (len(children))), category='warning')
290 % (len(children))), category='warning')
292 return redirect(url('repos_groups'))
291 raise HTTPFound(location=url('repos_groups'))
293
292
294 try:
293 try:
295 RepoGroupModel().delete(group_name)
294 RepoGroupModel().delete(group_name)
@@ -303,8 +302,8 b' class RepoGroupsController(BaseControlle'
303 % group_name, category='error')
302 % group_name, category='error')
304
303
305 if gr.parent_group:
304 if gr.parent_group:
306 return redirect(url('repos_group_home', group_name=gr.parent_group.group_name))
305 raise HTTPFound(location=url('repos_group_home', group_name=gr.parent_group.group_name))
307 return redirect(url('repos_groups'))
306 raise HTTPFound(location=url('repos_groups'))
308
307
309 def show_by_name(self, group_name):
308 def show_by_name(self, group_name):
310 """
309 """
@@ -404,7 +403,7 b' class RepoGroupsController(BaseControlle'
404 if self._revoke_perms_on_yourself(form_result):
403 if self._revoke_perms_on_yourself(form_result):
405 msg = _('Cannot revoke permission for yourself as admin')
404 msg = _('Cannot revoke permission for yourself as admin')
406 h.flash(msg, category='warning')
405 h.flash(msg, category='warning')
407 return redirect(url('edit_repo_group_perms', group_name=group_name))
406 raise HTTPFound(location=url('edit_repo_group_perms', group_name=group_name))
408 recursive = form_result['recursive']
407 recursive = form_result['recursive']
409 # iterate over all members(if in recursive mode) of this groups and
408 # iterate over all members(if in recursive mode) of this groups and
410 # set the permissions !
409 # set the permissions !
@@ -418,7 +417,7 b' class RepoGroupsController(BaseControlle'
418 # repo_name, self.ip_addr, self.sa)
417 # repo_name, self.ip_addr, self.sa)
419 Session().commit()
418 Session().commit()
420 h.flash(_('Repository group permissions updated'), category='success')
419 h.flash(_('Repository group permissions updated'), category='success')
421 return redirect(url('edit_repo_group_perms', group_name=group_name))
420 raise HTTPFound(location=url('edit_repo_group_perms', group_name=group_name))
422
421
423 @HasRepoGroupPermissionAnyDecorator('group.admin')
422 @HasRepoGroupPermissionAnyDecorator('group.admin')
424 def delete_perms(self, group_name):
423 def delete_perms(self, group_name):
@@ -29,11 +29,10 b' import logging'
29 import traceback
29 import traceback
30 import formencode
30 import formencode
31 from formencode import htmlfill
31 from formencode import htmlfill
32 from webob.exc import HTTPInternalServerError, HTTPForbidden, HTTPNotFound
33 from pylons import request, tmpl_context as c, url
32 from pylons import request, tmpl_context as c, url
34 from pylons.controllers.util import redirect
35 from pylons.i18n.translation import _
33 from pylons.i18n.translation import _
36 from sqlalchemy.sql.expression import func
34 from sqlalchemy.sql.expression import func
35 from webob.exc import HTTPFound, HTTPInternalServerError, HTTPForbidden, HTTPNotFound
37
36
38 from kallithea.lib import helpers as h
37 from kallithea.lib import helpers as h
39 from kallithea.lib.auth import LoginRequired, \
38 from kallithea.lib.auth import LoginRequired, \
@@ -71,7 +70,7 b' class ReposController(BaseRepoController'
71
70
72 if repo_obj is None:
71 if repo_obj is None:
73 h.not_mapped_error(repo_name)
72 h.not_mapped_error(repo_name)
74 return redirect(url('repos'))
73 raise HTTPFound(location=url('repos'))
75
74
76 return repo_obj
75 return repo_obj
77
76
@@ -152,9 +151,9 b' class ReposController(BaseRepoController'
152 msg = (_('Error creating repository %s')
151 msg = (_('Error creating repository %s')
153 % form_result.get('repo_name'))
152 % form_result.get('repo_name'))
154 h.flash(msg, category='error')
153 h.flash(msg, category='error')
155 return redirect(url('home'))
154 raise HTTPFound(location=url('home'))
156
155
157 return redirect(h.url('repo_creating_home',
156 raise HTTPFound(location=h.url('repo_creating_home',
158 repo_name=form_result['repo_name_full'],
157 repo_name=form_result['repo_name_full'],
159 task_id=task_id))
158 task_id=task_id))
160
159
@@ -282,7 +281,7 b' class ReposController(BaseRepoController'
282 log.error(traceback.format_exc())
281 log.error(traceback.format_exc())
283 h.flash(_('Error occurred during update of repository %s') \
282 h.flash(_('Error occurred during update of repository %s') \
284 % repo_name, category='error')
283 % repo_name, category='error')
285 return redirect(url('edit_repo', repo_name=changed_name))
284 raise HTTPFound(location=url('edit_repo', repo_name=changed_name))
286
285
287 @HasRepoPermissionAllDecorator('repository.admin')
286 @HasRepoPermissionAllDecorator('repository.admin')
288 def delete(self, repo_name):
287 def delete(self, repo_name):
@@ -299,7 +298,7 b' class ReposController(BaseRepoController'
299 repo = repo_model.get_by_repo_name(repo_name)
298 repo = repo_model.get_by_repo_name(repo_name)
300 if not repo:
299 if not repo:
301 h.not_mapped_error(repo_name)
300 h.not_mapped_error(repo_name)
302 return redirect(url('repos'))
301 raise HTTPFound(location=url('repos'))
303 try:
302 try:
304 _forks = repo.forks.count()
303 _forks = repo.forks.count()
305 handle_forks = None
304 handle_forks = None
@@ -327,8 +326,8 b' class ReposController(BaseRepoController'
327 category='error')
326 category='error')
328
327
329 if repo.group:
328 if repo.group:
330 return redirect(url('repos_group_home', group_name=repo.group.group_name))
329 raise HTTPFound(location=url('repos_group_home', group_name=repo.group.group_name))
331 return redirect(url('repos'))
330 raise HTTPFound(location=url('repos'))
332
331
333 @HasRepoPermissionAllDecorator('repository.admin')
332 @HasRepoPermissionAllDecorator('repository.admin')
334 def edit(self, repo_name):
333 def edit(self, repo_name):
@@ -372,7 +371,7 b' class ReposController(BaseRepoController'
372 # repo_name, self.ip_addr, self.sa)
371 # repo_name, self.ip_addr, self.sa)
373 Session().commit()
372 Session().commit()
374 h.flash(_('Repository permissions updated'), category='success')
373 h.flash(_('Repository permissions updated'), category='success')
375 return redirect(url('edit_repo_perms', repo_name=repo_name))
374 raise HTTPFound(location=url('edit_repo_perms', repo_name=repo_name))
376
375
377 def edit_permissions_revoke(self, repo_name):
376 def edit_permissions_revoke(self, repo_name):
378 try:
377 try:
@@ -409,7 +408,7 b' class ReposController(BaseRepoController'
409 c.active = 'fields'
408 c.active = 'fields'
410 if request.POST:
409 if request.POST:
411
410
412 return redirect(url('repo_edit_fields'))
411 raise HTTPFound(location=url('repo_edit_fields'))
413 return render('admin/repos/repo_edit.html')
412 return render('admin/repos/repo_edit.html')
414
413
415 @HasRepoPermissionAllDecorator('repository.admin')
414 @HasRepoPermissionAllDecorator('repository.admin')
@@ -431,7 +430,7 b' class ReposController(BaseRepoController'
431 if isinstance(e, formencode.Invalid):
430 if isinstance(e, formencode.Invalid):
432 msg += ". " + e.msg
431 msg += ". " + e.msg
433 h.flash(msg, category='error')
432 h.flash(msg, category='error')
434 return redirect(url('edit_repo_fields', repo_name=repo_name))
433 raise HTTPFound(location=url('edit_repo_fields', repo_name=repo_name))
435
434
436 @HasRepoPermissionAllDecorator('repository.admin')
435 @HasRepoPermissionAllDecorator('repository.admin')
437 def delete_repo_field(self, repo_name, field_id):
436 def delete_repo_field(self, repo_name, field_id):
@@ -443,7 +442,7 b' class ReposController(BaseRepoController'
443 log.error(traceback.format_exc())
442 log.error(traceback.format_exc())
444 msg = _('An error occurred during removal of field')
443 msg = _('An error occurred during removal of field')
445 h.flash(msg, category='error')
444 h.flash(msg, category='error')
446 return redirect(url('edit_repo_fields', repo_name=repo_name))
445 raise HTTPFound(location=url('edit_repo_fields', repo_name=repo_name))
447
446
448 @HasRepoPermissionAllDecorator('repository.admin')
447 @HasRepoPermissionAllDecorator('repository.admin')
449 def edit_advanced(self, repo_name):
448 def edit_advanced(self, repo_name):
@@ -468,7 +467,7 b' class ReposController(BaseRepoController'
468
467
469 c.active = 'advanced'
468 c.active = 'advanced'
470 if request.POST:
469 if request.POST:
471 return redirect(url('repo_edit_advanced'))
470 raise HTTPFound(location=url('repo_edit_advanced'))
472 return htmlfill.render(
471 return htmlfill.render(
473 render('admin/repos/repo_edit.html'),
472 render('admin/repos/repo_edit.html'),
474 defaults=defaults,
473 defaults=defaults,
@@ -495,7 +494,7 b' class ReposController(BaseRepoController'
495 h.flash(_('An error occurred during setting this'
494 h.flash(_('An error occurred during setting this'
496 ' repository in public journal'),
495 ' repository in public journal'),
497 category='error')
496 category='error')
498 return redirect(url('edit_repo_advanced', repo_name=repo_name))
497 raise HTTPFound(location=url('edit_repo_advanced', repo_name=repo_name))
499
498
500
499
501 @HasRepoPermissionAllDecorator('repository.admin')
500 @HasRepoPermissionAllDecorator('repository.admin')
@@ -521,7 +520,7 b' class ReposController(BaseRepoController'
521 h.flash(_('An error occurred during this operation'),
520 h.flash(_('An error occurred during this operation'),
522 category='error')
521 category='error')
523
522
524 return redirect(url('edit_repo_advanced', repo_name=repo_name))
523 raise HTTPFound(location=url('edit_repo_advanced', repo_name=repo_name))
525
524
526 @HasRepoPermissionAllDecorator('repository.admin')
525 @HasRepoPermissionAllDecorator('repository.admin')
527 def edit_advanced_locking(self, repo_name):
526 def edit_advanced_locking(self, repo_name):
@@ -542,7 +541,7 b' class ReposController(BaseRepoController'
542 log.error(traceback.format_exc())
541 log.error(traceback.format_exc())
543 h.flash(_('An error occurred during unlocking'),
542 h.flash(_('An error occurred during unlocking'),
544 category='error')
543 category='error')
545 return redirect(url('edit_repo_advanced', repo_name=repo_name))
544 raise HTTPFound(location=url('edit_repo_advanced', repo_name=repo_name))
546
545
547 @HasRepoPermissionAnyDecorator('repository.write', 'repository.admin')
546 @HasRepoPermissionAnyDecorator('repository.write', 'repository.admin')
548 def toggle_locking(self, repo_name):
547 def toggle_locking(self, repo_name):
@@ -567,7 +566,7 b' class ReposController(BaseRepoController'
567 log.error(traceback.format_exc())
566 log.error(traceback.format_exc())
568 h.flash(_('An error occurred during unlocking'),
567 h.flash(_('An error occurred during unlocking'),
569 category='error')
568 category='error')
570 return redirect(url('summary_home', repo_name=repo_name))
569 raise HTTPFound(location=url('summary_home', repo_name=repo_name))
571
570
572 @HasRepoPermissionAllDecorator('repository.admin')
571 @HasRepoPermissionAllDecorator('repository.admin')
573 def edit_caches(self, repo_name):
572 def edit_caches(self, repo_name):
@@ -586,7 +585,7 b' class ReposController(BaseRepoController'
586 h.flash(_('An error occurred during cache invalidation'),
585 h.flash(_('An error occurred during cache invalidation'),
587 category='error')
586 category='error')
588
587
589 return redirect(url('edit_repo_caches', repo_name=c.repo_name))
588 raise HTTPFound(location=url('edit_repo_caches', repo_name=c.repo_name))
590 return render('admin/repos/repo_edit.html')
589 return render('admin/repos/repo_edit.html')
591
590
592 @HasRepoPermissionAllDecorator('repository.admin')
591 @HasRepoPermissionAllDecorator('repository.admin')
@@ -603,7 +602,7 b' class ReposController(BaseRepoController'
603 log.error(traceback.format_exc())
602 log.error(traceback.format_exc())
604 h.flash(_('An error occurred during pull from remote location'),
603 h.flash(_('An error occurred during pull from remote location'),
605 category='error')
604 category='error')
606 return redirect(url('edit_repo_remote', repo_name=c.repo_name))
605 raise HTTPFound(location=url('edit_repo_remote', repo_name=c.repo_name))
607 return render('admin/repos/repo_edit.html')
606 return render('admin/repos/repo_edit.html')
608
607
609 @HasRepoPermissionAllDecorator('repository.admin')
608 @HasRepoPermissionAllDecorator('repository.admin')
@@ -636,6 +635,6 b' class ReposController(BaseRepoController'
636 log.error(traceback.format_exc())
635 log.error(traceback.format_exc())
637 h.flash(_('An error occurred during deletion of repository stats'),
636 h.flash(_('An error occurred during deletion of repository stats'),
638 category='error')
637 category='error')
639 return redirect(url('edit_repo_statistics', repo_name=c.repo_name))
638 raise HTTPFound(location=url('edit_repo_statistics', repo_name=c.repo_name))
640
639
641 return render('admin/repos/repo_edit.html')
640 return render('admin/repos/repo_edit.html')
@@ -31,8 +31,8 b' import formencode'
31
31
32 from formencode import htmlfill
32 from formencode import htmlfill
33 from pylons import request, tmpl_context as c, url, config
33 from pylons import request, tmpl_context as c, url, config
34 from pylons.controllers.util import redirect
35 from pylons.i18n.translation import _
34 from pylons.i18n.translation import _
35 from webob.exc import HTTPFound
36
36
37 from kallithea.lib import helpers as h
37 from kallithea.lib import helpers as h
38 from kallithea.lib.auth import LoginRequired, HasPermissionAllDecorator
38 from kallithea.lib.auth import LoginRequired, HasPermissionAllDecorator
@@ -218,7 +218,7 b' class SettingsController(BaseController)'
218 for repo_name in added) or '-',
218 for repo_name in added) or '-',
219 ', '.join(h.escape(safe_unicode(repo_name)) for repo_name in removed) or '-')),
219 ', '.join(h.escape(safe_unicode(repo_name)) for repo_name in removed) or '-')),
220 category='success')
220 category='success')
221 return redirect(url('admin_settings_mapping'))
221 raise HTTPFound(location=url('admin_settings_mapping'))
222
222
223 defaults = Setting.get_app_settings()
223 defaults = Setting.get_app_settings()
224 defaults.update(self._get_hg_ui_settings())
224 defaults.update(self._get_hg_ui_settings())
@@ -278,7 +278,7 b' class SettingsController(BaseController)'
278 'application settings'),
278 'application settings'),
279 category='error')
279 category='error')
280
280
281 return redirect(url('admin_settings_global'))
281 raise HTTPFound(location=url('admin_settings_global'))
282
282
283 defaults = Setting.get_app_settings()
283 defaults = Setting.get_app_settings()
284 defaults.update(self._get_hg_ui_settings())
284 defaults.update(self._get_hg_ui_settings())
@@ -336,7 +336,7 b' class SettingsController(BaseController)'
336 'visualisation settings'),
336 'visualisation settings'),
337 category='error')
337 category='error')
338
338
339 return redirect(url('admin_settings_visual'))
339 raise HTTPFound(location=url('admin_settings_visual'))
340
340
341 defaults = Setting.get_app_settings()
341 defaults = Setting.get_app_settings()
342 defaults.update(self._get_hg_ui_settings())
342 defaults.update(self._get_hg_ui_settings())
@@ -359,7 +359,7 b' class SettingsController(BaseController)'
359 'Kallithea version: %s' % c.kallithea_version)
359 'Kallithea version: %s' % c.kallithea_version)
360 if not test_email:
360 if not test_email:
361 h.flash(_('Please enter email address'), category='error')
361 h.flash(_('Please enter email address'), category='error')
362 return redirect(url('admin_settings_email'))
362 raise HTTPFound(location=url('admin_settings_email'))
363
363
364 test_email_txt_body = EmailNotificationModel()\
364 test_email_txt_body = EmailNotificationModel()\
365 .get_email_tmpl(EmailNotificationModel.TYPE_DEFAULT,
365 .get_email_tmpl(EmailNotificationModel.TYPE_DEFAULT,
@@ -374,7 +374,7 b' class SettingsController(BaseController)'
374 test_email_txt_body, test_email_html_body)
374 test_email_txt_body, test_email_html_body)
375
375
376 h.flash(_('Send email task created'), category='success')
376 h.flash(_('Send email task created'), category='success')
377 return redirect(url('admin_settings_email'))
377 raise HTTPFound(location=url('admin_settings_email'))
378
378
379 defaults = Setting.get_app_settings()
379 defaults = Setting.get_app_settings()
380 defaults.update(self._get_hg_ui_settings())
380 defaults.update(self._get_hg_ui_settings())
@@ -425,7 +425,7 b' class SettingsController(BaseController)'
425 h.flash(_('Error occurred during hook creation'),
425 h.flash(_('Error occurred during hook creation'),
426 category='error')
426 category='error')
427
427
428 return redirect(url('admin_settings_hooks'))
428 raise HTTPFound(location=url('admin_settings_hooks'))
429
429
430 defaults = Setting.get_app_settings()
430 defaults = Setting.get_app_settings()
431 defaults.update(self._get_hg_ui_settings())
431 defaults.update(self._get_hg_ui_settings())
@@ -449,7 +449,7 b' class SettingsController(BaseController)'
449 full_index = request.POST.get('full_index', False)
449 full_index = request.POST.get('full_index', False)
450 run_task(tasks.whoosh_index, repo_location, full_index)
450 run_task(tasks.whoosh_index, repo_location, full_index)
451 h.flash(_('Whoosh reindex task scheduled'), category='success')
451 h.flash(_('Whoosh reindex task scheduled'), category='success')
452 return redirect(url('admin_settings_search'))
452 raise HTTPFound(location=url('admin_settings_search'))
453
453
454 defaults = Setting.get_app_settings()
454 defaults = Setting.get_app_settings()
455 defaults.update(self._get_hg_ui_settings())
455 defaults.update(self._get_hg_ui_settings())
@@ -31,8 +31,8 b' import formencode'
31
31
32 from formencode import htmlfill
32 from formencode import htmlfill
33 from pylons import request, tmpl_context as c, url, config
33 from pylons import request, tmpl_context as c, url, config
34 from pylons.controllers.util import redirect
35 from pylons.i18n.translation import _
34 from pylons.i18n.translation import _
35 from webob.exc import HTTPFound
36
36
37 from sqlalchemy.orm import joinedload
37 from sqlalchemy.orm import joinedload
38 from sqlalchemy.sql.expression import func
38 from sqlalchemy.sql.expression import func
@@ -163,7 +163,7 b' class UserGroupsController(BaseControlle'
163 h.flash(_('Error occurred during creation of user group %s') \
163 h.flash(_('Error occurred during creation of user group %s') \
164 % request.POST.get('users_group_name'), category='error')
164 % request.POST.get('users_group_name'), category='error')
165
165
166 return redirect(url('users_groups'))
166 raise HTTPFound(location=url('users_groups'))
167
167
168 @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true')
168 @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true')
169 def new(self, format='html'):
169 def new(self, format='html'):
@@ -224,7 +224,7 b' class UserGroupsController(BaseControlle'
224 h.flash(_('Error occurred during update of user group %s') \
224 h.flash(_('Error occurred during update of user group %s') \
225 % request.POST.get('users_group_name'), category='error')
225 % request.POST.get('users_group_name'), category='error')
226
226
227 return redirect(url('edit_users_group', id=id))
227 raise HTTPFound(location=url('edit_users_group', id=id))
228
228
229 @HasUserGroupPermissionAnyDecorator('usergroup.admin')
229 @HasUserGroupPermissionAnyDecorator('usergroup.admin')
230 def delete(self, id):
230 def delete(self, id):
@@ -246,7 +246,7 b' class UserGroupsController(BaseControlle'
246 log.error(traceback.format_exc())
246 log.error(traceback.format_exc())
247 h.flash(_('An error occurred during deletion of user group'),
247 h.flash(_('An error occurred during deletion of user group'),
248 category='error')
248 category='error')
249 return redirect(url('users_groups'))
249 raise HTTPFound(location=url('users_groups'))
250
250
251 def show(self, id, format='html'):
251 def show(self, id, format='html'):
252 """GET /user_groups/id: Show a specific item"""
252 """GET /user_groups/id: Show a specific item"""
@@ -312,13 +312,13 b' class UserGroupsController(BaseControlle'
312 form['perms_updates'])
312 form['perms_updates'])
313 except RepoGroupAssignmentError:
313 except RepoGroupAssignmentError:
314 h.flash(_('Target group cannot be the same'), category='error')
314 h.flash(_('Target group cannot be the same'), category='error')
315 return redirect(url('edit_user_group_perms', id=id))
315 raise HTTPFound(location=url('edit_user_group_perms', id=id))
316 #TODO: implement this
316 #TODO: implement this
317 #action_logger(self.authuser, 'admin_changed_repo_permissions',
317 #action_logger(self.authuser, 'admin_changed_repo_permissions',
318 # repo_name, self.ip_addr, self.sa)
318 # repo_name, self.ip_addr, self.sa)
319 Session().commit()
319 Session().commit()
320 h.flash(_('User group permissions updated'), category='success')
320 h.flash(_('User group permissions updated'), category='success')
321 return redirect(url('edit_user_group_perms', id=id))
321 raise HTTPFound(location=url('edit_user_group_perms', id=id))
322
322
323 @HasUserGroupPermissionAnyDecorator('usergroup.admin')
323 @HasUserGroupPermissionAnyDecorator('usergroup.admin')
324 def delete_perms(self, id):
324 def delete_perms(self, id):
@@ -444,7 +444,7 b' class UserGroupsController(BaseControlle'
444 h.flash(_('An error occurred during permissions saving'),
444 h.flash(_('An error occurred during permissions saving'),
445 category='error')
445 category='error')
446
446
447 return redirect(url('edit_user_group_default_perms', id=id))
447 raise HTTPFound(location=url('edit_user_group_default_perms', id=id))
448
448
449 @HasUserGroupPermissionAnyDecorator('usergroup.admin')
449 @HasUserGroupPermissionAnyDecorator('usergroup.admin')
450 def edit_advanced(self, id):
450 def edit_advanced(self, id):
@@ -31,10 +31,9 b' import formencode'
31
31
32 from formencode import htmlfill
32 from formencode import htmlfill
33 from pylons import request, tmpl_context as c, url, config
33 from pylons import request, tmpl_context as c, url, config
34 from pylons.controllers.util import redirect
35 from pylons.i18n.translation import _
34 from pylons.i18n.translation import _
36 from sqlalchemy.sql.expression import func
35 from sqlalchemy.sql.expression import func
37 from webob.exc import HTTPNotFound
36 from webob.exc import HTTPFound, HTTPNotFound
38
37
39 import kallithea
38 import kallithea
40 from kallithea.lib.exceptions import DefaultUserException, \
39 from kallithea.lib.exceptions import DefaultUserException, \
@@ -148,7 +147,7 b' class UsersController(BaseController):'
148 log.error(traceback.format_exc())
147 log.error(traceback.format_exc())
149 h.flash(_('Error occurred during creation of user %s') \
148 h.flash(_('Error occurred during creation of user %s') \
150 % request.POST.get('username'), category='error')
149 % request.POST.get('username'), category='error')
151 return redirect(url('users'))
150 raise HTTPFound(location=url('users'))
152
151
153 def new(self, format='html'):
152 def new(self, format='html'):
154 """GET /users/new: Form to create a new item"""
153 """GET /users/new: Form to create a new item"""
@@ -201,7 +200,7 b' class UsersController(BaseController):'
201 log.error(traceback.format_exc())
200 log.error(traceback.format_exc())
202 h.flash(_('Error occurred during update of user %s') \
201 h.flash(_('Error occurred during update of user %s') \
203 % form_result.get('username'), category='error')
202 % form_result.get('username'), category='error')
204 return redirect(url('edit_user', id=id))
203 raise HTTPFound(location=url('edit_user', id=id))
205
204
206 def delete(self, id):
205 def delete(self, id):
207 """DELETE /users/id: Delete an existing item"""
206 """DELETE /users/id: Delete an existing item"""
@@ -222,7 +221,7 b' class UsersController(BaseController):'
222 log.error(traceback.format_exc())
221 log.error(traceback.format_exc())
223 h.flash(_('An error occurred during deletion of user'),
222 h.flash(_('An error occurred during deletion of user'),
224 category='error')
223 category='error')
225 return redirect(url('users'))
224 raise HTTPFound(location=url('users'))
226
225
227 def show(self, id, format='html'):
226 def show(self, id, format='html'):
228 """GET /users/id: Show a specific item"""
227 """GET /users/id: Show a specific item"""
@@ -306,7 +305,7 b' class UsersController(BaseController):'
306 ApiKeyModel().create(c.user.user_id, description, lifetime)
305 ApiKeyModel().create(c.user.user_id, description, lifetime)
307 Session().commit()
306 Session().commit()
308 h.flash(_("API key successfully created"), category='success')
307 h.flash(_("API key successfully created"), category='success')
309 return redirect(url('edit_user_api_keys', id=c.user.user_id))
308 raise HTTPFound(location=url('edit_user_api_keys', id=c.user.user_id))
310
309
311 def delete_api_key(self, id):
310 def delete_api_key(self, id):
312 c.user = self._get_user_or_raise_if_default(id)
311 c.user = self._get_user_or_raise_if_default(id)
@@ -324,7 +323,7 b' class UsersController(BaseController):'
324 Session().commit()
323 Session().commit()
325 h.flash(_("API key successfully deleted"), category='success')
324 h.flash(_("API key successfully deleted"), category='success')
326
325
327 return redirect(url('edit_user_api_keys', id=c.user.user_id))
326 raise HTTPFound(location=url('edit_user_api_keys', id=c.user.user_id))
328
327
329 def update_account(self, id):
328 def update_account(self, id):
330 pass
329 pass
@@ -387,7 +386,7 b' class UsersController(BaseController):'
387 log.error(traceback.format_exc())
386 log.error(traceback.format_exc())
388 h.flash(_('An error occurred during permissions saving'),
387 h.flash(_('An error occurred during permissions saving'),
389 category='error')
388 category='error')
390 return redirect(url('edit_user_perms', id=id))
389 raise HTTPFound(location=url('edit_user_perms', id=id))
391
390
392 def edit_emails(self, id):
391 def edit_emails(self, id):
393 c.user = self._get_user_or_raise_if_default(id)
392 c.user = self._get_user_or_raise_if_default(id)
@@ -420,7 +419,7 b' class UsersController(BaseController):'
420 log.error(traceback.format_exc())
419 log.error(traceback.format_exc())
421 h.flash(_('An error occurred during email saving'),
420 h.flash(_('An error occurred during email saving'),
422 category='error')
421 category='error')
423 return redirect(url('edit_user_emails', id=id))
422 raise HTTPFound(location=url('edit_user_emails', id=id))
424
423
425 def delete_email(self, id):
424 def delete_email(self, id):
426 """DELETE /user_emails_delete/id: Delete an existing item"""
425 """DELETE /user_emails_delete/id: Delete an existing item"""
@@ -431,7 +430,7 b' class UsersController(BaseController):'
431 user_model.delete_extra_email(id, email_id)
430 user_model.delete_extra_email(id, email_id)
432 Session().commit()
431 Session().commit()
433 h.flash(_("Removed email from user"), category='success')
432 h.flash(_("Removed email from user"), category='success')
434 return redirect(url('edit_user_emails', id=id))
433 raise HTTPFound(location=url('edit_user_emails', id=id))
435
434
436 def edit_ips(self, id):
435 def edit_ips(self, id):
437 c.user = self._get_user_or_raise_if_default(id)
436 c.user = self._get_user_or_raise_if_default(id)
@@ -470,8 +469,8 b' class UsersController(BaseController):'
470 category='error')
469 category='error')
471
470
472 if 'default_user' in request.POST:
471 if 'default_user' in request.POST:
473 return redirect(url('admin_permissions_ips'))
472 raise HTTPFound(location=url('admin_permissions_ips'))
474 return redirect(url('edit_user_ips', id=id))
473 raise HTTPFound(location=url('edit_user_ips', id=id))
475
474
476 def delete_ip(self, id):
475 def delete_ip(self, id):
477 """DELETE /user_ips_delete/id: Delete an existing item"""
476 """DELETE /user_ips_delete/id: Delete an existing item"""
@@ -483,5 +482,5 b' class UsersController(BaseController):'
483 h.flash(_("Removed IP address from user whitelist"), category='success')
482 h.flash(_("Removed IP address from user whitelist"), category='success')
484
483
485 if 'default_user' in request.POST:
484 if 'default_user' in request.POST:
486 return redirect(url('admin_permissions_ips'))
485 raise HTTPFound(location=url('admin_permissions_ips'))
487 return redirect(url('edit_user_ips', id=id))
486 raise HTTPFound(location=url('edit_user_ips', id=id))
@@ -29,9 +29,8 b' import logging'
29 import traceback
29 import traceback
30
30
31 from pylons import request, url, session, tmpl_context as c
31 from pylons import request, url, session, tmpl_context as c
32 from pylons.controllers.util import redirect
33 from pylons.i18n.translation import _
32 from pylons.i18n.translation import _
34 from webob.exc import HTTPNotFound, HTTPBadRequest
33 from webob.exc import HTTPFound, HTTPNotFound, HTTPBadRequest
35
34
36 import kallithea.lib.helpers as h
35 import kallithea.lib.helpers as h
37 from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
36 from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
@@ -99,8 +98,8 b' class ChangelogController(BaseRepoContro'
99 if request.GET.get('set'):
98 if request.GET.get('set'):
100 request.GET.pop('set', None)
99 request.GET.pop('set', None)
101 if revision is None:
100 if revision is None:
102 return redirect(url('changelog_home', repo_name=repo_name, **request.GET))
101 raise HTTPFound(location=url('changelog_home', repo_name=repo_name, **request.GET))
103 return redirect(url('changelog_file_home', repo_name=repo_name, revision=revision, f_path=f_path, **request.GET))
102 raise HTTPFound(location=url('changelog_file_home', repo_name=repo_name, revision=revision, f_path=f_path, **request.GET))
104
103
105 limit = 2000
104 limit = 2000
106 default = 100
105 default = 100
@@ -118,7 +117,7 b' class ChangelogController(BaseRepoContro'
118 branch_name not in c.db_repo_scm_instance.branches and
117 branch_name not in c.db_repo_scm_instance.branches and
119 branch_name not in c.db_repo_scm_instance.closed_branches and
118 branch_name not in c.db_repo_scm_instance.closed_branches and
120 not revision):
119 not revision):
121 return redirect(url('changelog_file_home', repo_name=c.repo_name,
120 raise HTTPFound(location=url('changelog_file_home', repo_name=c.repo_name,
122 revision=branch_name, f_path=f_path or ''))
121 revision=branch_name, f_path=f_path or ''))
123
122
124 if revision == 'tip':
123 if revision == 'tip':
@@ -140,7 +139,7 b' class ChangelogController(BaseRepoContro'
140 collection = cs.get_file_history(f_path)
139 collection = cs.get_file_history(f_path)
141 except RepositoryError as e:
140 except RepositoryError as e:
142 h.flash(safe_str(e), category='warning')
141 h.flash(safe_str(e), category='warning')
143 redirect(h.url('changelog_home', repo_name=repo_name))
142 raise HTTPFound(location=h.url('changelog_home', repo_name=repo_name))
144 collection = list(reversed(collection))
143 collection = list(reversed(collection))
145 else:
144 else:
146 collection = c.db_repo_scm_instance.get_changesets(start=0, end=revision,
145 collection = c.db_repo_scm_instance.get_changesets(start=0, end=revision,
@@ -155,11 +154,11 b' class ChangelogController(BaseRepoContro'
155 c.statuses = c.db_repo.statuses(page_revisions)
154 c.statuses = c.db_repo.statuses(page_revisions)
156 except EmptyRepositoryError as e:
155 except EmptyRepositoryError as e:
157 h.flash(safe_str(e), category='warning')
156 h.flash(safe_str(e), category='warning')
158 return redirect(url('summary_home', repo_name=c.repo_name))
157 raise HTTPFound(location=url('summary_home', repo_name=c.repo_name))
159 except (RepositoryError, ChangesetDoesNotExistError, Exception) as e:
158 except (RepositoryError, ChangesetDoesNotExistError, Exception) as e:
160 log.error(traceback.format_exc())
159 log.error(traceback.format_exc())
161 h.flash(safe_str(e), category='error')
160 h.flash(safe_str(e), category='error')
162 return redirect(url('changelog_home', repo_name=c.repo_name))
161 raise HTTPFound(location=url('changelog_home', repo_name=c.repo_name))
163
162
164 c.branch_name = branch_name
163 c.branch_name = branch_name
165 c.branch_filters = [('', _('None'))] + \
164 c.branch_filters = [('', _('None'))] + \
@@ -29,13 +29,12 b' Original author and date, and relevant c'
29 import logging
29 import logging
30 import traceback
30 import traceback
31 from collections import defaultdict
31 from collections import defaultdict
32 from webob.exc import HTTPForbidden, HTTPBadRequest, HTTPNotFound
33
32
34 from pylons import tmpl_context as c, request, response
33 from pylons import tmpl_context as c, request, response
35 from pylons.i18n.translation import _
34 from pylons.i18n.translation import _
36 from pylons.controllers.util import redirect
35 from webob.exc import HTTPFound, HTTPForbidden, HTTPBadRequest, HTTPNotFound
36
37 from kallithea.lib.utils import jsonify
37 from kallithea.lib.utils import jsonify
38
39 from kallithea.lib.vcs.exceptions import RepositoryError, \
38 from kallithea.lib.vcs.exceptions import RepositoryError, \
40 ChangesetDoesNotExistError
39 ChangesetDoesNotExistError
41
40
@@ -383,7 +382,7 b' class ChangesetController(BaseRepoContro'
383 msg = _('Changing status on a changeset associated with '
382 msg = _('Changing status on a changeset associated with '
384 'a closed pull request is not allowed')
383 'a closed pull request is not allowed')
385 h.flash(msg, category='warning')
384 h.flash(msg, category='warning')
386 return redirect(h.url('changeset_home', repo_name=repo_name,
385 raise HTTPFound(location=h.url('changeset_home', repo_name=repo_name,
387 revision=revision))
386 revision=revision))
388 action_logger(self.authuser,
387 action_logger(self.authuser,
389 'user_commented_revision:%s' % revision,
388 'user_commented_revision:%s' % revision,
@@ -392,7 +391,7 b' class ChangesetController(BaseRepoContro'
392 Session().commit()
391 Session().commit()
393
392
394 if not request.environ.get('HTTP_X_PARTIAL_XHR'):
393 if not request.environ.get('HTTP_X_PARTIAL_XHR'):
395 return redirect(h.url('changeset_home', repo_name=repo_name,
394 raise HTTPFound(location=h.url('changeset_home', repo_name=repo_name,
396 revision=revision))
395 revision=revision))
397 #only ajax below
396 #only ajax below
398 data = {
397 data = {
@@ -30,10 +30,9 b' Original author and date, and relevant c'
30 import logging
30 import logging
31 import re
31 import re
32
32
33 from webob.exc import HTTPBadRequest
34 from pylons import request, tmpl_context as c, url
33 from pylons import request, tmpl_context as c, url
35 from pylons.controllers.util import redirect
36 from pylons.i18n.translation import _
34 from pylons.i18n.translation import _
35 from webob.exc import HTTPFound, HTTPBadRequest
37
36
38 from kallithea.lib.utils2 import safe_str
37 from kallithea.lib.utils2 import safe_str
39 from kallithea.lib.vcs.utils.hgcompat import unionrepo
38 from kallithea.lib.vcs.utils.hgcompat import unionrepo
@@ -207,19 +206,19 b' class CompareController(BaseRepoControll'
207 msg = 'Could not find org repo %s' % org_repo
206 msg = 'Could not find org repo %s' % org_repo
208 log.error(msg)
207 log.error(msg)
209 h.flash(msg, category='error')
208 h.flash(msg, category='error')
210 return redirect(url('compare_home', repo_name=c.repo_name))
209 raise HTTPFound(location=url('compare_home', repo_name=c.repo_name))
211
210
212 if other_repo is None:
211 if other_repo is None:
213 msg = 'Could not find other repo %s' % other_repo
212 msg = 'Could not find other repo %s' % other_repo
214 log.error(msg)
213 log.error(msg)
215 h.flash(msg, category='error')
214 h.flash(msg, category='error')
216 return redirect(url('compare_home', repo_name=c.repo_name))
215 raise HTTPFound(location=url('compare_home', repo_name=c.repo_name))
217
216
218 if org_repo.scm_instance.alias != other_repo.scm_instance.alias:
217 if org_repo.scm_instance.alias != other_repo.scm_instance.alias:
219 msg = 'compare of two different kind of remote repos not available'
218 msg = 'compare of two different kind of remote repos not available'
220 log.error(msg)
219 log.error(msg)
221 h.flash(msg, category='error')
220 h.flash(msg, category='error')
222 return redirect(url('compare_home', repo_name=c.repo_name))
221 raise HTTPFound(location=url('compare_home', repo_name=c.repo_name))
223
222
224 c.a_rev = self._get_ref_rev(org_repo, org_ref_type, org_ref_name,
223 c.a_rev = self._get_ref_rev(org_repo, org_ref_type, org_ref_name,
225 returnempty=True)
224 returnempty=True)
@@ -33,9 +33,9 b' import shutil'
33
33
34 from pylons import request, response, tmpl_context as c, url
34 from pylons import request, response, tmpl_context as c, url
35 from pylons.i18n.translation import _
35 from pylons.i18n.translation import _
36 from pylons.controllers.util import redirect
36 from webob.exc import HTTPFound
37
37 from kallithea.lib.utils import jsonify, action_logger
38 from kallithea.lib.utils import jsonify, action_logger
38
39 from kallithea.lib import diffs
39 from kallithea.lib import diffs
40 from kallithea.lib import helpers as h
40 from kallithea.lib import helpers as h
41
41
@@ -306,7 +306,7 b' class FilesController(BaseRepoController'
306 % (h.person_by_id(repo.locked[0]),
306 % (h.person_by_id(repo.locked[0]),
307 h.fmt_date(h.time_to_datetime(repo.locked[1]))),
307 h.fmt_date(h.time_to_datetime(repo.locked[1]))),
308 'warning')
308 'warning')
309 return redirect(h.url('files_home',
309 raise HTTPFound(location=h.url('files_home',
310 repo_name=repo_name, revision='tip'))
310 repo_name=repo_name, revision='tip'))
311
311
312 # check if revision is a branch identifier- basically we cannot
312 # check if revision is a branch identifier- basically we cannot
@@ -316,7 +316,7 b' class FilesController(BaseRepoController'
316 if revision not in _branches.keys() + _branches.values():
316 if revision not in _branches.keys() + _branches.values():
317 h.flash(_('You can only delete files with revision '
317 h.flash(_('You can only delete files with revision '
318 'being a valid branch '), category='warning')
318 'being a valid branch '), category='warning')
319 return redirect(h.url('files_home',
319 raise HTTPFound(location=h.url('files_home',
320 repo_name=repo_name, revision='tip',
320 repo_name=repo_name, revision='tip',
321 f_path=f_path))
321 f_path=f_path))
322
322
@@ -352,7 +352,7 b' class FilesController(BaseRepoController'
352 except Exception:
352 except Exception:
353 log.error(traceback.format_exc())
353 log.error(traceback.format_exc())
354 h.flash(_('Error occurred during commit'), category='error')
354 h.flash(_('Error occurred during commit'), category='error')
355 return redirect(url('changeset_home',
355 raise HTTPFound(location=url('changeset_home',
356 repo_name=c.repo_name, revision='tip'))
356 repo_name=c.repo_name, revision='tip'))
357
357
358 return render('files/files_delete.html')
358 return render('files/files_delete.html')
@@ -366,7 +366,7 b' class FilesController(BaseRepoController'
366 % (h.person_by_id(repo.locked[0]),
366 % (h.person_by_id(repo.locked[0]),
367 h.fmt_date(h.time_to_datetime(repo.locked[1]))),
367 h.fmt_date(h.time_to_datetime(repo.locked[1]))),
368 'warning')
368 'warning')
369 return redirect(h.url('files_home',
369 raise HTTPFound(location=h.url('files_home',
370 repo_name=repo_name, revision='tip'))
370 repo_name=repo_name, revision='tip'))
371
371
372 # check if revision is a branch identifier- basically we cannot
372 # check if revision is a branch identifier- basically we cannot
@@ -376,7 +376,7 b' class FilesController(BaseRepoController'
376 if revision not in _branches.keys() + _branches.values():
376 if revision not in _branches.keys() + _branches.values():
377 h.flash(_('You can only edit files with revision '
377 h.flash(_('You can only edit files with revision '
378 'being a valid branch '), category='warning')
378 'being a valid branch '), category='warning')
379 return redirect(h.url('files_home',
379 raise HTTPFound(location=h.url('files_home',
380 repo_name=repo_name, revision='tip',
380 repo_name=repo_name, revision='tip',
381 f_path=f_path))
381 f_path=f_path))
382
382
@@ -386,7 +386,7 b' class FilesController(BaseRepoController'
386 c.file = self.__get_filenode(c.cs, f_path)
386 c.file = self.__get_filenode(c.cs, f_path)
387
387
388 if c.file.is_binary:
388 if c.file.is_binary:
389 return redirect(url('files_home', repo_name=c.repo_name,
389 raise HTTPFound(location=url('files_home', repo_name=c.repo_name,
390 revision=c.cs.raw_id, f_path=f_path))
390 revision=c.cs.raw_id, f_path=f_path))
391 c.default_message = _('Edited file %s via Kallithea') % (f_path)
391 c.default_message = _('Edited file %s via Kallithea') % (f_path)
392 c.f_path = f_path
392 c.f_path = f_path
@@ -405,7 +405,7 b' class FilesController(BaseRepoController'
405
405
406 if content == old_content:
406 if content == old_content:
407 h.flash(_('No changes'), category='warning')
407 h.flash(_('No changes'), category='warning')
408 return redirect(url('changeset_home', repo_name=c.repo_name,
408 raise HTTPFound(location=url('changeset_home', repo_name=c.repo_name,
409 revision='tip'))
409 revision='tip'))
410 try:
410 try:
411 self.scm_model.commit_change(repo=c.db_repo_scm_instance,
411 self.scm_model.commit_change(repo=c.db_repo_scm_instance,
@@ -418,7 +418,7 b' class FilesController(BaseRepoController'
418 except Exception:
418 except Exception:
419 log.error(traceback.format_exc())
419 log.error(traceback.format_exc())
420 h.flash(_('Error occurred during commit'), category='error')
420 h.flash(_('Error occurred during commit'), category='error')
421 return redirect(url('changeset_home',
421 raise HTTPFound(location=url('changeset_home',
422 repo_name=c.repo_name, revision='tip'))
422 repo_name=c.repo_name, revision='tip'))
423
423
424 return render('files/files_edit.html')
424 return render('files/files_edit.html')
@@ -433,7 +433,7 b' class FilesController(BaseRepoController'
433 % (h.person_by_id(repo.locked[0]),
433 % (h.person_by_id(repo.locked[0]),
434 h.fmt_date(h.time_to_datetime(repo.locked[1]))),
434 h.fmt_date(h.time_to_datetime(repo.locked[1]))),
435 'warning')
435 'warning')
436 return redirect(h.url('files_home',
436 raise HTTPFound(location=h.url('files_home',
437 repo_name=repo_name, revision='tip'))
437 repo_name=repo_name, revision='tip'))
438
438
439 r_post = request.POST
439 r_post = request.POST
@@ -462,11 +462,11 b' class FilesController(BaseRepoController'
462
462
463 if not content:
463 if not content:
464 h.flash(_('No content'), category='warning')
464 h.flash(_('No content'), category='warning')
465 return redirect(url('changeset_home', repo_name=c.repo_name,
465 raise HTTPFound(location=url('changeset_home', repo_name=c.repo_name,
466 revision='tip'))
466 revision='tip'))
467 if not filename:
467 if not filename:
468 h.flash(_('No filename'), category='warning')
468 h.flash(_('No filename'), category='warning')
469 return redirect(url('changeset_home', repo_name=c.repo_name,
469 raise HTTPFound(location=url('changeset_home', repo_name=c.repo_name,
470 revision='tip'))
470 revision='tip'))
471 #strip all crap out of file, just leave the basename
471 #strip all crap out of file, just leave the basename
472 filename = os.path.basename(filename)
472 filename = os.path.basename(filename)
@@ -492,14 +492,14 b' class FilesController(BaseRepoController'
492 except NonRelativePathError as e:
492 except NonRelativePathError as e:
493 h.flash(_('Location must be relative path and must not '
493 h.flash(_('Location must be relative path and must not '
494 'contain .. in path'), category='warning')
494 'contain .. in path'), category='warning')
495 return redirect(url('changeset_home', repo_name=c.repo_name,
495 raise HTTPFound(location=url('changeset_home', repo_name=c.repo_name,
496 revision='tip'))
496 revision='tip'))
497 except (NodeError, NodeAlreadyExistsError) as e:
497 except (NodeError, NodeAlreadyExistsError) as e:
498 h.flash(_(e), category='error')
498 h.flash(_(e), category='error')
499 except Exception:
499 except Exception:
500 log.error(traceback.format_exc())
500 log.error(traceback.format_exc())
501 h.flash(_('Error occurred during commit'), category='error')
501 h.flash(_('Error occurred during commit'), category='error')
502 return redirect(url('changeset_home',
502 raise HTTPFound(location=url('changeset_home',
503 repo_name=c.repo_name, revision='tip'))
503 repo_name=c.repo_name, revision='tip'))
504
504
505 return render('files/files_add.html')
505 return render('files/files_add.html')
@@ -620,7 +620,7 b' class FilesController(BaseRepoController'
620 _url = url('files_home', repo_name=c.repo_name,
620 _url = url('files_home', repo_name=c.repo_name,
621 revision=diff1, f_path=c.f_path)
621 revision=diff1, f_path=c.f_path)
622
622
623 return redirect(_url)
623 raise HTTPFound(location=_url)
624 try:
624 try:
625 if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]:
625 if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]:
626 c.changeset_1 = c.db_repo_scm_instance.get_changeset(diff1)
626 c.changeset_1 = c.db_repo_scm_instance.get_changeset(diff1)
@@ -655,7 +655,7 b' class FilesController(BaseRepoController'
655 node2 = FileNode(f_path, '', changeset=c.changeset_2)
655 node2 = FileNode(f_path, '', changeset=c.changeset_2)
656 except (RepositoryError, NodeError):
656 except (RepositoryError, NodeError):
657 log.error(traceback.format_exc())
657 log.error(traceback.format_exc())
658 return redirect(url('files_home', repo_name=c.repo_name,
658 raise HTTPFound(location=url('files_home', repo_name=c.repo_name,
659 f_path=f_path))
659 f_path=f_path))
660
660
661 if c.action == 'download':
661 if c.action == 'download':
@@ -31,8 +31,8 b' import traceback'
31 from formencode import htmlfill
31 from formencode import htmlfill
32
32
33 from pylons import tmpl_context as c, request, url
33 from pylons import tmpl_context as c, request, url
34 from pylons.controllers.util import redirect
35 from pylons.i18n.translation import _
34 from pylons.i18n.translation import _
35 from webob.exc import HTTPFound
36
36
37 import kallithea.lib.helpers as h
37 import kallithea.lib.helpers as h
38
38
@@ -77,7 +77,7 b' class ForksController(BaseRepoController'
77
77
78 if c.repo_info is None:
78 if c.repo_info is None:
79 h.not_mapped_error(repo_name)
79 h.not_mapped_error(repo_name)
80 return redirect(url('repos'))
80 raise HTTPFound(location=url('repos'))
81
81
82 c.default_user_id = User.get_default_user().user_id
82 c.default_user_id = User.get_default_user().user_id
83 c.in_public_journal = UserFollowing.query()\
83 c.in_public_journal = UserFollowing.query()\
@@ -137,7 +137,7 b' class ForksController(BaseRepoController'
137 c.repo_info = Repository.get_by_repo_name(repo_name)
137 c.repo_info = Repository.get_by_repo_name(repo_name)
138 if not c.repo_info:
138 if not c.repo_info:
139 h.not_mapped_error(repo_name)
139 h.not_mapped_error(repo_name)
140 return redirect(url('home'))
140 raise HTTPFound(location=url('home'))
141
141
142 defaults = self.__load_data(repo_name)
142 defaults = self.__load_data(repo_name)
143
143
@@ -186,6 +186,6 b' class ForksController(BaseRepoController'
186 h.flash(_('An error occurred during repository forking %s') %
186 h.flash(_('An error occurred during repository forking %s') %
187 repo_name, category='error')
187 repo_name, category='error')
188
188
189 return redirect(h.url('repo_creating_home',
189 raise HTTPFound(location=h.url('repo_creating_home',
190 repo_name=form_result['repo_name_full'],
190 repo_name=form_result['repo_name_full'],
191 task_id=task_id))
191 task_id=task_id))
@@ -31,10 +31,9 b' import re'
31 import formencode
31 import formencode
32
32
33 from formencode import htmlfill
33 from formencode import htmlfill
34 from pylons.i18n.translation import _
35 from pylons import request, session, tmpl_context as c, url
34 from webob.exc import HTTPFound, HTTPBadRequest
36 from webob.exc import HTTPFound, HTTPBadRequest
35 from pylons.i18n.translation import _
36 from pylons.controllers.util import redirect
37 from pylons import request, session, tmpl_context as c, url
38
37
39 import kallithea.lib.helpers as h
38 import kallithea.lib.helpers as h
40 from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator
39 from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator
@@ -152,7 +151,7 b' class LoginController(BaseController):'
152 h.flash(_('You have successfully registered into Kallithea'),
151 h.flash(_('You have successfully registered into Kallithea'),
153 category='success')
152 category='success')
154 Session().commit()
153 Session().commit()
155 return redirect(url('login_home'))
154 raise HTTPFound(location=url('login_home'))
156
155
157 except formencode.Invalid as errors:
156 except formencode.Invalid as errors:
158 return htmlfill.render(
157 return htmlfill.render(
@@ -196,7 +195,7 b' class LoginController(BaseController):'
196 redirect_link = UserModel().send_reset_password_email(form_result)
195 redirect_link = UserModel().send_reset_password_email(form_result)
197 h.flash(_('A password reset confirmation code has been sent'),
196 h.flash(_('A password reset confirmation code has been sent'),
198 category='success')
197 category='success')
199 return redirect(redirect_link)
198 raise HTTPFound(location=redirect_link)
200
199
201 except formencode.Invalid as errors:
200 except formencode.Invalid as errors:
202 return htmlfill.render(
201 return htmlfill.render(
@@ -249,12 +248,12 b' class LoginController(BaseController):'
249
248
250 UserModel().reset_password(form_result['email'], form_result['password'])
249 UserModel().reset_password(form_result['email'], form_result['password'])
251 h.flash(_('Successfully updated password'), category='success')
250 h.flash(_('Successfully updated password'), category='success')
252 return redirect(url('login_home'))
251 raise HTTPFound(location=url('login_home'))
253
252
254 def logout(self):
253 def logout(self):
255 session.delete()
254 session.delete()
256 log.info('Logging out and deleting session for user')
255 log.info('Logging out and deleting session for user')
257 redirect(url('home'))
256 raise HTTPFound(location=url('home'))
258
257
259 def authentication_token(self):
258 def authentication_token(self):
260 """Return the CSRF protection token for the session - just like it
259 """Return the CSRF protection token for the session - just like it
@@ -30,11 +30,9 b' import traceback'
30 import formencode
30 import formencode
31 import re
31 import re
32
32
33 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPBadRequest
34
35 from pylons import request, tmpl_context as c, url
33 from pylons import request, tmpl_context as c, url
36 from pylons.controllers.util import redirect
37 from pylons.i18n.translation import _
34 from pylons.i18n.translation import _
35 from webob.exc import HTTPFound, HTTPNotFound, HTTPForbidden, HTTPBadRequest
38
36
39 from kallithea.lib.vcs.utils.hgcompat import unionrepo
37 from kallithea.lib.vcs.utils.hgcompat import unionrepo
40 from kallithea.lib.compat import json
38 from kallithea.lib.compat import json
@@ -237,7 +235,7 b' class PullrequestsController(BaseRepoCon'
237 except EmptyRepositoryError as e:
235 except EmptyRepositoryError as e:
238 h.flash(h.literal(_('There are no changesets yet')),
236 h.flash(h.literal(_('There are no changesets yet')),
239 category='warning')
237 category='warning')
240 redirect(url('summary_home', repo_name=org_repo.repo_name))
238 raise HTTPFound(location=url('summary_home', repo_name=org_repo.repo_name))
241
239
242 org_rev = request.GET.get('rev_end')
240 org_rev = request.GET.get('rev_end')
243 # rev_start is not directly useful - its parent could however be used
241 # rev_start is not directly useful - its parent could however be used
@@ -369,9 +367,9 b' class PullrequestsController(BaseRepoCon'
369 h.flash(_('Error occurred while creating pull request'),
367 h.flash(_('Error occurred while creating pull request'),
370 category='error')
368 category='error')
371 log.error(traceback.format_exc())
369 log.error(traceback.format_exc())
372 return redirect(url('pullrequest_home', repo_name=repo_name))
370 raise HTTPFound(location=url('pullrequest_home', repo_name=repo_name))
373
371
374 return redirect(pull_request.url())
372 raise HTTPFound(location=pull_request.url())
375
373
376 def create_update(self, old_pull_request, updaterev, title, description, reviewers_ids):
374 def create_update(self, old_pull_request, updaterev, title, description, reviewers_ids):
377 org_repo = RepoModel()._get_repo(old_pull_request.org_repo.repo_name)
375 org_repo = RepoModel()._get_repo(old_pull_request.org_repo.repo_name)
@@ -456,7 +454,7 b' class PullrequestsController(BaseRepoCon'
456 h.flash(_('Error occurred while creating pull request'),
454 h.flash(_('Error occurred while creating pull request'),
457 category='error')
455 category='error')
458 log.error(traceback.format_exc())
456 log.error(traceback.format_exc())
459 return redirect(old_pull_request.url())
457 raise HTTPFound(location=old_pull_request.url())
460
458
461 ChangesetCommentsModel().create(
459 ChangesetCommentsModel().create(
462 text=_('Closed, replaced by %s .') % pull_request.url(canonical=True),
460 text=_('Closed, replaced by %s .') % pull_request.url(canonical=True),
@@ -470,7 +468,7 b' class PullrequestsController(BaseRepoCon'
470 h.flash(_('Pull request update created'),
468 h.flash(_('Pull request update created'),
471 category='success')
469 category='success')
472
470
473 return redirect(pull_request.url())
471 raise HTTPFound(location=pull_request.url())
474
472
475 # pullrequest_post for PR editing
473 # pullrequest_post for PR editing
476 @LoginRequired()
474 @LoginRequired()
@@ -513,7 +511,7 b' class PullrequestsController(BaseRepoCon'
513 Session().commit()
511 Session().commit()
514 h.flash(_('Pull request updated'), category='success')
512 h.flash(_('Pull request updated'), category='success')
515
513
516 return redirect(pull_request.url())
514 raise HTTPFound(location=pull_request.url())
517
515
518 @LoginRequired()
516 @LoginRequired()
519 @NotAnonymous()
517 @NotAnonymous()
@@ -528,7 +526,7 b' class PullrequestsController(BaseRepoCon'
528 Session().commit()
526 Session().commit()
529 h.flash(_('Successfully deleted pull request'),
527 h.flash(_('Successfully deleted pull request'),
530 category='success')
528 category='success')
531 return redirect(url('my_pullrequests'))
529 raise HTTPFound(location=url('my_pullrequests'))
532 raise HTTPForbidden()
530 raise HTTPForbidden()
533
531
534 @LoginRequired()
532 @LoginRequired()
@@ -762,7 +760,7 b' class PullrequestsController(BaseRepoCon'
762 Session().commit()
760 Session().commit()
763
761
764 if not request.environ.get('HTTP_X_PARTIAL_XHR'):
762 if not request.environ.get('HTTP_X_PARTIAL_XHR'):
765 return redirect(pull_request.url())
763 raise HTTPFound(location=pull_request.url())
766
764
767 data = {
765 data = {
768 'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))),
766 'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))),
@@ -35,13 +35,12 b' import collections'
35 from decorator import decorator
35 from decorator import decorator
36
36
37 from pylons import url, request, session
37 from pylons import url, request, session
38 from pylons.controllers.util import redirect
39 from pylons.i18n.translation import _
38 from pylons.i18n.translation import _
40 from webhelpers.pylonslib import secure_form
39 from webhelpers.pylonslib import secure_form
41 from sqlalchemy import or_
40 from sqlalchemy import or_
42 from sqlalchemy.orm.exc import ObjectDeletedError
41 from sqlalchemy.orm.exc import ObjectDeletedError
43 from sqlalchemy.orm import joinedload
42 from sqlalchemy.orm import joinedload
44 from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPMethodNotAllowed
43 from webob.exc import HTTPFound, HTTPBadRequest, HTTPForbidden, HTTPMethodNotAllowed
45
44
46 from kallithea import __platform__, is_windows, is_unix
45 from kallithea import __platform__, is_windows, is_unix
47 from kallithea.lib.vcs.utils.lazy import LazyProperty
46 from kallithea.lib.vcs.utils.lazy import LazyProperty
@@ -717,7 +716,7 b' def redirect_to_login(message=None):'
717 if message:
716 if message:
718 h.flash(h.literal(message), category='warning')
717 h.flash(h.literal(message), category='warning')
719 log.debug('Redirecting to login page, origin: %s', p)
718 log.debug('Redirecting to login page, origin: %s', p)
720 return redirect(url('login_home', came_from=p))
719 raise HTTPFound(location=url('login_home', came_from=p))
721
720
722
721
723 class LoginRequired(object):
722 class LoginRequired(object):
@@ -40,7 +40,6 b' import paste.httpheaders'
40
40
41 from pylons import config, tmpl_context as c, request, session, url
41 from pylons import config, tmpl_context as c, request, session, url
42 from pylons.controllers import WSGIController
42 from pylons.controllers import WSGIController
43 from pylons.controllers.util import redirect
44 from pylons.templating import render_mako as render # don't remove this import
43 from pylons.templating import render_mako as render # don't remove this import
45 from pylons.i18n.translation import _
44 from pylons.i18n.translation import _
46
45
@@ -479,7 +478,7 b' class BaseRepoController(BaseController)'
479 if route in ['repo_creating_home']:
478 if route in ['repo_creating_home']:
480 return
479 return
481 check_url = url('repo_creating_home', repo_name=c.repo_name)
480 check_url = url('repo_creating_home', repo_name=c.repo_name)
482 return redirect(check_url)
481 raise webob.exc.HTTPFound(location=check_url)
483
482
484 dbr = c.db_repo = _dbr
483 dbr = c.db_repo = _dbr
485 c.db_repo_scm_instance = c.db_repo.scm_instance
484 c.db_repo_scm_instance = c.db_repo.scm_instance
General Comments 0
You need to be logged in to leave comments. Login now