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

Fixes #7304: Require explicit values for all required choice fields during CSV import

This commit is contained in:
jeremystretch
2021-09-28 12:04:54 -04:00
parent 16f5e233d0
commit 71449b3414
9 changed files with 21 additions and 29 deletions

View File

@ -11,6 +11,7 @@
### Bug Fixes ### Bug Fixes
* [#7294](https://github.com/netbox-community/netbox/issues/7294) - Fix SVG rendering for cable traces ending at unoccupied front ports * [#7294](https://github.com/netbox-community/netbox/issues/7294) - Fix SVG rendering for cable traces ending at unoccupied front ports
* [#7304](https://github.com/netbox-community/netbox/issues/7304) - Require explicit values for all required choice fields during CSV import
* [#7321](https://github.com/netbox-community/netbox/issues/7321) - Don't overwrite multi-select custom fields during bulk edit * [#7321](https://github.com/netbox-community/netbox/issues/7321) - Don't overwrite multi-select custom fields during bulk edit
* [#7324](https://github.com/netbox-community/netbox/issues/7324) - Fix TypeError exception in web UI when filtering objects using single-choice filters * [#7324](https://github.com/netbox-community/netbox/issues/7324) - Fix TypeError exception in web UI when filtering objects using single-choice filters
* [#7333](https://github.com/netbox-community/netbox/issues/7333) - Prevent inadvertent deletion of prior change records when deleting objects * [#7333](https://github.com/netbox-community/netbox/issues/7333) - Prevent inadvertent deletion of prior change records when deleting objects

View File

@ -60,7 +60,6 @@ class CircuitCSVForm(CustomFieldModelCSVForm):
) )
status = CSVChoiceField( status = CSVChoiceField(
choices=CircuitStatusChoices, choices=CircuitStatusChoices,
required=False,
help_text='Operational status' help_text='Operational status'
) )
tenant = CSVModelChoiceField( tenant = CSVModelChoiceField(

View File

@ -122,10 +122,10 @@ class CircuitTestCase(ViewTestCases.PrimaryObjectViewTestCase):
} }
cls.csv_data = ( cls.csv_data = (
"cid,provider,type", "cid,provider,type,status",
"Circuit 4,Provider 1,Circuit Type 1", "Circuit 4,Provider 1,Circuit Type 1,active",
"Circuit 5,Provider 1,Circuit Type 1", "Circuit 5,Provider 1,Circuit Type 1,active",
"Circuit 6,Provider 1,Circuit Type 1", "Circuit 6,Provider 1,Circuit Type 1,active",
) )
cls.bulk_edit_data = { cls.bulk_edit_data = {

View File

@ -70,7 +70,6 @@ class SiteGroupCSVForm(CustomFieldModelCSVForm):
class SiteCSVForm(CustomFieldModelCSVForm): class SiteCSVForm(CustomFieldModelCSVForm):
status = CSVChoiceField( status = CSVChoiceField(
choices=SiteStatusChoices, choices=SiteStatusChoices,
required=False,
help_text='Operational status' help_text='Operational status'
) )
region = CSVModelChoiceField( region = CSVModelChoiceField(
@ -156,7 +155,6 @@ class RackCSVForm(CustomFieldModelCSVForm):
) )
status = CSVChoiceField( status = CSVChoiceField(
choices=RackStatusChoices, choices=RackStatusChoices,
required=False,
help_text='Operational status' help_text='Operational status'
) )
role = CSVModelChoiceField( role = CSVModelChoiceField(
@ -929,22 +927,18 @@ class PowerFeedCSVForm(CustomFieldModelCSVForm):
) )
status = CSVChoiceField( status = CSVChoiceField(
choices=PowerFeedStatusChoices, choices=PowerFeedStatusChoices,
required=False,
help_text='Operational status' help_text='Operational status'
) )
type = CSVChoiceField( type = CSVChoiceField(
choices=PowerFeedTypeChoices, choices=PowerFeedTypeChoices,
required=False,
help_text='Primary or redundant' help_text='Primary or redundant'
) )
supply = CSVChoiceField( supply = CSVChoiceField(
choices=PowerFeedSupplyChoices, choices=PowerFeedSupplyChoices,
required=False,
help_text='Supply type (AC/DC)' help_text='Supply type (AC/DC)'
) )
phase = CSVChoiceField( phase = CSVChoiceField(
choices=PowerFeedPhaseChoices, choices=PowerFeedPhaseChoices,
required=False,
help_text='Single or three-phase' help_text='Single or three-phase'
) )

View File

@ -322,10 +322,10 @@ class RackTestCase(ViewTestCases.PrimaryObjectViewTestCase):
} }
cls.csv_data = ( cls.csv_data = (
"site,location,name,width,u_height", "site,location,name,status,width,u_height",
"Site 1,,Rack 4,19,42", "Site 1,,Rack 4,active,19,42",
"Site 1,Location 1,Rack 5,19,42", "Site 1,Location 1,Rack 5,active,19,42",
"Site 2,Location 2,Rack 6,19,42", "Site 2,Location 2,Rack 6,active,19,42",
) )
cls.bulk_edit_data = { cls.bulk_edit_data = {
@ -1991,10 +1991,10 @@ class PowerFeedTestCase(ViewTestCases.PrimaryObjectViewTestCase):
} }
cls.csv_data = ( cls.csv_data = (
"site,power_panel,name,voltage,amperage,max_utilization", "site,power_panel,name,status,type,supply,phase,voltage,amperage,max_utilization",
"Site 1,Power Panel 1,Power Feed 4,120,20,80", "Site 1,Power Panel 1,Power Feed 4,active,primary,ac,single-phase,120,20,80",
"Site 1,Power Panel 1,Power Feed 5,120,20,80", "Site 1,Power Panel 1,Power Feed 5,active,primary,ac,single-phase,120,20,80",
"Site 1,Power Panel 1,Power Feed 6,120,20,80", "Site 1,Power Panel 1,Power Feed 6,active,primary,ac,single-phase,120,20,80",
) )
cls.bulk_edit_data = { cls.bulk_edit_data = {

View File

@ -506,10 +506,10 @@ class CustomFieldImportTest(TestCase):
Import a Site in CSV format, including a value for each CustomField. Import a Site in CSV format, including a value for each CustomField.
""" """
data = ( data = (
('name', 'slug', 'cf_text', 'cf_integer', 'cf_boolean', 'cf_date', 'cf_url', 'cf_select'), ('name', 'slug', 'status', 'cf_text', 'cf_integer', 'cf_boolean', 'cf_date', 'cf_url', 'cf_select'),
('Site 1', 'site-1', 'ABC', '123', 'True', '2020-01-01', 'http://example.com/1', 'Choice A'), ('Site 1', 'site-1', 'active', 'ABC', '123', 'True', '2020-01-01', 'http://example.com/1', 'Choice A'),
('Site 2', 'site-2', 'DEF', '456', 'False', '2020-01-02', 'http://example.com/2', 'Choice B'), ('Site 2', 'site-2', 'active', 'DEF', '456', 'False', '2020-01-02', 'http://example.com/2', 'Choice B'),
('Site 3', 'site-3', '', '', '', '', '', ''), ('Site 3', 'site-3', 'active', '', '', '', '', '', ''),
) )
csv_data = '\n'.join(','.join(row) for row in data) csv_data = '\n'.join(','.join(row) for row in data)

View File

@ -198,7 +198,6 @@ class IPAddressCSVForm(CustomFieldModelCSVForm):
) )
status = CSVChoiceField( status = CSVChoiceField(
choices=IPAddressStatusChoices, choices=IPAddressStatusChoices,
required=False,
help_text='Operational status' help_text='Operational status'
) )
role = CSVChoiceField( role = CSVChoiceField(

View File

@ -64,7 +64,6 @@ class ClusterCSVForm(CustomFieldModelCSVForm):
class VirtualMachineCSVForm(CustomFieldModelCSVForm): class VirtualMachineCSVForm(CustomFieldModelCSVForm):
status = CSVChoiceField( status = CSVChoiceField(
choices=VirtualMachineStatusChoices, choices=VirtualMachineStatusChoices,
required=False,
help_text='Operational status of device' help_text='Operational status of device'
) )
cluster = CSVModelChoiceField( cluster = CSVModelChoiceField(

View File

@ -194,10 +194,10 @@ class VirtualMachineTestCase(ViewTestCases.PrimaryObjectViewTestCase):
} }
cls.csv_data = ( cls.csv_data = (
"name,cluster", "name,status,cluster",
"Virtual Machine 4,Cluster 1", "Virtual Machine 4,active,Cluster 1",
"Virtual Machine 5,Cluster 1", "Virtual Machine 5,active,Cluster 1",
"Virtual Machine 6,Cluster 1", "Virtual Machine 6,active,Cluster 1",
) )
cls.bulk_edit_data = { cls.bulk_edit_data = {