summaryrefslogtreecommitdiff
path: root/chimere/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-11-30 15:54:53 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-11-30 15:54:53 +0100
commitd32140f33cfb0c952b965c6f4605c85420cb0d88 (patch)
tree3abc0ace273364720fd395d7fed6110104057d80 /chimere/forms.py
parent72bda3fe8a40a0e3f7a96e9188802fd0b30b5763 (diff)
downloadChimère-d32140f33cfb0c952b965c6f4605c85420cb0d88.tar.bz2
Chimère-d32140f33cfb0c952b965c6f4605c85420cb0d88.zip
Do not display categories when no category is available
Diffstat (limited to 'chimere/forms.py')
-rw-r--r--chimere/forms.py10
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')