diff options
Diffstat (limited to 'archaeological_warehouse/forms.py')
-rw-r--r-- | archaeological_warehouse/forms.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index 94e31b759..f020864ff 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2017 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,6 +17,8 @@ # See the file COPYING for details. +from collections import OrderedDict + from django import forms from django.conf import settings from django.forms.formsets import formset_factory @@ -212,9 +214,13 @@ class ContainerModifyForm(ContainerForm): def __init__(self, *args, **kwargs): super(ContainerModifyForm, self).__init__(*args, **kwargs) - self.fields.keyOrder.pop(self.fields.keyOrder.index('index')) - self.fields.keyOrder.insert( - self.fields.keyOrder.index("location") + 1, 'index') + fields = OrderedDict() + idx = self.fields.pop('index') + for key, value in self.fields.items(): + fields[key] = value + if key == 'location': + fields['index'] = idx + self.fields = fields def clean(self): # manage unique ID |