summaryrefslogtreecommitdiff
path: root/devel
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2014-09-22 18:15:28 -0500
committerDan McGee <dan@archlinux.org>2014-09-22 18:15:28 -0500
commit600143236d464e590c091201ae7ea6ec75b93923 (patch)
treeabfcacd8122c6d4f5f1ea30ae52665d6bef74906 /devel
parent39a52bbe34d51aa8f4d7a8ad5d685d47ef56c457 (diff)
Update to OrderedDict usage for Django 1.7
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel')
-rw-r--r--devel/forms.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/devel/forms.py b/devel/forms.py
index 861a576c..e2b1a7a2 100644
--- a/devel/forms.py
+++ b/devel/forms.py
@@ -1,4 +1,5 @@
import random
+from collections import OrderedDict
from string import ascii_letters, digits
from django import forms
@@ -51,13 +52,16 @@ class NewUserForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(NewUserForm, self).__init__(*args, **kwargs)
- # Hack ourself so certain fields appear first. self.fields is a
- # SortedDict object where we can manipulate the keyOrder list.
- order = self.fields.keyOrder
- keys = ('username', 'private_email', 'first_name', 'last_name')
- for key in reversed(keys):
- order.remove(key)
- order.insert(0, key)
+ # Hack ourself so certain fields appear first
+ old = self.fields
+ self.fields = OrderedDict()
+ keys = ('username', 'private_email', 'first_name', 'last_name',
+ 'alias', 'public_email')
+ for key in keys:
+ self.fields[key] = old[key]
+ for key, val in old.items():
+ if key not in keys:
+ self.fields[key] = old[key]
def clean_username(self):
username = self.cleaned_data['username']