diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-04-09 20:06:04 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-04-09 20:06:04 +0200 |
commit | f28caac841516b268af2df4230654216bc9c3d72 (patch) | |
tree | e56ef03b1e10781afb29039bfad06a977bf9ddf2 | |
parent | 11e03ef2e267a79dcd5b96bc170c852fc4d0dc23 (diff) | |
download | Ishtar-f28caac841516b268af2df4230654216bc9c3d72.tar.bz2 Ishtar-f28caac841516b268af2df4230654216bc9c3d72.zip |
Manage hierarchical display with select2
-rw-r--r-- | archaeological_finds/forms.py | 20 | ||||
-rw-r--r-- | archaeological_warehouse/ishtar_menu.py | 2 | ||||
-rw-r--r-- | ishtar_common/static/media/style.css | 6 | ||||
-rw-r--r-- | ishtar_common/widgets.py | 2 |
4 files changed, 22 insertions, 8 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index 8fe945e88..bdb602606 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -148,8 +148,7 @@ class FindForm(ManageOldType, forms.Form): is_complete = forms.NullBooleanField(label=_(u"Is complete?"), required=False) material_type = widgets.Select2MultipleField( - model=models.MaterialType, label=_(u"Material type"), required=False, - available=True + label=_(u"Material type"), required=False ) conservatory_state = forms.ChoiceField(label=_(u"Conservatory state"), choices=[], required=False) @@ -157,18 +156,17 @@ class FindForm(ManageOldType, forms.Form): label=_(u"Conservatory comment"), required=False, widget=forms.Textarea) object_type = widgets.Select2MultipleField( - model=models.ObjectType, label=_(u"Object types"), required=False, - available=True + label=_(u"Object types"), required=False, ) preservation_to_consider = forms.MultipleChoiceField( label=_(u"Preservation type"), choices=[], widget=widgets.Select2Multiple, required=False) integritie = forms.MultipleChoiceField( label=_(u"Integrity / interest"), choices=[], - widget=widgets.CheckboxSelectMultiple, required=False) + widget=widgets.Select2Multiple, required=False) remarkabilitie = forms.MultipleChoiceField( label=_(u"Remarkability"), choices=[], - widget=widgets.CheckboxSelectMultiple, required=False) + widget=widgets.Select2Multiple, required=False) get_first_base_find__topographic_localisation = forms.CharField( label=_(u"Point of topographic reference"), required=False, max_length=120 @@ -232,8 +230,18 @@ class FindForm(ManageOldType, forms.Form): self.fields[srs].help_text = \ SpatialReferenceSystem.get_help() self.fields['checked'].choices = models.CHECK_CHOICES + self.fields['material_type'].choices = models.MaterialType.get_types( + initial=self.init_data.get('material_type'), + empty_first=False + ) self.fields['material_type'].help_text = models.MaterialType.get_help() + self.fields['object_type'].choices = models.ObjectType.get_types( + initial=self.init_data.get('object_type'), + empty_first=False + ) + self.fields['object_type'].help_text = models.ObjectType.get_help() + self.fields['get_first_base_find__batch'].choices = \ models.BatchType.get_types( initial=self.init_data.get('get_first_base_find__batch')) diff --git a/archaeological_warehouse/ishtar_menu.py b/archaeological_warehouse/ishtar_menu.py index d2ebc2306..bcbfe881b 100644 --- a/archaeological_warehouse/ishtar_menu.py +++ b/archaeological_warehouse/ishtar_menu.py @@ -25,7 +25,7 @@ from archaeological_finds.models import Treatment import models -# be carreful: each access_controls must be relevant with check_rights in urls +# be careful: each access_controls must be relevant with check_rights in urls MENU_SECTIONS = [ diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 011db3652..178f02362 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -101,6 +101,12 @@ div.form { border:1px solid #D14; } +.select2-container .select2-results__option { + font-family: monospace; + padding: 0 6px; + font-size: 1.1em; +} + hr.spacer{ clear:both; border:0; diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 94709406c..b0f28a6cf 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -118,7 +118,7 @@ class Select2Multiple(forms.SelectMultiple): try: choices.append((v, self.model.objects.get(pk=v))) except (self.model.DoesNotExist, ValueError): - # an old reference ? it should not happen + # an old reference? it should not happen pass html = super(Select2Multiple, self).render(name, value, attrs, choices) |