Преглед изворни кода

Fixes #7176: Reset query parameters on APISelect when deep copied

thatmattlove пре 4 година
родитељ
комит
4a13ee6f40
2 измењених фајлова са 8 додато и 0 уклоњено
  1. 1 0
      docs/release-notes/version-3.0.md
  2. 7 0
      netbox/utilities/forms/widgets.py

+ 1 - 0
docs/release-notes/version-3.0.md

@@ -7,6 +7,7 @@
 * [#7153](https://github.com/netbox-community/netbox/issues/7153) - Allow clearing of assigned device type images
 * [#7153](https://github.com/netbox-community/netbox/issues/7153) - Allow clearing of assigned device type images
 * [#7164](https://github.com/netbox-community/netbox/issues/7164) - Fix styling of "decommissioned" label for circuits
 * [#7164](https://github.com/netbox-community/netbox/issues/7164) - Fix styling of "decommissioned" label for circuits
 * [#7169](https://github.com/netbox-community/netbox/issues/7169) - Fix CSV import file upload
 * [#7169](https://github.com/netbox-community/netbox/issues/7169) - Fix CSV import file upload
+* [#7176](https://github.com/netbox-community/netbox/issues/7176) - Fix issue where query parameters were duplicated across different forms of the same type
 * [#7193](https://github.com/netbox-community/netbox/issues/7193) - Fix prefix (flat) template issue when viewing child prefixes with prefixes available
 * [#7193](https://github.com/netbox-community/netbox/issues/7193) - Fix prefix (flat) template issue when viewing child prefixes with prefixes available
 
 
 ---
 ---

+ 7 - 0
netbox/utilities/forms/widgets.py

@@ -163,6 +163,13 @@ class APISelect(SelectWithDisabled):
         if api_url:
         if api_url:
             self.attrs['data-url'] = '/{}{}'.format(settings.BASE_PATH, api_url.lstrip('/'))  # Inject BASE_PATH
             self.attrs['data-url'] = '/{}{}'.format(settings.BASE_PATH, api_url.lstrip('/'))  # Inject BASE_PATH
 
 
+    def __deepcopy__(self, memo):
+        """Reset `static_params` and `dynamic_params` when APISelect is deepcopied."""
+        result = super().__deepcopy__(memo)
+        result.dynamic_params = {}
+        result.static_params = {}
+        return result
+
     def _process_query_param(self, key: str, value: JSONPrimitive) -> None:
     def _process_query_param(self, key: str, value: JSONPrimitive) -> None:
         """
         """
         Based on query param value's type and value, update instance's dynamic/static params.
         Based on query param value's type and value, update instance's dynamic/static params.