summaryrefslogtreecommitdiff
path: root/chimere/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/forms.py')
-rw-r--r--chimere/forms.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/chimere/forms.py b/chimere/forms.py
index 580fb09..74b7aa0 100644
--- a/chimere/forms.py
+++ b/chimere/forms.py
@@ -296,6 +296,15 @@ class MarkerAdminFormBase(forms.ModelForm):
self.fields['categories'].choices = subcategories
elif hasattr(self, 'categories_choices'):
self.fields['categories'].choices = self.categories_choices
+ # auto select if there is only one category
+ self.fields['categories'].label = ""
+ if (len(self.fields['categories'].choices) == 1):
+ self.fields['categories'].widget = forms.MultipleHiddenInput()
+ choices = 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 not settings.CHIMERE_SEARCH_ENGINE and 'keywords' in self.fields:
self.fields.pop('keywords')
if not settings.CHIMERE_DAYS_BEFORE_EVENT: