From d954c50097843363136efeec602833894db8321e Mon Sep 17 00:00:00 2001 From: Ken Raffenetti Date: Thu, 26 Oct 2006 22:11:03 +0000 Subject: fixed validation for newly added interfaces and ips from the host edit page git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2459 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Hostbase/hostbase/views.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/Server/Hostbase/hostbase/views.py b/src/lib/Server/Hostbase/hostbase/views.py index 9b342f188..1f8a6787b 100644 --- a/src/lib/Server/Hostbase/hostbase/views.py +++ b/src/lib/Server/Hostbase/hostbase/views.py @@ -1,8 +1,8 @@ -# Create your views here. """Views.py Contains all the views associated with the hostbase app Also has does form validation """ +__revision__ = "$Revision: $" from django.http import HttpResponse, HttpResponseRedirect @@ -53,7 +53,6 @@ dispatch = {'mac_addr':'i.mac_addr LIKE \'%%%%%s%%%%\'', ## t.failures = False ## return HttpResponse(str(t)) - def login(request): return render_to_response('login.html', {'next':'/hostbase'}) @@ -741,6 +740,15 @@ def validate(request, new=False, host_id=None): for number in request.POST['ip_addr%d' % ip.id].split(".") if (number.isdigit() and int(number) > 255 and 'ip_addr (%s)' % request.POST['ip_addr%d' % ip.id] not in failures)] + if (request.POST['%dip_addr' % interface.id] + and not regex.ipaddr.match(request.POST['%dip_addr' % interface.id])): + failures.append('ip_addr (%s)' % request.POST['%dip_addr' % interface.id]) + if (request.POST['mac_addr_new'] + and not regex.macaddr.match(request.POST['mac_addr_new'])): + failures.append('mac_addr (%s)' % request.POST['mac_addr_new']) + if (request.POST['ip_addr_new'] + and not regex.ipaddr.match(request.POST['ip_addr_new'])): + failures.append('ip_addr (%s)' % request.POST['ip_addr_new']) if not failures: return 0 -- cgit v1.2.3-1-g7c22