(request)
Update relationship type. Should be an AJAX POST.

    :param request: Django request object (Required)
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
Update relationship type. Should be an AJAX POST.
Update relationship type . Should be an AJAX POST .
def update_relationship_type(request):
    """
    Update relationship type. Should be an AJAX POST.

    :param request: Django request object (Required)
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
    """

    if request.method == 'POST' and request.is_ajax():
        user = request.user
        acl = get_acl_object(request.POST['my_type'])
        if user.has_access_to(acl.RELATIONSHIPS_EDIT):
            results = update_relationship_types(left_type=request.POST['my_type'],
                                                left_id=request.POST['my_value'],
                                                right_type=request.POST['reverse_type'],
                                                right_id=request.POST['dest_id'],
                                                rel_type=request.POST['forward_relationship'],
                                                rel_date=request.POST['relationship_date'],
                                                new_type=request.POST['new_relationship'],
                                                analyst=request.user.username)
        else:
            results = {'success':False,
                       'message':'User does not have permission to update relationship.'}
        if results['success']:
            message = "Successfully updated relationship: %s" % results['message']
            result = {'success': True, 'message': message}
        else:
            message = "Error updating relationship: %s" % results['message']
            result = {'success': False, 'message': message}
        return HttpResponse(json.dumps(result), content_type="application/json")
    else:
        error = "Expected AJAX POST"
        return render(request, "error.html",
                                  {"error" : error })
def update_relationship_type ( request ) : if request . method == 'POST' and request . is_ajax ( ) : user = request . user acl = get_acl_object ( request . POST [ 'my_type' ] ) if user . has_access_to ( acl . RELATIONSHIPS_EDIT ) : results = update_relationship_types ( left_type = request . POST [ 'my_type' ] , left_id = request . POST [ 'my_value' ] , right_type = request . POST [ 'reverse_type' ] , right_id = request . POST [ 'dest_id' ] , rel_type = request . POST [ 'forward_relationship' ] , rel_date = request . POST [ 'relationship_date' ] , new_type = request . POST [ 'new_relationship' ] , analyst = request . user . username ) else : results = { 'success' : False , 'message' : 'User does not have permission to update relationship.' } if results [ 'success' ] : message = "Successfully updated relationship: %s" % results [ 'message' ] result = { 'success' : True , 'message' : message } else : message = "Error updating relationship: %s" % results [ 'message' ] result = { 'success' : False , 'message' : message } return HttpResponse ( json . dumps ( result ) , content_type = "application/json" ) else : error = "Expected AJAX POST" return render ( request , "error.html" , { "error" : error } )