diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index ed8a722ec..9fcaa712d 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -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) diff --git a/netbox/extras/forms.py b/netbox/extras/forms.py index 4a4f95213..fe98d9ca3 100644 --- a/netbox/extras/forms.py +++ b/netbox/extras/forms.py @@ -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', ) diff --git a/netbox/extras/tests/test_views.py b/netbox/extras/tests/test_views.py index 7f2aa41a8..72d965fd0 100644 --- a/netbox/extras/tests/test_views.py +++ b/netbox/extras/tests/test_views.py @@ -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 = { diff --git a/netbox/templates/extras/customfield.html b/netbox/templates/extras/customfield.html index fd5576c2a..bf79059b8 100644 --- a/netbox/templates/extras/customfield.html +++ b/netbox/templates/extras/customfield.html @@ -56,7 +56,13 @@ Choices - {{ object.choices|placeholder }} + + {% if object.choices %} + {{ object.choices|join:", " }} + {% else %} + + {% endif %} + Filter Logic