Example #1
0
def f_req(request):
    if request.method == "POST":
        new_request = AddFriendRequest(
            current_user=request.POST["current_user"], request_user=request.POST["request_user"]
        )
        createRequest(new_request.current_user, new_request.request_user)
        return JsonResponse({"abcd": "reached_here"})

    if request.method == "GET":
        url = "http://192.168.0.108:8000/media/"
        # print("iam here")
        get_request = GetFriendRequests(current_user=request.GET["current_user"])
        friend_requests = getFriendRequests(get_request.current_user)
        request_user_array = []
        final_user_array_object = {}
        for friend_request in friend_requests:
            user = User.inflate(friend_request[0])
            request_user_data = user.name
            request_user_image_url = getDp(user.name).name
            record = {"uid": request_user_data, "url": url + request_user_image_url}
            print record
            request_user_array.append(record)
            # print user.name
        final_user_array_object["req_users"] = request_user_array
        return JsonResponse(final_user_array_object)
Example #2
0
def existUser(user):
    exists = []
    query = "MATCH (a:User{name: {no_name}}) return a"
    results, columns = db.cypher_query(query, {"no_name": user})
    for row in results:
        exists = User.inflate(row[0])
    if not exists:
        return False
    else:
        return True