Browse Source

Use set_username to rename users in admin

Rafał Pitoń 11 years ago
parent
commit
ec1f3aadc5
1 changed files with 7 additions and 0 deletions
  1. 7 0
      misago/users/views/admin/users.py

+ 7 - 0
misago/users/views/admin/users.py

@@ -116,7 +116,14 @@ class EditUser(UserAdmin, generic.ModelFormView):
     template = 'edit.html'
     message_submit = _('User "%s" has been edited.')
 
+    def real_dispatch(self, request, target):
+        target.old_username = target.username
+        return super(EditUser, self).real_dispatch(request, target)
+
     def handle_form(self, form, request, target):
+        target.username = target.old_username
+        target.set_username(form.cleaned_data.get('username'))
+
         if form.cleaned_data.get('new_password'):
             target.set_password(form.cleaned_data['new_password'])