Anonymous committed 627a304

Edit user properly comments now and you can change the username of a user
in the edit view.

Comments (0)

Files changed (4)

 class EditUserForm(ProfileEditForm):
     """Like the profile form."""
+    username = forms.TextField(lazy_gettext(u'Username'))
     is_admin = forms.BooleanField(lazy_gettext(u'Administrator'),
         help_text=lazy_gettext(u'Enable if this user is an admin.'))
     def __init__(self, user, initial=None, action=None, request=None):
         if user is not None:
-            initial = forms.fill_dict(initial, is_admin=user.is_admin)
+            initial = forms.fill_dict(initial, username=user.username,
+                                      is_admin=user.is_admin)
         ProfileEditForm.__init__(self, user, initial, action, request)
     def validate_is_admin(self, value):
     def apply_changes(self):
         super(EditUserForm, self).apply_changes()
+        self.user.username =['username']
         self.user.is_admin =['is_admin']


 import re
 import string
 from datetime import datetime
-from itertools import chain
+from itertools import chain, count
 from functools import update_wrapper
 from threading import Lock
 from urlparse import urljoin
             setattr(obj, field, value)
-def _next_position_hint():
-    """Return the next position hint."""
-    global _last_position_hint
-    _position_hint_lock.acquire()
-    try:
-        _last_position_hint += 1
-        return _last_position_hint
-    finally:
-        _position_hint_lock.release()
+_next_position_hint = count().next
 def _decode(data):


         del self._keys[:]
+    def move(self, key, index):
+        self._keys.remove(key)
+        self._keys.insert(index, key)
     def copy(self):
         return self.__class__(self)


     form = EditUserForm(user)
     if request.method == 'POST' and form.validate():
         request.flash(_(u'The user details where changed.'))
+        session.commit()
         return form.redirect('admin.edit_users')
     return render_template('admin/edit_user.html', form=form.as_widget(), user=user)