fix formatting issues

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Alice Kile authored and James Valleroy committed 2019-12-07 13:08:35 -05:00
1 parent fa74a26042
commit eb83e00011
134 files changed
+598 -720

No files matched your search

+48 -77
View File
@@ -34,17 +34,15 @@ class ConnectionTypeSelectForm(forms.Form):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['connection_type'].widget.attrs.update({
'autofocus': 'autofocus'
})
self.fields['connection_type'].widget.attrs.update(
{'autofocus': 'autofocus'})
class ConnectionForm(forms.Form):
"""Base form to create/edit a connection."""
name = forms.CharField(label=_('Connection Name'))
interface = forms.ChoiceField(
label=_('Physical Interface'),
choices=(),
label=_('Physical Interface'), choices=(),
help_text=_('The network device that this connection should be bound '
'to.'))
zone = forms.ChoiceField(
@@ -52,90 +50,70 @@ class ConnectionForm(forms.Form):
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(
label=_('IPv4 Addressing Method'), help_text=format_lazy(
ugettext_lazy(
'"Automatic" method will make {box_name} acquire '
'configuration from this network making it a client. "Shared" '
'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')),
('disabled', _('Disabled'))])
choices=[('auto', _('Automatic (DHCP)')), ('shared', _('Shared')),
('manual', _('Manual')), ('disabled', _('Disabled'))])
ipv4_address = forms.CharField(
label=_('Address'),
validators=[validators.validate_ipv4_address],
label=_('Address'), validators=[validators.validate_ipv4_address],
required=False)
ipv4_netmask = forms.CharField(
label=_('Netmask'),
help_text=_('Optional value. If left blank, a default netmask '
'based on the address will be used.'),
validators=[validators.validate_ipv4_address],
required=False)
validators=[validators.validate_ipv4_address], required=False)
ipv4_gateway = forms.CharField(
label=_('Gateway'),
help_text=_('Optional value.'),
validators=[validators.validate_ipv4_address],
required=False)
label=_('Gateway'), help_text=_('Optional value.'),
validators=[validators.validate_ipv4_address], required=False)
ipv4_dns = forms.CharField(
label=_('DNS Server'),
help_text=_('Optional value. If this value is given and IPv4 '
'addressing method is "Automatic", the DNS Servers '
'provided by a DHCP server will be ignored.'),
validators=[validators.validate_ipv4_address],
required=False)
validators=[validators.validate_ipv4_address], required=False)
ipv4_second_dns = forms.CharField(
label=_('Second DNS Server'),
help_text=_('Optional value. If this value is given and IPv4 '
'Addressing Method is "Automatic", the DNS Servers '
'provided by a DHCP server will be ignored.'),
validators=[validators.validate_ipv4_address],
required=False)
validators=[validators.validate_ipv4_address], required=False)
ipv6_method = forms.ChoiceField(
label=_('IPv6 Addressing Method'),
help_text=format_lazy(
label=_('IPv6 Addressing Method'), help_text=format_lazy(
ugettext_lazy(
'"Automatic" methods will make {box_name} acquire '
'configuration from this network making it a client.'),
box_name=ugettext_lazy(cfg.box_name)),
choices=[('auto', _('Automatic')),
('dhcp', _('Automatic, DHCP only')),
('manual', _('Manual')),
('ignore', _('Ignore'))])
choices=[('auto', _('Automatic')), ('dhcp', _('Automatic, DHCP only')),
('manual', _('Manual')), ('ignore', _('Ignore'))])
ipv6_address = forms.CharField(
label=_('Address'),
validators=[validators.validate_ipv6_address],
required=False)
ipv6_prefix = forms.IntegerField(
label=_('Prefix'),
help_text=_('Value between 1 and 128.'),
min_value=1,
max_value=128,
label=_('Address'), validators=[validators.validate_ipv6_address],
required=False)
ipv6_prefix = forms.IntegerField(label=_('Prefix'),
help_text=_('Value between 1 and 128.'),
min_value=1, max_value=128,
required=False)
ipv6_gateway = forms.CharField(
label=_('Gateway'),
help_text=_('Optional value.'),
validators=[validators.validate_ipv6_address],
required=False)
label=_('Gateway'), help_text=_('Optional value.'),
validators=[validators.validate_ipv6_address], required=False)
ipv6_dns = forms.CharField(
label=_('DNS Server'),
help_text=_('Optional value. If this value is given and IPv6 '
'addressing method is "Automatic", the DNS Servers '
'provided by a DHCP server will be ignored.'),
validators=[validators.validate_ipv6_address],
required=False)
validators=[validators.validate_ipv6_address], required=False)
ipv6_second_dns = forms.CharField(
label=_('Second DNS Server'),
help_text=_('Optional value. If this value is given and IPv6 '
'Addressing Method is "Automatic", the DNS Servers '
'provided by a DHCP server will be ignored.'),
validators=[validators.validate_ipv6_address],
required=False)
validators=[validators.validate_ipv6_address], required=False)
@staticmethod
def _get_interface_choices(device_type):
@@ -143,8 +121,8 @@ class ConnectionForm(forms.Form):
interfaces = network.get_interface_list(device_type)
choices = [('', _('-- select --'))]
for interface, mac in interfaces.items():
display_string = '{interface} ({mac})'.format(interface=interface,
mac=mac)
display_string = '{interface} ({mac})'.format(
interface=interface, mac=mac)
choices.append((interface, display_string))
return choices
@@ -258,33 +236,29 @@ class PPPoEForm(EthernetForm):
class WifiForm(ConnectionForm):
"""Form to create/edit a Wi-Fi connection."""
field_order = ['name', 'interface', 'zone', 'ssid', 'mode', 'band',
'channel', 'bssid', 'auth_mode', 'passphrase',
'ipv4_method', 'ipv4_address', 'ipv4_netmask',
'ipv4_gateway', 'ipv4_dns', 'ipv4_second_dns',
'ipv6_method', 'ipv6_address', 'ipv6_prefix',
'ipv6_gateway', 'ipv6_dns', 'ipv6_second_dns']
field_order = [
'name', 'interface', 'zone', 'ssid', 'mode', 'band', 'channel',
'bssid', 'auth_mode', 'passphrase', 'ipv4_method', 'ipv4_address',
'ipv4_netmask', 'ipv4_gateway', 'ipv4_dns', 'ipv4_second_dns',
'ipv6_method', 'ipv6_address', 'ipv6_prefix', 'ipv6_gateway',
'ipv6_dns', 'ipv6_second_dns'
]
ssid = forms.CharField(
label=_('SSID'),
help_text=_('The visible name of the network.'))
ssid = forms.CharField(label=_('SSID'),
help_text=_('The visible name of the network.'))
mode = forms.ChoiceField(
label=_('Mode'),
choices=[('infrastructure', _('Infrastructure')),
('ap', _('Access Point')),
('adhoc', _('Ad-hoc'))])
label=_('Mode'), choices=[('infrastructure', _('Infrastructure')),
('ap', _('Access Point')),
('adhoc', _('Ad-hoc'))])
band = forms.ChoiceField(
label=_('Frequency Band'),
choices=[('auto', _('Automatic')),
('a', _('A (5 GHz)')),
('bg', _('B/G (2.4 GHz)'))])
label=_('Frequency Band'), choices=[('auto', _('Automatic')),
('a', _('A (5 GHz)')),
('bg', _('B/G (2.4 GHz)'))])
channel = forms.IntegerField(
label=_('Channel'),
help_text=_('Optional value. Wireless channel in the selected '
'frequency band to restrict to. Blank or 0 value means '
'automatic selection.'),
min_value=0,
max_value=255,
'automatic selection.'), min_value=0, max_value=255,
required=False)
bssid = forms.RegexField(
label=_('BSSID'),
@@ -292,18 +266,15 @@ class WifiForm(ConnectionForm):
'When connecting to an access point, connect only if the '
'BSSID of the access point matches the one provided. '
'Example: 00:11:22:aa:bb:cc.'),
regex=r'^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$',
required=False)
regex=r'^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$', required=False)
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'))])
passphrase = forms.CharField(
label=_('Passphrase'),
validators=[validators.MinLengthValidator(8)],
required=False)
choices=[('wpa', _('WPA')), ('open', _('Open'))])
passphrase = forms.CharField(label=_('Passphrase'),
validators=[validators.MinLengthValidator(8)],
required=False)
def __init__(self, *args, **kwargs):
"""Initialize the form, populate interface choices."""