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)
def happy(user_id): pair_id = request.form['pair_shown_id'] pair_matched = get_pair_from_pair_id(pair_id) user_id = request.form['user_id'] user = get_user_from_user_id(user_id) user.make_pair_match(pair_matched) return render_template("happy.html", user=user, pair_matched=pair_matched)
def sad(user_id): pair_id = request.form['pair_shown_id'] pair_shown = get_pair_from_pair_id(pair_id) user_id = request.form['user_id'] user = get_user_from_user_id(user_id) pair_shown.decline_this_pair(user_id) log.debug("Pair: {} declined by: {}".format(pair_shown, user)) return render_template("sad.html", user=user, pair_shown=pair_shown)
def matchmake(user_id): user_id = request.form['user_id'] user = get_user_from_user_id(user_id) log.debug("MATCHMAKE {}".format(user.username)) try: next_pair = user.get_next_pair() log.debug("Offering {} for user {}".format(next_pair, user)) error = None descriptions = next_pair.get_descriptions() except Exception: next_pair = None descriptions = ["nothing", "nothing"] error = "no pairs" return render_template("matchmake.html", user=user, next_pair=next_pair, error=error, descriptions=descriptions)
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="")
match1 = dom.make_pair_match(dom_next_pair) print "Made match 1 with id: ", match1.id # new match - success dom_next_pair = dom.get_next_pair() print "Dom's next pair is: ", dom_next_pair match2 = dom.make_pair_match(dom_next_pair) print "Made match 2 with id: ", match2.id # test wingman matches dom_wingman_matches = dom.matches_as_wingman() print "Dom has wingmanned for: {}".format(dom_wingman_matches) # new match - fail on too many dom_next_pair = dom.get_next_pair() print "Dom's next pair is: ", dom_next_pair match3 = dom.make_pair_match(dom_next_pair) print "Made match 3 with id: ", match3.id user = get_user_from_user_id(2) print user
def edit_profile(user_id): user_id = request.form['user_id'] user = get_user_from_user_id(user_id) return render_template("profile.html", user=user)
def home(user_id): user_id = request.form['user_id'] user = get_user_from_user_id(user_id) return render_template("home.html", user=user)
def matches(user_id): user_id = request.form['user_id'] user = get_user_from_user_id(user_id) return render_template("matches.html", user=user)