From dda193247adf92df860ad799bb2127e34f2fe2b4 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 26 Sep 2022 16:47:34 -0400 Subject: [PATCH] Fixes #10470: Omit read-only custom fields from CSV import forms --- docs/release-notes/version-3.3.md | 1 + netbox/netbox/forms/base.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index d4d2d35f5..60d8b5381 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -9,6 +9,7 @@ * [#10439](https://github.com/netbox-community/netbox/issues/10439) - Fix form widget styling for DeviceType airflow field * [#10445](https://github.com/netbox-community/netbox/issues/10445) - Avoid rounding virtual machine memory values * [#10461](https://github.com/netbox-community/netbox/issues/10461) - Enable filtering by read-only custom fields in the UI +* [#10470](https://github.com/netbox-community/netbox/issues/10470) - Omit read-only custom fields from CSV import forms --- diff --git a/netbox/netbox/forms/base.py b/netbox/netbox/forms/base.py index fa741faf7..2cbc67971 100644 --- a/netbox/netbox/forms/base.py +++ b/netbox/netbox/forms/base.py @@ -63,6 +63,11 @@ class NetBoxModelCSVForm(CSVModelForm, NetBoxModelForm): """ tags = None # Temporary fix in lieu of tag import support (see #9158) + def _get_custom_fields(self, content_type): + return CustomField.objects.filter(content_types=content_type).filter( + ui_visibility=CustomFieldVisibilityChoices.VISIBILITY_READ_WRITE + ) + def _get_form_field(self, customfield): return customfield.to_form_field(for_csv_import=True)