コード例 #1
0
ファイル: user.py プロジェクト: fozbek/devSeater
def userProfile(username):
    currentUser = getCurrentUser()
    user = UserModel.getUserByUsername(username, getCurrentUid())

    if user == None:
        return render_template("not-found.html",
                               title="User Not Found!",
                               msg="The user you trying to access not found!",
                               currentUser=getCurrentUser())

    userLinks = UserModel.getUserLinks(user["uid"])
    userProjects = ProjectModel.getUserProjects(user["uid"])
    lastUserPosts = UserPostModel.getLastUserPosts(user["uid"], 10,
                                                   getCurrentUid())
    popularProjects = ProjectModel.getPopularProjects(10)
    whoToFollowList = UserModel.getWhoToFollowList(5, getCurrentUid())

    #Remove password and email fields
    user.pop("password")
    user.pop("email")

    return render_template("user-profile.html",
                           currentUser=currentUser,
                           user=user,
                           userLinks=userLinks,
                           userProjects=userProjects,
                           lastUserPosts=lastUserPosts,
                           popularProjects=popularProjects,
                           whoToFollowList=whoToFollowList)
コード例 #2
0
def getUser():
    if request.method == "GET":
        uid = request.args.get("uid")
        username = request.args.get("username")
        email = request.args.get("email")

        if uid != None:
            user = UserModel.getUser(uid)
        elif username != None:
            user = UserModel.getUserByUsername(username)
        elif email != None:
            user = UserModel.getUserByEmail(email)
        else:
            return render_template("private-api/unknown-request.html")
        try:
            user.pop("password")
        except:
            print("password field cannot be popped!")
            return
        return json.dumps(user, cls=DateTimeEncoder)

    return redirect(url_for("index"))