1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #7358: Add missing choices column to custom field CSV import form

This commit is contained in:
jeremystretch
2021-09-27 12:28:52 -04:00
parent d87d860a57
commit c7523ffc67
4 changed files with 19 additions and 6 deletions

View File

@ -17,6 +17,7 @@
* [#7341](https://github.com/netbox-community/netbox/issues/7341) - Fix incorrect URL in circuit breadcrumbs
* [#7353](https://github.com/netbox-community/netbox/issues/7353) - Fix bulk creation of device/VM components via list view
* [#7356](https://github.com/netbox-community/netbox/issues/7356) - Fix display of model documentation when adding device components
* [#7358](https://github.com/netbox-community/netbox/issues/7358) - Add missing `choices` column to custom field CSV import form
* [#7360](https://github.com/netbox-community/netbox/issues/7360) - Correct redirection URL after removing child device from device bay
## v3.0.3 (2021-09-20)

View File

@ -1,6 +1,7 @@
from django import forms
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.forms import SimpleArrayField
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _
@ -46,12 +47,17 @@ class CustomFieldCSVForm(CSVModelForm):
limit_choices_to=FeatureQuery('custom_fields'),
help_text="One or more assigned object types"
)
choices = SimpleArrayField(
base_field=forms.CharField(),
required=False,
help_text='Comma-separated list of field choices'
)
class Meta:
model = CustomField
fields = (
'name', 'label', 'type', 'content_types', 'required', 'description', 'weight', 'filter_logic', 'default',
'weight',
'choices', 'weight',
)

View File

@ -39,10 +39,10 @@ class CustomFieldTestCase(ViewTestCases.PrimaryObjectViewTestCase):
}
cls.csv_data = (
"name,label,type,content_types,weight,filter_logic",
"field4,Field 4,text,dcim.site,100,exact",
"field5,Field 5,text,dcim.site,100,exact",
"field6,Field 6,text,dcim.site,100,exact",
'name,label,type,content_types,weight,filter_logic,choices',
'field4,Field 4,text,dcim.site,100,exact,',
'field5,Field 5,integer,dcim.site,100,exact,',
'field6,Field 6,select,dcim.site,100,exact,"A,B,C"',
)
cls.bulk_edit_data = {

View File

@ -56,7 +56,13 @@
</tr>
<tr>
<th scope="row">Choices</th>
<td>{{ object.choices|placeholder }}</td>
<td>
{% if object.choices %}
{{ object.choices|join:", " }}
{% else %}
<span class="text-muted">&mdash;</span>
{% endif %}
</td>
</tr>
<tr>
<th scope="row">Filter Logic</th>