def delete_route(request):
  if request.method == "POST":
    ip = request.POST.get('ip')
    netmask = request.POST.get('netmask')
    gateway = request.POST.get('gateway')
    status,err = route.delete_route(ip,netmask)
    if err:
        return_dict['error'] = err
        return django.http.HttpResponseRedirect('/view_routes/')
    else:
        return django.http.HttpResponseRedirect('/view_routes/')
  else:
    return django.http.HttpResponseRedirect('/view_routes/')
Exemplo n.º 2
0
def delete_route(request):
    if request.method == "POST":
        ip = request.POST.get('ip')
        netmask = request.POST.get('netmask')
        gateway = request.POST.get('gateway')
        status, err = route.delete_route(ip, netmask)
        if err:
            return_dict['error'] = err
            return django.http.HttpResponseRedirect('/view_routes/')
        else:
            return django.http.HttpResponseRedirect('/view_routes/')
    else:
        return django.http.HttpResponseRedirect('/view_routes/')
def edit_route(request):
  return_dict = {}
  if request.method == 'GET':
    form = networking_forms.CreateRouteForm(request.GET)
  else:
    form = networking_forms.CreateRouteForm(request.POST)
    if form.is_valid():
      cd = form.cleaned_data
      status,err = route.delete_route(cd['ip'],cd['netmask'])
      status,err = route.add_route(cd['ip'],cd['gateway'],cd['netmask'],cd['interface'])
      if err:
        return_dict['error'] = err
      else:
        return django.http.HttpResponseRedirect('/view_routes/')
  return_dict['form'] = form
  return django.shortcuts.render_to_response("create_route.html", return_dict, context_instance=django.template.context.RequestContext(request))
  pass
Exemplo n.º 4
0
def edit_route(request):
    return_dict = {}
    if request.method == 'GET':
        form = networking_forms.CreateRouteForm(request.GET)
    else:
        form = networking_forms.CreateRouteForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            status, err = route.delete_route(cd['ip'], cd['netmask'])
            status, err = route.add_route(cd['ip'], cd['gateway'],
                                          cd['netmask'], cd['interface'])
            if err:
                return_dict['error'] = err
            else:
                return django.http.HttpResponseRedirect('/view_routes/')
    return_dict['form'] = form
    return django.shortcuts.render_to_response(
        "create_route.html",
        return_dict,
        context_instance=django.template.context.RequestContext(request))
    pass