diff --git a/openwisp_network_topology/admin.py b/openwisp_network_topology/admin.py index d4579603..1b81ad46 100644 --- a/openwisp_network_topology/admin.py +++ b/openwisp_network_topology/admin.py @@ -104,6 +104,14 @@ class TopologyAdmin( receive_url_baseurl = app_settings.TOPOLOGY_API_BASEURL change_form_template = 'admin/topology/topology/change_form.html' + def get_fields(self, request, obj=None): + fields = list(super().get_fields(request, obj)) + if not obj: + # Receive URL cannot be created without an object. + # Hence, remove the "receive_url" field. + fields.remove('receive_url') + return fields + def get_actions(self, request): """ move delete action to last position diff --git a/openwisp_network_topology/integrations/device/tests/test_wifi_mesh.py b/openwisp_network_topology/integrations/device/tests/test_wifi_mesh.py index 5b0c289f..79693990 100644 --- a/openwisp_network_topology/integrations/device/tests/test_wifi_mesh.py +++ b/openwisp_network_topology/integrations/device/tests/test_wifi_mesh.py @@ -266,8 +266,14 @@ def test_topology_admin(self): """ admin = self._create_admin() self.client.force_login(admin) - topology = self._create_topology() - response = self.client.get( - reverse(f'{self.prefix}_topology_change', args=[topology.id]) - ) - self.assertContains(response, 'Wifi mesh') + + with self.subTest('Test add form'): + response = self.client.get(reverse(f'{self.prefix}_topology_add')) + self.assertContains(response, 'Wifi mesh') + + with self.subTest('Test change form'): + topology = self._create_topology() + response = self.client.get( + reverse(f'{self.prefix}_topology_change', args=[topology.id]) + ) + self.assertContains(response, 'Wifi mesh')