Changeset - 9b80c2a64781
[Not reviewed]
default
0 2 0
Mads Kiilerich - 9 years ago 2016-09-06 00:51:18
madski@unity3d.com
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.
2 files changed with 9 insertions and 10 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/users.py
Show inline comments
 
@@ -122,10 +122,9 @@ class UsersController(BaseController):
 
        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 @@ class UsersController(BaseController):
 
            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
kallithea/tests/functional/test_admin_users.py
Show inline comments
 
@@ -76,9 +76,13 @@ class TestAdminUsersController(TestContr
 
             '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 <a href="/_admin/users/''')
 
        self.checkSessionFlash(response, '''/edit">%s</a>''' % (username))
 
        self.checkSessionFlash(response, '''Created user %s''' % username)
 

	
 
        response = response.follow()
 
        response.mustcontain("""%s user settings""" % username) # in <title>
 

	
 
        new_user = Session().query(User). \
 
            filter(User.username == username).one()
 
@@ -89,10 +93,6 @@ class TestAdminUsersController(TestContr
 
        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'
0 comments (0 inline, 0 general)