diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-05-26 17:35:07 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-05-26 17:35:07 +0200 |
commit | 63bb46ac8b05c7184c9ee50e7a76894b8722db52 (patch) | |
tree | 4558bf9f45a132494aaa7c61017859c847e958e5 /chimere/forms.py | |
parent | 22c012d11c996019ec04e2e7559a2747126b95ad (diff) | |
download | Chimère-63bb46ac8b05c7184c9ee50e7a76894b8722db52.tar.bz2 Chimère-63bb46ac8b05c7184c9ee50e7a76894b8722db52.zip |
Edit page - one category read-only: manage two types of category listing
Diffstat (limited to 'chimere/forms.py')
-rw-r--r-- | chimere/forms.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/chimere/forms.py b/chimere/forms.py index 107812b..1a0679b 100644 --- a/chimere/forms.py +++ b/chimere/forms.py @@ -303,10 +303,17 @@ class MarkerAdminFormBase(forms.ModelForm): if (len(choices) == 1): self.fields['categories'].widget = forms.MultipleHiddenInput() choices = list(self.fields['categories'].choices) - self.fields['categories'].label = u"{} / {}".format( - choices[0][0], choices[0][1][0][1]) - self.fields['categories'].initial = \ - [self.fields['categories'].choices[0][1][0][0]] + if type(choices[0][1]) in (list, tuple): + # hierarchical choices + self.fields['categories'].label = u"{} / {}".format( + choices[0][0], choices[0][1][0][1]) + self.fields['categories'].initial = \ + [self.fields['categories'].choices[0][1][0][0]] + else: + self.fields['categories'].label = u"{}".format( + choices[0][1]) + self.fields['categories'].initial = \ + [self.fields['categories'].choices[0][0]] if not settings.CHIMERE_SEARCH_ENGINE and 'keywords' in self.fields: self.fields.pop('keywords') if not settings.CHIMERE_DAYS_BEFORE_EVENT: |