예제 #1
0
파일: views.py 프로젝트: optionstvm/crits
def edit_config(request, name):
    """
    Edit a service's configuration.
    """

    analyst = request.user.username
    if request.method == "POST":
        results = do_edit_config(name, analyst, post_data=request.POST)
        if results['success'] == True:
            return redirect(reverse('crits.services.views.detail', args=[name]))
        else:
            return render_to_response('services_edit_config.html',
                                      {'form': results['form'],
                                       'service': results['service'],
                                       'config_error': results['config_error']},
                                      RequestContext(request))
    else:
        results = do_edit_config(name, analyst)
        if results['success'] == True:
            return render_to_response('services_edit_config.html',
                                      {'form': results['form'],
                                       'service': results['service']},
                                      RequestContext(request))
        else:
            return render_to_response('error.html', {'error': error},
                                      RequestContext(request))
예제 #2
0
def edit_config(request, name):
    """
    Edit a service's configuration.
    """

    analyst = request.user.username
    if request.method == "POST" and request.is_ajax():
        results = do_edit_config(name, analyst, post_data=request.POST)
        if 'service' in results:
            del results['service']
        return HttpResponse(json.dumps(results), content_type="application/json")
    elif request.method == "POST" and not request.is_ajax():
        error = results['config_error']
        return render_to_response('error.html',
                                  {'error': "Expected AJAX POST."},
                                  RequestContext(request))
    else:
        results = do_edit_config(name, analyst)
        if results['success'] == True:
            return render_to_response('services_edit_config.html',
                                      {'form': results['form'],
                                       'service': results['service']},
                                      RequestContext(request))
        else:
            error = results['config_error']
            return render_to_response('error.html', {'error': error},
                                      RequestContext(request))
예제 #3
0
파일: views.py 프로젝트: landw1re/crits
def edit_config(request, name):
    """
    Edit a service's configuration.
    """

    analyst = request.user.username
    if request.method == "POST":
        results = do_edit_config(name, analyst, post_data=request.POST)
        if results['success'] == True:
            return redirect(reverse('crits.services.views.detail',
                                    args=[name]))
        else:
            return render_to_response(
                'services_edit_config.html', {
                    'form': results['form'],
                    'service': results['service'],
                    'config_error': results['config_error']
                }, RequestContext(request))
    else:
        results = do_edit_config(name, analyst)
        if results['success'] == True:
            return render_to_response('services_edit_config.html', {
                'form': results['form'],
                'service': results['service']
            }, RequestContext(request))
        else:
            error = results['config_error']
            return render_to_response('error.html', {'error': error},
                                      RequestContext(request))