summaryrefslogtreecommitdiff
path: root/ishtar_common/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-31 17:06:29 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-31 17:06:29 +0100
commit7bc356efd27f625618dda25e0abde2fda30d9850 (patch)
tree013b56c339effd0a0540f5cee907986e30fd897a /ishtar_common/forms.py
parentc72f6a2dfcc14607cac31c71e96128ea457428b3 (diff)
downloadIshtar-7bc356efd27f625618dda25e0abde2fda30d9850.tar.bz2
Ishtar-7bc356efd27f625618dda25e0abde2fda30d9850.zip
Search: manage dynamic query parameters (ex: divisions details)
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r--ishtar_common/forms.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index 2a072aade..93c6cd8ed 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -569,17 +569,25 @@ class IshtarForm(forms.Form, BSForm):
class TableSelect(IshtarForm):
def __init__(self, *args, **kwargs):
super(TableSelect, self).__init__(*args, **kwargs)
- ALT_NAMES = {}
- if hasattr(self, '_model') and hasattr(self._model, "ALT_NAMES"):
- ALT_NAMES = self._model.ALT_NAMES
+ alt_names = {}
+ if hasattr(self, '_model'):
+ if hasattr(self._model, "get_alt_names"):
+ alt_names = self._model.get_alt_names()
+
+ for k_dyn in self._model.DYNAMIC_REQUESTS:
+ dyn = self._model.DYNAMIC_REQUESTS[k_dyn]
+ fields = dyn.get_form_fields()
+ for k in fields:
+ self.fields[k] = fields[k]
+
for k in self.fields:
self.fields[k].required = False # no field is required for search
cls = 'form-control'
if k == 'search_vector':
cls += " search-vector"
self.fields[k].widget.attrs['class'] = cls
- if k in ALT_NAMES:
- self.fields[k].alt_name = ALT_NAMES[k][0]
+ if k in alt_names:
+ self.fields[k].alt_name = alt_names[k].search_key
else:
self.fields[k].alt_name = k
key = self.fields.keys()[0]