mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
made the latest changes pep8 compatible
This commit is contained in:
parent
81ad2019b1
commit
df0d1304b7
@ -71,19 +71,22 @@ class TrimmedCharField(forms.CharField):
|
|||||||
class ConfigureForm(forms.Form):
|
class ConfigureForm(forms.Form):
|
||||||
"""Form to configure the dynamic DNS client"""
|
"""Form to configure the dynamic DNS client"""
|
||||||
enabled = forms.BooleanField(label=_('Enable Dynamic DNS'),
|
enabled = forms.BooleanField(label=_('Enable Dynamic DNS'),
|
||||||
required=False,widget=forms.CheckboxInput
|
required=False, widget=forms.CheckboxInput
|
||||||
(attrs={'onclick': 'mod_form();'}))
|
(attrs={'onclick': 'mod_form();'}))
|
||||||
|
|
||||||
dynamicdns_service = forms.ChoiceField(label=_('Service type'),
|
service_type = forms.ChoiceField(label=_('Service type'),
|
||||||
help_text=_('Please choose a update protocol according to your provider.\
|
help_text=_('Please choose a update\
|
||||||
We recommend the GnudIP protocol. If your provider does not \
|
protocol according to your \
|
||||||
support the GnudIP protocol or your provider is not listed \
|
provider. If your provider does not\
|
||||||
you may use the update URL of your provider.'),
|
support the GnudIP protocol or your\
|
||||||
choices=(('1', 'GnuDIP'),
|
provider is not listed you may use\
|
||||||
('2', 'noip.com'),
|
the update URL of your provider.'),
|
||||||
('3', 'selfhost.bz'),
|
choices=(('1', 'GnuDIP'),
|
||||||
('4', 'other Update URL')),
|
('2', 'noip.com'),
|
||||||
widget=forms.Select(attrs={'onChange':'dropdown()'}))
|
('3', 'selfhost.bz'),
|
||||||
|
('4', 'other Update URL')),
|
||||||
|
widget=forms.Select(attrs={'onChange':
|
||||||
|
'dropdown()'}))
|
||||||
|
|
||||||
dynamicdns_server = TrimmedCharField(
|
dynamicdns_server = TrimmedCharField(
|
||||||
label=_('GnudIP Server Address'),
|
label=_('GnudIP Server Address'),
|
||||||
@ -92,23 +95,24 @@ class ConfigureForm(forms.Form):
|
|||||||
validators=[
|
validators=[
|
||||||
validators.RegexValidator(r'^[\w-]{1,63}(\.[\w-]{1,63})*$',
|
validators.RegexValidator(r'^[\w-]{1,63}(\.[\w-]{1,63})*$',
|
||||||
_('Invalid server name'))])
|
_('Invalid server name'))])
|
||||||
|
|
||||||
dynamicdns_update_url = TrimmedCharField(
|
dynamicdns_update_url = TrimmedCharField(label=_('Update URL'),
|
||||||
label=_('Update URL'),
|
required=False,
|
||||||
required=False,
|
help_text=_('The Variables $User\
|
||||||
help_text=_('The Variables $User, $Pass, $IP, $Domain may be used \
|
, $Pass, $IP, $Domain\
|
||||||
within this URL.</br> Example URL: </br> \
|
may be used'))
|
||||||
https://some.tld/up.php?us=$User&pw=$Pass&ip=$IP&dom=$Domain'))
|
|
||||||
|
disable_SSL_cert_check = forms.BooleanField(label=_('accept all SSL \
|
||||||
disable_SSL_cert_check = forms.BooleanField(
|
certificates'),
|
||||||
label=_('accept all SSL certificates'),
|
help_text=_('use this option \
|
||||||
help_text=_('use this option if your provider uses\
|
if your provider \
|
||||||
self signed certificates'),
|
uses self signed\
|
||||||
required=False)
|
certificates'),
|
||||||
|
required=False)
|
||||||
use_http_basic_auth = forms.BooleanField(
|
|
||||||
label=_('use HTTP basic authentication'),
|
use_http_basic_auth = forms.BooleanField(label=_('use HTTP basic \
|
||||||
required=False)
|
authentication'),
|
||||||
|
required=False)
|
||||||
|
|
||||||
dynamicdns_domain = TrimmedCharField(
|
dynamicdns_domain = TrimmedCharField(
|
||||||
label=_('Domain Name'),
|
label=_('Domain Name'),
|
||||||
@ -210,7 +214,7 @@ def get_status():
|
|||||||
output = actions.run('dynamicdns', 'status')
|
output = actions.run('dynamicdns', 'status')
|
||||||
details = output.split()
|
details = output.split()
|
||||||
status['enabled'] = (output.split()[0] == 'enabled')
|
status['enabled'] = (output.split()[0] == 'enabled')
|
||||||
|
|
||||||
if len(details) > 1:
|
if len(details) > 1:
|
||||||
if details[1] == 'disabled':
|
if details[1] == 'disabled':
|
||||||
status['dynamicdns_server'] = ''
|
status['dynamicdns_server'] = ''
|
||||||
@ -250,7 +254,7 @@ def get_status():
|
|||||||
status['dynamicdns_ipurl'] = details[5]
|
status['dynamicdns_ipurl'] = details[5]
|
||||||
else:
|
else:
|
||||||
status['dynamicdns_ipurl'] = ''
|
status['dynamicdns_ipurl'] = ''
|
||||||
|
|
||||||
if len(details) > 6:
|
if len(details) > 6:
|
||||||
if details[6] == 'disabled':
|
if details[6] == 'disabled':
|
||||||
status['dynamicdns_update_url'] = ''
|
status['dynamicdns_update_url'] = ''
|
||||||
@ -258,23 +262,23 @@ def get_status():
|
|||||||
status['dynamicdns_update_url'] = details[6]
|
status['dynamicdns_update_url'] = details[6]
|
||||||
else:
|
else:
|
||||||
status['dynamicdns_update_url'] = ''
|
status['dynamicdns_update_url'] = ''
|
||||||
|
|
||||||
if len(details) > 7:
|
if len(details) > 7:
|
||||||
status['disable_SSL_cert_check'] = (output.split()[7] == 'enabled')
|
status['disable_SSL_cert_check'] = (output.split()[7] == 'enabled')
|
||||||
else:
|
else:
|
||||||
status['disable_SSL_cert_check'] = False
|
status['disable_SSL_cert_check'] = False
|
||||||
|
|
||||||
if len(details) > 8:
|
if len(details) > 8:
|
||||||
status['use_http_basic_auth'] = (output.split()[8] == 'enabled')
|
status['use_http_basic_auth'] = (output.split()[8] == 'enabled')
|
||||||
else:
|
else:
|
||||||
status['use_http_basic_auth'] = False
|
status['use_http_basic_auth'] = False
|
||||||
|
|
||||||
if not status['dynamicdns_server'] and not status['dynamicdns_update_url']:
|
if not status['dynamicdns_server'] and not status['dynamicdns_update_url']:
|
||||||
status['dynamicdns_service'] = '1'
|
status['service_type'] = '1'
|
||||||
elif not status['dynamicdns_server'] and status['dynamicdns_update_url']:
|
elif not status['dynamicdns_server'] and status['dynamicdns_update_url']:
|
||||||
status['dynamicdns_service'] = '4'
|
status['service_type'] = '4'
|
||||||
else:
|
else:
|
||||||
status['dynamicdns_service'] = '1'
|
status['service_type'] = '1'
|
||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
@ -309,15 +313,15 @@ def _apply_changes(request, old_status, new_status):
|
|||||||
old_status['enabled'] != \
|
old_status['enabled'] != \
|
||||||
new_status['enabled']:
|
new_status['enabled']:
|
||||||
|
|
||||||
disable_ssl_check="disabled"
|
disable_ssl_check = "disabled"
|
||||||
use_http_basic_auth="disabled"
|
use_http_basic_auth = "disabled"
|
||||||
|
|
||||||
if new_status['disable_SSL_cert_check']:
|
if new_status['disable_SSL_cert_check']:
|
||||||
disable_ssl_check = "enabled"
|
disable_ssl_check = "enabled"
|
||||||
|
|
||||||
if new_status['use_http_basic_auth']:
|
if new_status['use_http_basic_auth']:
|
||||||
use_http_basic_auth = "enabled"
|
use_http_basic_auth = "enabled"
|
||||||
|
|
||||||
_run(['configure', '-s', new_status['dynamicdns_server'],
|
_run(['configure', '-s', new_status['dynamicdns_server'],
|
||||||
'-d', new_status['dynamicdns_domain'],
|
'-d', new_status['dynamicdns_domain'],
|
||||||
'-u', new_status['dynamicdns_user'],
|
'-u', new_status['dynamicdns_user'],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user