##// END OF EJS Templates
admin: don't redirect back to the list of users after creating a user...
Mads Kiilerich -
r6118:9b80c2a6 default
parent child Browse files
Show More
@@ -122,10 +122,9 b' class UsersController(BaseController):'
122 try:
122 try:
123 form_result = user_form.to_python(dict(request.POST))
123 form_result = user_form.to_python(dict(request.POST))
124 user = user_model.create(form_result)
124 user = user_model.create(form_result)
125 usr = form_result['username']
125 action_logger(self.authuser, 'admin_created_user:%s' % user.username,
126 action_logger(self.authuser, 'admin_created_user:%s' % usr,
127 None, self.ip_addr, self.sa)
126 None, self.ip_addr, self.sa)
128 h.flash(h.literal(_('Created user %s') % h.link_to(h.escape(usr), url('edit_user', id=user.user_id))),
127 h.flash(_('Created user %s') % user.username,
129 category='success')
128 category='success')
130 Session().commit()
129 Session().commit()
131 except formencode.Invalid as errors:
130 except formencode.Invalid as errors:
@@ -142,7 +141,7 b' class UsersController(BaseController):'
142 log.error(traceback.format_exc())
141 log.error(traceback.format_exc())
143 h.flash(_('Error occurred during creation of user %s') \
142 h.flash(_('Error occurred during creation of user %s') \
144 % request.POST.get('username'), category='error')
143 % request.POST.get('username'), category='error')
145 raise HTTPFound(location=url('users'))
144 raise HTTPFound(location=url('edit_user', id=user.user_id))
146
145
147 def new(self, format='html'):
146 def new(self, format='html'):
148 c.default_extern_type = auth_internal.KallitheaAuthPlugin.name
147 c.default_extern_type = auth_internal.KallitheaAuthPlugin.name
@@ -76,9 +76,13 b' class TestAdminUsersController(TestContr'
76 'extern_type': 'internal',
76 'extern_type': 'internal',
77 'email': email,
77 'email': email,
78 '_authentication_token': self.authentication_token()})
78 '_authentication_token': self.authentication_token()})
79 # 302 Found
80 # The resource was found at http://localhost/_admin/users/5/edit; you should be redirected automatically.
79
81
80 self.checkSessionFlash(response, '''Created user <a href="/_admin/users/''')
82 self.checkSessionFlash(response, '''Created user %s''' % username)
81 self.checkSessionFlash(response, '''/edit">%s</a>''' % (username))
83
84 response = response.follow()
85 response.mustcontain("""%s user settings""" % username) # in <title>
82
86
83 new_user = Session().query(User). \
87 new_user = Session().query(User). \
84 filter(User.username == username).one()
88 filter(User.username == username).one()
@@ -89,10 +93,6 b' class TestAdminUsersController(TestContr'
89 assert new_user.lastname == lastname
93 assert new_user.lastname == lastname
90 assert new_user.email == email
94 assert new_user.email == email
91
95
92 response.follow()
93 response = response.follow()
94 response.mustcontain("""newtestuser""")
95
96 def test_create_err(self):
96 def test_create_err(self):
97 self.log_user()
97 self.log_user()
98 username = 'new_user'
98 username = 'new_user'
General Comments 0
You need to be logged in to leave comments. Login now