removed dictionary because string values can be used in dropdown menu directly

This commit is contained in:
Daniel Steglich 2015-03-13 14:09:58 +01:00
parent 337fa56b15
commit 8af4ee423a
2 changed files with 15 additions and 22 deletions

View File

@ -30,13 +30,6 @@ from plinth import package
LOGGER = logging.getLogger(__name__)
EMPTYSTRING = 'none'
SERVICE = {
"GnuDIP": "1",
"noip": "2",
"selfhost": "3",
"freedns": "4",
"other": "5",
}
subsubmenu = [{'url': reverse_lazy('dynamicdns:index'),
'text': _('About')},
@ -113,11 +106,11 @@ class ConfigureForm(forms.Form):
"""ToDo: sync this list with the html template file"""
provider_choices = (
('1', 'GnuDIP'),
('2', 'noip.com'),
('3', 'selfhost.bz'),
('4', 'freedns.afraid.org'),
('5', 'other update URL'))
('GnuDIP', 'GnuDIP'),
('noip', 'noip.com'),
('selfhost', 'selfhost.bz'),
('freedns', 'freedns.afraid.org'),
('other', 'other update URL'))
enabled = forms.BooleanField(label=_('Enable Dynamic DNS'),
required=False)
@ -187,7 +180,7 @@ class ConfigureForm(forms.Form):
old_dynamicdns_secret = self.initial['dynamicdns_secret']
"""clear the fields which are not in use"""
if service_type == SERVICE['GnuDIP']:
if service_type == 'GnuDIP':
dynamicdns_update_url = ""
else:
dynamicdns_server = ""
@ -328,11 +321,11 @@ def get_status():
status['use_http_basic_auth'] = False
if not status['dynamicdns_server'] and not status['dynamicdns_update_url']:
status['service_type'] = SERVICE['GnuDIP']
status['service_type'] = 'GnuDIP'
elif not status['dynamicdns_server'] and status['dynamicdns_update_url']:
status['service_type'] = SERVICE['other']
status['service_type'] = 'other'
else:
status['service_type'] = SERVICE['GnuDIP']
status['service_type'] = 'GnuDIP'
return status
@ -354,7 +347,7 @@ def _apply_changes(request, old_status, new_status):
if new_status['dynamicdns_server'] == '':
new_status['dynamicdns_server'] = EMPTYSTRING
if new_status['service_type'] == SERVICE['GnuDIP']:
if new_status['service_type'] == 'GnuDIP':
new_status['dynamicdns_update_url'] = EMPTYSTRING
else:
new_status['dynamicdns_server'] = EMPTYSTRING

View File

@ -118,16 +118,16 @@
if ( $("#id_dynamicdns_server").val().length == 0 ) {
set_update_url_mode()
if ( update_url == NOIP) {
$("#id_service_type").val(2);
$("#id_service_type").val("noip");
} else if ( update_url == SELFHOST) {
$("#id_service_type").val(3);
$("#id_service_type").val("selfhost");
} else if ( update_url == FREEDNS) {
$("#id_service_type").val(4);
$("#id_service_type").val("freedns");
} else {
$("#id_service_type").val(5);
$("#id_service_type").val("other");
}
} else {
$("#id_service_type").val(1);
$("#id_service_type").val("GnuDIP");
set_gnudip_mode();
}
}