예제 #1
0
파일: team.py 프로젝트: leonwu127/play
def update(request):
    form = TeamForm(request.user, request.POST, instance=request.team)
    if form.is_valid():
        form.save()
        messages.success(request, "Your team was updated successfully")
        return redirect("/team")

    return render(request, "team/edit.html", {"form": form}, status=400)
예제 #2
0
파일: team.py 프로젝트: thanaphon/play
def update(request):
    form = TeamForm(request.user, request.POST, instance=request.team)
    if form.is_valid():
        form.save()
        messages.success(request, 'Your team was updated successfully')
        return redirect('/team')

    return render(request, 'team/edit.html', {
        'form': form,
    }, status=400)
예제 #3
0
파일: team.py 프로젝트: thanaphon/play
def edit(request):
    user = request.user
    team = request.team
    return render(request, 'team/edit.html', {
        'form': TeamForm(request.user, instance=team),
        'user': user,
    })
예제 #4
0
파일: team.py 프로젝트: leonwu127/play
def edit(request):
    user = request.user
    team = request.team
    return render(
        request,
        "team/edit.html",
        {"form": TeamForm(request.user, instance=team), "user": user},
    )
예제 #5
0
파일: team.py 프로젝트: leonwu127/play
def new(request):
    # Don't use the middleware here, check manually.
    # If the user is on a team already, don't let them make a new one.
    if request.user.assigned_to_team():
        messages.warning(request, "You're already assigned to a team")
        return redirect("/team")

    if request.method == "POST":
        form = TeamForm(request.user, request.POST)
        if form.is_valid():
            form.save()
            messages.success(request, "Your team was created successfully")
            return redirect("/team")
        else:
            status = 400
    else:
        status = 200
        form = TeamForm(request.user)

    return render(request, "team/new.html", {"form": form}, status=status)