Unverified Commit adaa6d64 authored by Aleksandar Trifunovic's avatar Aleksandar Trifunovic
Browse files

rewrite logic to put some key at the beginning of the OrderedDict

parent cbf837ec
......@@ -53,15 +53,11 @@ class Meta:
def __init__(self, *args, **kwargs):
super(NewUserForm, self).__init__(*args, **kwargs)
# 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, _ in list(old.items()):
if key not in keys:
self.fields[key] = old[key]
# add all remaining keys afterwards
keys += tuple(k for k in self.fields.keys() if k not in keys)
self.fields = OrderedDict((key, old[key]) for key in keys)
def clean_username(self):
username = self.cleaned_data['username']
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment