diff options
Diffstat (limited to 'chimere/forms.py')
-rw-r--r-- | chimere/forms.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/chimere/forms.py b/chimere/forms.py index 4685144..6881f42 100644 --- a/chimere/forms.py +++ b/chimere/forms.py @@ -354,6 +354,8 @@ class MarkerAdminFormBase(forms.ModelForm): return if subcategories: self.fields['categories'].choices = subcategories + elif subcategories is None: + self.fields['categories'].choices = [] # auto select if there is only one category choices = list(self.fields['categories'].choices) self.fields['categories'].choices = choices @@ -378,16 +380,16 @@ class MarkerAdminFormBase(forms.ModelForm): # not a clean way to filter properties... # to do: change creation process pms = [pm.getNamedId() for pm in self.pms] - for k in self.fields.keys(): - if not k.startswith('property_') or \ - k in pms: + keys = [k for k in self.fields.keys()] + for k in keys: + if not k.startswith('property_') or k in pms: continue self.fields.pop(k) def clean(self): """ Verify that a start date is provided when an end date is set - Verify the mandatory properties (to be check manualy because it depends + Verify the mandatory properties (to be check manually because it depends on the checked categories) """ start_date = self.cleaned_data.get('start_date') |