From 600143236d464e590c091201ae7ea6ec75b93923 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 22 Sep 2014 18:15:28 -0500 Subject: Update to OrderedDict usage for Django 1.7 Signed-off-by: Dan McGee --- devel/forms.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'devel/forms.py') 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'] -- cgit v1.2.3-2-g168b