コード例 #1
0
def creator_profile(creator):
    creator = creator
    profil = fetchall(
        "select profile.info, profile.level, profile.age, profile.location FROM((Match join registration on Match.creator = registration.username)join profile on registration.pid = profile.pid) WHERE creator = %s",
        [creator])
    img = fetchall(
        "select profile.img FROM((Match join registration on Match.creator = registration.username)join profile on registration.pid = profile.pid) WHERE creator = %s",
        [creator])
    print(profil)
    print(img)

    return render_template("creator_profile.html",
                           creator=creator,
                           profil=profil,
                           img=img)
コード例 #2
0
def start_page():
    print(session.get("username"))
    print(session.get("logged_in"))

    if not session.get("logged_in"):
        print("No username found in session")
        return log_in()
    else:
        print("Success")
        img = fetchone(
            "select img from(profile join registration on profile.pid = registration.pid) where username = %s",
            [session["username"]])

        profileInfo = []
        profileInfo = fetchall(
            "select * from(profile join registration on profile.pid = registration.pid) where username = %s",
            [session["username"]])

        personName = fetchone(
            "select name from(person join registration on person.pid = registration.pid) where username = %s",
            [session["username"]])
        session["logged_in"] = True

        return render_template("welcome.html",
                               picture=img,
                               user=session["username"],
                               profileInfo=profileInfo,
                               personName=personName)
コード例 #3
0
def show_Game(ort, klass, antal):
    print(ort, klass, antal)
    # check if creator name is username session, then don't show.
    sql = "select ort, klass, antal, match.matchid, booked from(match join booking on match.matchid = booking.matchid) where ort = %s AND klass = %s AND antal = %s AND antal > 0;"
    val = ort, klass, antal
    games = fetchall(sql, val)
    return games
コード例 #4
0
def user_log():
    if user_login.log_in() == True:
        username = request.form["userName"]
        img = fetchone(
            "select img from(profile join registration on profile.pid = registration.pid) where username = %s",
            [username])
        profileInfo = []
        profileInfo = fetchall(
            "select * from(profile join registration on profile.pid = registration.pid) where username = %s",
            [username])

        personName = fetchone(
            "select name from(person join registration on person.pid = registration.pid) where username = %s",
            [username])
        session["username"] = username
        session["logged_in"] = True
        return render_template("welcome.html",
                               picture=img,
                               user=session["username"],
                               profileInfo=profileInfo,
                               personName=personName)

    elif user_login.log_in() == False:
        flash("Fel lösenord eller användarnamn")
        return render_template("log_in.html", username="")
コード例 #5
0
def show_my_games():
    show_match.check_date()
    game = fetchall(
        "select location, level, players, creator, match.matchid, date, gender from (match join booking on match.matchid = booking.matchid) where booking.username = %s ORDER BY date;",
        [session["username"]])
    return render_template("my_games.html",
                           user=session["username"],
                           matches=game)
コード例 #6
0
def changeProfile():
    informationProfile = fetchall(
        "select * from (profile join registration on profile.pid = registration.pid) where username = %s",
        [session["username"]])
    print(informationProfile)
    return render_template("edit_profile.html",
                           user=session["username"],
                           info=informationProfile)
コード例 #7
0
def show_past_chatt():
    messages = []
    sql = "select writer,message,date from msg WHERE writer = %s OR reciever = %s"
    val = session["username"], session["username"]
    insert(sql, val)
    messages = fetchall(sql, val)
    return render_template("messages.html",
                           user=session["username"],
                           messages=messages)
コード例 #8
0
def show_Match_Profile(matchid):
    result = fetchall(
        "select location, level, players, info, creator, matchid, gender from match where matchid = %s AND players > 0",
        [matchid])

    match = []
    for record in result:
        match.append(record)
    return match
コード例 #9
0
def show_all_ranks(location, level):
    check_date()
    sql = "select DISTINCT location,level,players,match.matchid,gender,date,username from (match join booking on match.matchid = booking.matchid) where location = %s and level = %s AND players > 0 AND creator != %s ORDER BY date"
    val = (location, level, session["username"])
    result = fetchall(sql, val)
    games = []
    for record in result:
        games.append(record)
    return games
コード例 #10
0
def show_my_games():
    print(session["username"])
    game = fetchall(
        "select ort, klass, antal, skapare, match.matchid from (match join booking on match.matchid = booking.matchid) where booking.username = %s",
        [session["username"]])
    print(game)
    return render_template("my_games.html",
                           user=session["username"],
                           matches=game)
コード例 #11
0
def show_all_match(ort):
    sql = "select ort, klass, antal, matchid from match where ort = %s AND antal > 0"
    val = (ort, )
    result = fetchall(sql, val)
    games = []
    for record in result:
        games.append(record)
    print(games)
    return games
コード例 #12
0
def show_match_profile(matchid):
    matchid = matchid
    result = fetchall(
        "select location, level, info, creator, matchid, players from match where matchid = %s",
        [matchid])
    my_matches = []
    for record in result:
        my_matches.append(record)
    return render_template("match_profile.html",
                           match=show_match.show_Match_Profile(matchid),
                           my_matches=my_matches)
コード例 #13
0
def show_comment(matchid):
    print("hej")
    matchid = matchid
    result = fetchall(
        "select message, writer, matchid from msg where matchid = %s ORDER BY date DESC",
        [matchid])
    print(result)
    comments = []
    for record in result:
        print(record)
        comments.append(record)
    print(comments)
    return comments
コード例 #14
0
def register():
    """
    Receives User registration information from a form and creates Person,Profile % registartion in the database.
    """
    fName = request.form["fName"]
    lName = request.form["lName"]
    email = request.form["email"]
    gender = request.form["gender"]

    username = request.form["userName"]
    password = request.form["pwd"]
    password = hash_password(password)

    level = request.form["level"]
    location = request.form["location"]

    username_list = fetchall("select username from registration", "")
    username_list = ("".join(str(username_list)))

    if username not in username_list:

        def insert_person():
            sql = "insert into person(name, email, gender) values(%s,%s,%s)"
            name = fName + " " + lName
            val = (
                name,
                email,
                gender,
            )
            insert(sql, val)

        def insert_registration():
            sql = "insert into registration(username, password) values(%s,%s)"
            val = (
                username,
                password,
            )
            insert(sql, val)

        def insert_profile():
            sql = "insert into profile(img, level, location) values(%s, %s, %s)"
            image = 'static/img/uploads/blank_profile.png'
            val = (image, level, location)
            insert(sql, val)

        insert_person()
        insert_profile()
        insert_registration()
        return True
    else:
        return False
コード例 #15
0
def check_date():
    """
    Converts database "date" to same format as date.today() and compares if the date is expired.
    If date expired = remove match from database.
    """
    current = date.today()
    current = current.strftime("%a, %d %b %Y")
    current = datetime.strptime(str(current), "%a, %d %b %Y")
    result = fetchall("select date from match where matchid > %s", [0])
    print(current)

    for record in result:
        record = datetime.strptime(record[0], "%a, %d %b %Y")
        if record < current:
            print("delete")
            new_record = record.strftime("%a, %d %b %Y")
            print(new_record)
            update("delete from match where date = %s", [new_record])
コード例 #16
0
def my_game_info(matchid):
    matchid = matchid
    result = fetchall(
        "select ort, klass, info, skapare, matchid, antal from match where matchid = %s",
        [matchid])
    my_matches = []
    for record in result:
        my_matches.append(record)

    #Checks if skapare = username
    if my_matches[0][3] == session["username"]:
        return render_template("show_my_games.html",
                               user=session["username"],
                               my_matches=my_matches,
                               creator=True)
    else:
        return render_template("show_my_games.html",
                               user=session["username"],
                               my_matches=my_matches)
コード例 #17
0
def profil():
    profile.editProfile(session["username"])
    img = fetchone(
        "select img from(profile join registration on profile.pid = registration.pid) where username = %s",
        [session["username"]])

    profileInfo = []
    profileInfo = fetchall(
        "select * from(profile join registration on profile.pid = registration.pid) where username = %s",
        [session["username"]])
    personName = fetchone(
        "select name from(person join registration on person.pid = registration.pid) where username = %s",
        [session["username"]])

    return render_template("welcome.html",
                           picture=img,
                           user=session["username"],
                           profileInfo=profileInfo,
                           personName=personName)
コード例 #18
0
def my_game_info(matchid):
    matchid = matchid
    result = fetchall(
        "select location, level, info, creator, matchid, players from match where matchid = %s",
        [matchid])
    my_matches = []
    for record in result:
        my_matches.append(record)

    #Checks if creator = username
    if my_matches[0][3] == session["username"]:
        return render_template("show_my_games.html",
                               user=session["username"],
                               my_matches=my_matches,
                               creator=True,
                               comments=show_comment(matchid))
    else:
        return render_template("show_my_games.html",
                               user=session["username"],
                               my_matches=my_matches,
                               comments=show_comment(matchid))
コード例 #19
0
def log_in():
    cred = []
    cred = fetchall("select username from registration", "")
    usernameList = ("".join(str(cred)))
    username = request.form["userName"]
    password = request.form["pwd"]

    if username in usernameList:
        usernameToFind = (username, )
        cred = fetchone("select password from registration where username=%s",
                        usernameToFind)
        stored_password = cred[0]
        print(stored_password)
        print(password)
        if verify_password(stored_password, password):
            print("Password is correct")
            return True
        else:
            print(stored_password)
            print(password)
            print("fel lösenord")
            return False
    else:
        return False
コード例 #20
0
def show_Game(location, level, gender):
    check_date()
    sql = "select DISTINCT location,level,players,match.matchid,gender,date,username from (match join booking on match.matchid = booking.matchid) where location = %s AND level = %s AND gender = %s AND players > 0 AND creator != %s ORDER BY date"
    val = location, level, gender, session["username"]
    games = fetchall(sql, val)
    return games