summaryrefslogtreecommitdiff
path: root/ishtar_common/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-02-13 12:08:57 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-02-13 12:08:57 +0100
commita6d77a3a3358463c591900872a8ae62286f9509d (patch)
tree821bfa0e3a4cd1d4dec253357a83e67716547c04 /ishtar_common/forms.py
parent8e6c07426f06d26aa54a47dac5cac73f990959f0 (diff)
downloadIshtar-a6d77a3a3358463c591900872a8ae62286f9509d.tar.bz2
Ishtar-a6d77a3a3358463c591900872a8ae62286f9509d.zip
Search form: manage field ordering and custom fields
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r--ishtar_common/forms.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index 93c6cd8ed..754f63f74 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -164,6 +164,7 @@ class CustomForm(BSForm):
form_admin_name = ""
form_slug = ""
need_user_for_initialization = True
+ _explicit_ordering = False # explicit call to field ordering
def __init__(self, *args, **kwargs):
self.current_user = None
@@ -173,6 +174,10 @@ class CustomForm(BSForm):
except AttributeError:
pass
super(CustomForm, self).__init__(*args, **kwargs)
+ if not self._explicit_ordering:
+ self.custom_form_ordering()
+
+ def custom_form_ordering(self):
available, excluded, json_fields = self.check_custom_form(
self.current_user)
for exc in excluded:
@@ -288,6 +293,7 @@ class CustomForm(BSForm):
if 'class' in f.widget.attrs:
kls = f.widget.attrs['class'] + " " + kls
f.widget.attrs['class'] = kls
+ f.alt_name = slugify(attrs['label'])
fields.append((field.order or 1, key, f))
return fields
@@ -607,6 +613,7 @@ class HistorySelect(CustomForm, TableSelect):
modified_since = forms.DateField(
label=_(u"Modified since"), widget=DatePicker,
required=False)
+ _explicit_ordering = True
def __init__(self, *args, **kwargs):
super(HistorySelect, self).__init__(*args, **kwargs)
@@ -620,6 +627,7 @@ class HistorySelect(CustomForm, TableSelect):
for k in current_fields:
fields[k] = self.fields[k]
self.fields = fields
+ self.custom_form_ordering()
def get_now():