From a9ca2d7cc368bacf1ec98085889c2c9e6e74924a Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 13 Jul 2016 12:34:46 +0530 Subject: [PATCH] networks: Add 'disabled' IPv4 method, i18n Disabled IPv4 method allows not configuring IPv4 entirely on network interfaces as required in some cases. Also, make sure to internationalize all the choices form values in network module. There were missed before. --- plinth/modules/networks/forms.py | 19 +++++++++++-------- .../networks/templates/connections_edit.html | 5 ++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/plinth/modules/networks/forms.py b/plinth/modules/networks/forms.py index 9408b24d2..0850c1fd4 100644 --- a/plinth/modules/networks/forms.py +++ b/plinth/modules/networks/forms.py @@ -45,7 +45,8 @@ class ConnectionForm(forms.Form): label=_('Firewall Zone'), help_text=_('The firewall zone will control which services are \ available over this interfaces. Select Internal only for trusted networks.'), - choices=[('external', 'External'), ('internal', 'Internal')]) + choices=[('external', _('External')), + ('internal', _('Internal'))]) ipv4_method = forms.ChoiceField( label=_('IPv4 Addressing Method'), help_text=format_lazy( @@ -55,9 +56,10 @@ available over this interfaces. Select Internal only for trusted networks.'), 'method will make {box_name} act as a router, configure ' 'clients on this network and share its Internet connection.'), box_name=ugettext_lazy(cfg.box_name)), - choices=[('auto', 'Automatic (DHCP)'), - ('shared', 'Shared'), - ('manual', 'Manual')]) + choices=[('auto', _('Automatic (DHCP)')), + ('shared', _('Shared')), + ('manual', _('Manual')), + ('disabled', _('Disabled'))]) ipv4_address = forms.CharField( label=_('Address'), validators=[validators.validate_ipv4_address], @@ -195,14 +197,15 @@ class WifiForm(ConnectionForm): help_text=_('The visible name of the network.')) mode = forms.ChoiceField( label=_('Mode'), - choices=[('infrastructure', 'Infrastructure'), - ('ap', 'Access Point'), - ('adhoc', 'Ad-hoc')]) + choices=[('infrastructure', _('Infrastructure')), + ('ap', _('Access Point')), + ('adhoc', _('Ad-hoc'))]) auth_mode = forms.ChoiceField( label=_('Authentication Mode'), help_text=_('Select WPA if the wireless network is secured and \ requires clients to have the password to connect.'), - choices=[('wpa', 'WPA'), ('open', 'Open')]) + choices=[('wpa', _('WPA')), + ('open', _('Open'))]) passphrase = forms.CharField( label=_('Passphrase'), validators=[validators.MinLengthValidator(8)], diff --git a/plinth/modules/networks/templates/connections_edit.html b/plinth/modules/networks/templates/connections_edit.html index d73f923de..ee9fa5740 100644 --- a/plinth/modules/networks/templates/connections_edit.html +++ b/plinth/modules/networks/templates/connections_edit.html @@ -68,9 +68,12 @@ ipv4_required(false, ['address']); ipv4_readonly(false, ['address', 'netmask']); ipv4_readonly(true, ['gateway', 'dns', 'second_dns']); - } else { + } else if ($("#id_ipv4_method").prop("value") == "auto") { ipv4_readonly(true, ['address', 'netmask', 'gateway']); ipv4_readonly(false, ['dns', 'second_dns']); + } else { + ipv4_readonly(true, ['address', 'netmask', 'gateway', 'dns', + 'second_dns']); } }