def users_rename(request): user = _form_request_user(request) old_username = user.username new_username = request.params.get('new_username').strip() try: svc = request.find_service(name='rename_user') svc.check(user, new_username) rename_user.delay(user.id, new_username) request.session.flash( 'The user "%s" will be renamed to "%s" in the backgroud. Refresh this page to see if it\'s already done' % (old_username, new_username), 'success') return httpexceptions.HTTPFound( location=request.route_path('admin_users', _query=(('username', new_username), ('authority', user.authority)))) except (UserRenameError, ValueError) as e: request.session.flash(str(e), 'error') return httpexceptions.HTTPFound( location=request.route_path('admin_users', _query=(('username', old_username), ('authority', user.authority))))
def users_rename(request): user = _form_request_user(request) old_username = user.username new_username = request.params.get('new_username').strip() try: svc = request.find_service(name='rename_user') svc.check(user, new_username) rename_user.delay(user.id, new_username) request.session.flash( 'The user "%s" will be renamed to "%s" in the backgroud. Refresh this page to see if it\'s already done' % (old_username, new_username), 'success') return httpexceptions.HTTPFound( location=request.route_path('admin_users', _query=(('username', new_username), ('authority', user.authority)))) except (UserRenameError, ValueError) as e: request.session.flash(str(e), 'error') return httpexceptions.HTTPFound( location=request.route_path('admin_users', _query=(('username', old_username), ('authority', user.authority))))