From a21d0649b0e0122fdee368307241c6f938a85822 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 24 Sep 2020 16:02:27 +0200 Subject: Container: fix parent field on form - prevent recursion on parent location fix --- archaeological_warehouse/forms.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'archaeological_warehouse/forms.py') diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index 170edce1f..12e9f4949 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -308,6 +308,7 @@ class ContainerForm(CustomForm, ManageOldType, forms.Form): raise forms.ValidationError( _("The parent container is not attached to the same " "warehouse.")) + return self.cleaned_data["parent"] def clean(self): cleaned_data = self.cleaned_data @@ -343,10 +344,14 @@ class ContainerModifyForm(ContainerForm): super(ContainerModifyForm, self).__init__(*args, **kwargs) fields = OrderedDict() idx = self.fields.pop('index') + reordered = False for key, value in self.fields.items(): fields[key] = value if key == 'container_type': fields['index'] = idx + reordered = True + if not reordered: + fields['index'] = idx self.fields = fields def clean(self): -- cgit v1.2.3