@app.route('/user', methods=["GET","POST"])
@auth_check
def user(github):
    
    user_info = getGHcreds(github)
    user = users_db.find_one({ "github": user_info["github"] })

    if request.method == "GET":

        if user:
            user_info["uniqname"] = user["uniqname"]
            user_info["team_id"] = user["team_id"]

        return render_template('user.jade', **user_info)

    else: #POST
        user_info["uniqname"] = request.json["uniqname"]
        team_id = user_info["team_id"] = request.json["team_id"]

        team = teams_db.find_one({"id":team_id})

        #check if team exists
        if (team_id != "") and (not team):
            return json.dumps({"error":"Invalid Team Id!"})

        # check if team is full
        if team and team["size"] >= MAX_TEAM_MEMBERS and user["team_id"] != team_id:
            return json.dumps({"error": "Team is Full! Maximum Team Size is " + str(MAX_TEAM_MEMBERS)})

        # save the user
        users_db.update({ "github":user_info["github"] }, user_info, upsert= True);

        # increment user count for team 
        if team and (not user or user["team_id"] != team_id):
            # user is new to the team
            team["size"] += 1
            teams_db.update({ "id": team_id }, team)

        return json.dumps({"success" : 'ok'})


#API to ADD/EDIT team
dataset/ETHPy150Open ottosipe/github-class-repo-manager/app.py/user/original