diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-23 18:55:03 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-23 18:58:28 +0200 |
commit | d7a0f20cb5ac8fc70aec1af0e2c3858076896836 (patch) | |
tree | 31afcf63998ee39bc34e1657244d9101bd20416d /ishtar_common | |
parent | 1ef0151057998c9f14f7653f2f58cb0c333e6348 (diff) | |
download | Ishtar-d7a0f20cb5ac8fc70aec1af0e2c3858076896836.tar.bz2 Ishtar-d7a0f20cb5ac8fc70aec1af0e2c3858076896836.zip |
Display field number when no custom field is available
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/forms.py | 16 | ||||
-rw-r--r-- | ishtar_common/templates/blocks/bs_field_snippet.html | 2 |
2 files changed, 12 insertions, 6 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 433562f72..1ed545166 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -149,17 +149,23 @@ class CustomForm(object): order += 1 new_fields[order] = (key, field) - if not new_fields: - return - - # re-order for json fields - fields = OrderedDict() field_items, field_hidden_items = [], [] for key, field in self.fields.items(): if getattr(field.widget, 'is_hidden', None): field_hidden_items.append((key, field)) else: field_items.append((key, field)) + + if not new_fields: + # add index number for admin debug + for idx, field in enumerate(field_items): + idx = (idx + 1) * 10 + key, c_field = field + c_field.order_number = idx + return + + # re-order for json fields + fields = OrderedDict() for idx, field in enumerate(field_hidden_items): key, c_field = field fields[key] = c_field diff --git a/ishtar_common/templates/blocks/bs_field_snippet.html b/ishtar_common/templates/blocks/bs_field_snippet.html index c7b97c6de..830dd4cfa 100644 --- a/ishtar_common/templates/blocks/bs_field_snippet.html +++ b/ishtar_common/templates/blocks/bs_field_snippet.html @@ -2,7 +2,7 @@ <div class="form-group {% if field.field.widget.attrs.cols %}col-lg-12{% else %}col-lg-6{% endif %}{% if field.errors %} is-invalid{% endif %}{% if field.field.required %} required{% endif %}" data-alt-name="{{field.field.alt_name}}"> {% if field.label %}{{ field.label_tag }}{% endif %} - {% if show_field_number %}<span class="badge badge-pill badge-success field-tip"> + {% if show_field_number and field.field.order_number %}<span class="badge badge-pill badge-success field-tip"> {{field.field.order_number}} </span>{% endif %} {% if field.help_text %} |