mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 17:08:41 -06:00
Remove example choices from CSV import form
This commit is contained in:
parent
f9f7c19d81
commit
d85d963842
@ -71,9 +71,7 @@
|
|||||||
{% elif field.label %}
|
{% elif field.label %}
|
||||||
{{ field.label }}<br />
|
{{ field.label }}<br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if field.choices %}
|
{% if field|widget_type == 'dateinput' %}
|
||||||
<small class="text-muted">Choices: {{ field|example_choices }}</small>
|
|
||||||
{% elif field|widget_type == 'dateinput' %}
|
|
||||||
<small class="text-muted">Format: YYYY-MM-DD</small>
|
<small class="text-muted">Format: YYYY-MM-DD</small>
|
||||||
{% elif field|widget_type == 'checkboxinput' %}
|
{% elif field|widget_type == 'checkboxinput' %}
|
||||||
<small class="text-muted">Specify "true" or "false"</small>
|
<small class="text-muted">Specify "true" or "false"</small>
|
||||||
|
@ -116,28 +116,6 @@ def humanize_speed(speed):
|
|||||||
return '{} Kbps'.format(speed)
|
return '{} Kbps'.format(speed)
|
||||||
|
|
||||||
|
|
||||||
@register.filter()
|
|
||||||
def example_choices(field, arg=3):
|
|
||||||
"""
|
|
||||||
Returns a number (default: 3) of example choices for a ChoiceFiled (useful for CSV import forms).
|
|
||||||
"""
|
|
||||||
examples = []
|
|
||||||
if hasattr(field, 'queryset'):
|
|
||||||
choices = [
|
|
||||||
(obj.pk, getattr(obj, field.to_field_name)) for obj in field.queryset[:arg + 1]
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
choices = field.choices
|
|
||||||
for value, label in unpack_grouped_choices(choices):
|
|
||||||
if len(examples) == arg:
|
|
||||||
examples.append('etc.')
|
|
||||||
break
|
|
||||||
if not value or not label:
|
|
||||||
continue
|
|
||||||
examples.append(label)
|
|
||||||
return ', '.join(examples) or 'None'
|
|
||||||
|
|
||||||
|
|
||||||
@register.filter()
|
@register.filter()
|
||||||
def tzoffset(value):
|
def tzoffset(value):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user