covered empty server arguments and made parameter comparsion more easy

This commit is contained in:
Daniel Steglich 2015-03-05 14:03:11 +01:00
parent 21f0aeef1c
commit e42b8e5015
3 changed files with 21 additions and 23 deletions

View File

@ -54,7 +54,11 @@ doGetOpt()
while getopts ":s:d:u:p:I:U:c:b:" opt; do
case ${opt} in
s)
server=${OPTARG}
if [ "${OPTARG}" != "${EMPTYSTRING}" ];then
server=${OPTARG}
else
server=""
fi
;;
d)
host=${OPTARG}

View File

@ -29,6 +29,7 @@ from plinth import cfg
from plinth import package
LOGGER = logging.getLogger(__name__)
EMPTYSTRING = 'none'
subsubmenu = [{'url': reverse_lazy('dynamicdns:index'),
'text': _('About')},
@ -170,12 +171,15 @@ class ConfigureForm(forms.Form):
dynamicdns_server = cleaned_data.get('dynamicdns_server')
old_dynamicdns_secret = self.initial['dynamicdns_secret']
"""Todo: this is not working!! will see tomorrow why"""
if not dynamicdns_update_url and not dynamicdns_server:
raise forms.ValidationError('please give update URL or \
a GnuDIP Server')
LOGGER.info('no server address given')
if not dynamicdns_secret and not old_dynamicdns_secret:
raise forms.ValidationError('please give a password')
LOGGER.info('no password given')
@login_required
@ -311,27 +315,15 @@ def _apply_changes(request, old_status, new_status):
new_status['dynamicdns_secret'] = old_status['dynamicdns_secret']
if new_status['dynamicdns_ipurl'] == '':
new_status['dynamicdns_ipurl'] = 'none'
new_status['dynamicdns_ipurl'] = EMPTYSTRING
if old_status['dynamicdns_server'] != \
new_status['dynamicdns_server'] or \
old_status['dynamicdns_domain'] != \
new_status['dynamicdns_domain'] or \
old_status['dynamicdns_user'] != \
new_status['dynamicdns_user'] or \
old_status['dynamicdns_secret'] != \
new_status['dynamicdns_secret'] or \
old_status['dynamicdns_ipurl'] != \
new_status['dynamicdns_ipurl'] or \
old_status['dynamicdns_update_url'] != \
new_status['dynamicdns_update_url'] or \
old_status['disable_SSL_cert_check'] != \
new_status['disable_SSL_cert_check'] or \
old_status['use_http_basic_auth'] != \
new_status['use_http_basic_auth'] or \
old_status['enabled'] != \
new_status['enabled']:
if new_status['dynamicdns_update_url'] == '':
new_status['dynamicdns_update_url'] = EMPTYSTRING
if new_status['dynamicdns_server'] == '':
new_status['dynamicdns_server'] = EMPTYSTRING
if old_status != new_status:
disable_ssl_check = "disabled"
use_http_basic_auth = "disabled"
@ -357,6 +349,8 @@ def _apply_changes(request, old_status, new_status):
messages.success(request,
_('Dynamic DNS configuration is updated!'))
else:
LOGGER.info('nothing changed')
def _run(arguments, superuser=False):

View File

@ -14,7 +14,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see http://www.gnu.org/licenses/.
#
{% endcomment %}
@ -32,8 +32,8 @@
<h3>Dynamic DNS type</h3>
<div id='dynamicdns-no-js'>
You have disabled Javascript. Dynamic form mode is disabled and
some helper functions may not work </br> (but the main functionality should work)
</br><hr>
some helper functions may not work <br> (but the main functionality should work)
<br><hr>
</div>
<div id='div-dynamicdns-dropdown' style="display:none">
{% include 'bootstrapform/field.html' with field=form.service_type %}