From 9fbe9754f631bae7de6a92288e7e74e455f5deba Mon Sep 17 00:00:00 2001 From: Daniel Steglich Date: Mon, 5 Jan 2015 17:29:12 +0000 Subject: [PATCH] refactored configuration action to avoid multiple start/stop calls of the action script when the configuration changes --- plinth/modules/dynamicdns/dynamicdns.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/plinth/modules/dynamicdns/dynamicdns.py b/plinth/modules/dynamicdns/dynamicdns.py index 3d2b1bc6d..ddf467312 100644 --- a/plinth/modules/dynamicdns/dynamicdns.py +++ b/plinth/modules/dynamicdns/dynamicdns.py @@ -234,25 +234,24 @@ def _apply_changes(request, old_status, new_status): old_status['dynamicdns_secret'] != \ new_status['dynamicdns_secret'] or \ old_status['dynamicdns_ipurl'] != \ - new_status['dynamicdns_ipurl']: + new_status['dynamicdns_ipurl'] or \ + old_status['enabled'] != \ + new_status['enabled']: _run(['configure', '-s', new_status['dynamicdns_server'], '-d', new_status['dynamicdns_domain'], '-u', new_status['dynamicdns_user'], '-p', new_status['dynamicdns_secret'], '-I', new_status['dynamicdns_ipurl']]) - _run(['stop']) - _run(['start']) - messages.success(request, - _('Dynamic DNS configuration is updated!')) - if old_status['enabled'] != new_status['enabled']: + if old_status['enabled']: + _run(['stop']) + if new_status['enabled']: _run(['start']) - messages.success(request, _('Dynamic DNS is enabled now!')) - else: - _run(['stop']) - messages.success(request, _('Dynamic DNS is disabled now!')) + + messages.success(request, + _('Dynamic DNS configuration is updated!')) else: messages.error(request, _('At least on failure occured,\