Esempio n. 1
0
def match(match_id):

    # Get User and Match
    match_id = request.form['match_id']
    user_id = request.form['user_id']
    user = get_user_from_user_id(user_id)
    match = get_match_from_match_id(match_id)

    # Decide which Users the Conversation is between
    x = ""
    if user.id is match.get_user_ids()[1]:
        otheruser_id = match.get_user_ids()[0]
    elif user.id is match.get_user_ids()[0]:
        otheruser_id = match.get_user_ids()[1]
    else:
        user_id = match.get_user_ids()[1]
        otheruser_id = match.get_user_ids()[0]
        x = " as wingman"
    print "match user ids are {} and {}, ids I'm using are {} and {}".format(match.get_user_ids()[0], match.get_user_ids()[1], user_id, otheruser_id)
    conversation = get_user_conversation_in_match(match_id, user_id, otheruser_id)
    conversation_messages = conversation.get_message_strings_list()
    conversation_length = len(conversation_messages)
    return render_template("match.html", user=user, match=match,
                           conversation=conversation,
                           conversation_messages=conversation_messages,
                           conversation_length=conversation_length, x=x)
Esempio n. 2
0
def addingmessage():
    conversation_id = request.form['conversation_id']
    conversation = get_conversation_from_conversation_id(conversation_id)
    print "conversation is: ", conversation
    match_id = request.form['match_id']
    user_id = request.form['user_id']
    user = get_user_from_user_id(user_id)
    match = get_match_from_match_id(match_id)
    newmessage = request.form['newmessage']
    print "New message is :", newmessage
    conversation.add_message(newmessage, user_id)
    conversation_messages = conversation.get_message_strings_list()
    conversation_length = len(conversation_messages)
    return render_template("match.html", user=user, match=match,
                           conversation=conversation,
                           conversation_messages=conversation_messages,
                           conversation_length=conversation_length,
                           x="")