# HG changeset patch # User Mads Kiilerich # Date 1473115878 -7200 # Node ID 9b80c2a647815bbec289b0b932e9f1a375f100c8 # Parent e8bd3f074b4edef3b3640683d2a5a855f40acd48 admin: don't redirect back to the list of users after creating a user Staying on the user page gives a more natural flow, instead of having to click the link in the 'Created' flash message to get back to the user. diff -r e8bd3f074b4e -r 9b80c2a64781 kallithea/controllers/admin/users.py --- a/kallithea/controllers/admin/users.py Tue Sep 06 00:51:18 2016 +0200 +++ b/kallithea/controllers/admin/users.py Tue Sep 06 00:51:18 2016 +0200 @@ -122,10 +122,9 @@ try: form_result = user_form.to_python(dict(request.POST)) user = user_model.create(form_result) - usr = form_result['username'] - action_logger(self.authuser, 'admin_created_user:%s' % usr, + action_logger(self.authuser, 'admin_created_user:%s' % user.username, None, self.ip_addr, self.sa) - h.flash(h.literal(_('Created user %s') % h.link_to(h.escape(usr), url('edit_user', id=user.user_id))), + h.flash(_('Created user %s') % user.username, category='success') Session().commit() except formencode.Invalid as errors: @@ -142,7 +141,7 @@ log.error(traceback.format_exc()) h.flash(_('Error occurred during creation of user %s') \ % request.POST.get('username'), category='error') - raise HTTPFound(location=url('users')) + raise HTTPFound(location=url('edit_user', id=user.user_id)) def new(self, format='html'): c.default_extern_type = auth_internal.KallitheaAuthPlugin.name diff -r e8bd3f074b4e -r 9b80c2a64781 kallithea/tests/functional/test_admin_users.py --- a/kallithea/tests/functional/test_admin_users.py Tue Sep 06 00:51:18 2016 +0200 +++ b/kallithea/tests/functional/test_admin_users.py Tue Sep 06 00:51:18 2016 +0200 @@ -76,9 +76,13 @@ 'extern_type': 'internal', 'email': email, '_authentication_token': self.authentication_token()}) + # 302 Found + # The resource was found at http://localhost/_admin/users/5/edit; you should be redirected automatically. - self.checkSessionFlash(response, '''Created user %s''' % (username)) + self.checkSessionFlash(response, '''Created user %s''' % username) + + response = response.follow() + response.mustcontain("""%s user settings""" % username) # in new_user = Session().query(User). \ filter(User.username == username).one() @@ -89,10 +93,6 @@ assert new_user.lastname == lastname assert new_user.email == email - response.follow() - response = response.follow() - response.mustcontain("""newtestuser""") - def test_create_err(self): self.log_user() username = 'new_user'