From c4b21b014b98209df9e85f43489370efe2543c9f Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 29 Dec 2024 14:41:30 -0800 Subject: [PATCH] networks: Fix error during creation of PPPoE connections - Currently, when trying to create PPPoE connection, we get an exception that dns_over_tls key is not found in the form's cleaned_data. Fix this by not expecting the field to be present only for PPPoE connections. Tests: - Edit a regular Ethernet connection and change the value of DNS-over-TLS to all the different values and notice that the value is updated as expected. - Create a regular Ethernet connection with non-default value for DNS-over-TLS. The value for DNS-over-TLS on the connection set as expected. - Create/edit/delete of a PPPoE connection works. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/networks/forms.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plinth/modules/networks/forms.py b/plinth/modules/networks/forms.py index 9a6d9467d..79bb045f0 100644 --- a/plinth/modules/networks/forms.py +++ b/plinth/modules/networks/forms.py @@ -195,12 +195,16 @@ class ConnectionForm(forms.Form): 'name': self.cleaned_data['name'], 'interface': self.cleaned_data['interface'], 'zone': self.cleaned_data['zone'], - 'dns_over_tls': self.cleaned_data['dns_over_tls'], } + settings['common'] |= self.get_privacy_settings() settings['ipv4'] = self.get_ipv4_settings() settings['ipv6'] = self.get_ipv6_settings() return settings + def get_privacy_settings(self) -> dict[str, object]: + """Return privacy dict from cleaned data.""" + return {'dns_over_tls': self.cleaned_data['dns_over_tls']} + def get_ipv4_settings(self): """Return IPv4 dict from cleaned data.""" ipv4 = { @@ -290,6 +294,10 @@ class PPPoEForm(EthernetForm): } return settings + def get_privacy_settings(self) -> dict[str, object]: + """Return privacy dict from cleaned data.""" + return {} + def get_ipv4_settings(self): """Return IPv4 settings from cleaned data.""" return None