コード例 #1
0
ファイル: views.py プロジェクト: valentinmoscone/LaLiga
def profile(request):
    if request.method == 'GET':
        user = users.get_current_user()
        if user:
            allusers = User.all()
            allusers.filter("email =", user.email())
            result = allusers.get()
            if result is None:
                return redirect(users.create_login_url("/"))
            else:
                teams = Team.all()
                return render(request,"profile.html",{'userprofile': result, 'teams': teams})
        else:
            return redirect(users.create_login_url("/"))
    if request.method == 'POST':
        user = users.get_current_user()
        if user:
            allusers = User.all()
            allusers.filter("email =", user.email())
            result = allusers.get()
            if result is None:
                return redirect(users.create_login_url("/"))
            else:
                result.username = request.POST['username']
                result.age = request.POST['age']
                result.team = request.POST['team']
                result.put()
                return render(request, "profile.html",{'userprofile': result})
    return redirect(users.create_login_url("/"))
コード例 #2
0
ファイル: views.py プロジェクト: valentinmoscone/LaLiga
def home(request):
    if request.method == 'GET':
        user = users.get_current_user()
        if user:
            allusers = User.all()
            allusers.filter("email = ", user.email())
            result = allusers.get()
            if result is None:
                return redirect(users.create_login_url("/"))
            else:
                team = Team.all()
                return render(request,"home.html",{'teams': team, 'user': result})
        else:
            return redirect(users.create_login_url("/"))
    else:
        return redirect("https://www.google.com")
コード例 #3
0
ファイル: views.py プロジェクト: valentinmoscone/LaLiga
def team(request, team_name):
    if request.method == 'GET':
        user = users.get_current_user()
        if user:
            allusers = User.all()
            allusers.filter("email =", user.email())
            result = allusers.get()
            if result is None:
                return redirect(users.create_login_url("/"))
            else:
                team = Team.all()
                team.filter("name = ", team_name)
                resultteam = team.get()
                if resultteam is None:
                    return HttpResponseNotFound('<h1>404 Page not found</h1>')
                players = Player.all()
                players.filter("teamPlayer = ", team_name)
                return render(request, "team.html",{'teamdetail':resultteam,'playerdetail':players, 'user': result})
        else:
            return redirect(users.create_login_url("/"))
    else:
        return redirect("https://www.google.com")