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))
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))
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))