def update_objects_source(request): """ Update an object's source. Should be an AJAX POST. :param request: The Django request. :type request: :class:`django.http.HttpRequest` :returns: :class:`django.http.HttpResponse` """ if request.method == "POST" and request.is_ajax(): type_ = request.POST["coll"] oid = request.POST["oid"] name = request.POST.get("name") object_type = request.POST.get("type") value = request.POST["value"] new_source = request.POST["new_source"] new_method = request.POST["new_method"] new_reference = request.POST["new_reference"] analyst = "%s" % request.user.username results = update_object_source( type_, oid, object_type, name, value, new_source, new_method, new_reference, analyst ) if results["success"]: message = "Successfully updated object source: %s" % results["message"] result = {"success": True, "message": message} else: message = "Error updating object source: %s" % results["message"] result = {"success": False, "message": message} return HttpResponse(json.dumps(result), mimetype="application/json") else: error = "Expected AJAX POST" return render_to_response("error.html", {"error": error}, RequestContext(request))
def update_objects_source(request): """ Update an object's source. Should be an AJAX POST. :param request: The Django request. :type request: :class:`django.http.HttpRequest` :returns: :class:`django.http.HttpResponse` """ if request.method == 'POST' and request.is_ajax(): type_ = request.POST['coll'] oid = request.POST['oid'] object_type = request.POST.get('type') value = request.POST['value'] new_source = request.POST['new_source'] new_method = request.POST['new_method'] new_reference = request.POST['new_reference'] analyst = "%s" % request.user.username results = update_object_source(type_, oid, object_type, value, new_source, new_method, new_reference, analyst) if results['success']: message = "Successfully updated object source: %s" % results[ 'message'] result = {'success': True, 'message': message} else: message = "Error updating object source: %s" % results['message'] result = {'success': False, 'message': message} return HttpResponse(json.dumps(result), content_type="application/json") else: error = "Expected AJAX POST" return render_to_response("error.html", {"error": error}, RequestContext(request))
def update_objects_source(request): """ Update an object's source. Should be an AJAX POST. :param request: The Django request. :type request: :class:`django.http.HttpRequest` :returns: :class:`django.http.HttpResponse` """ if request.method == 'POST' and request.is_ajax(): type_ = request.POST['coll'] oid = request.POST['oid'] name = request.POST.get('name') object_type = request.POST.get('type') value = request.POST['value'] new_source = request.POST['new_source'] new_method = request.POST['new_method'] new_reference = request.POST['new_reference'] analyst = "%s" % request.user.username results = update_object_source(type_, oid, object_type, name, value, new_source, new_method, new_reference, analyst) if results['success']: message = "Successfully updated object source: %s" % results['message'] result = {'success': True, 'message': message} else: message = "Error updating object source: %s" % results['message'] result = {'success': False, 'message': message} return HttpResponse(json.dumps(result), mimetype="application/json") else: error = "Expected AJAX POST" return render_to_response("error.html", {"error" : error }, RequestContext(request))