Exemplo n.º 1
0
def create_team(request):
    if request.POST:
        form = TeamForm(request.POST)
        if form.is_valid():
            elem = form.save()
            return HttpResponseRedirect(object_link(elem))
        else:
            return HttpResponseBadRequest()

    return HttpResponseNotAllowed(['POST'])
Exemplo n.º 2
0
def create_team(request):
    if request.POST:
        form = TeamForm(request.POST)
        if form.is_valid():
            elem = form.save()
            return HttpResponseRedirect(object_link(elem))
        else:
            return HttpResponseBadRequest()

    return HttpResponseNotAllowed(['POST'])
Exemplo n.º 3
0
def edit_team(request, id):
    if request.POST:
        t = Team.objects.get(id=id)
        form = TeamForm(request.POST, instance=t)
        if form.is_valid():
            t = form.save()
            return HttpResponseRedirect(object_link(t))
        else:
            return HttpResponseBadRequest()

    return HttpResponseNotAllowed(['POST'])
Exemplo n.º 4
0
def edit_team(request, id):
    if request.POST:
        t = Team.objects.get(id=id)
        form = TeamForm(request.POST, instance=t)
        if form.is_valid():
            t = form.save()
            return HttpResponseRedirect(object_link(t))
        else:
            return HttpResponseBadRequest()

    return HttpResponseNotAllowed(['POST'])
Exemplo n.º 5
0
def teams(request):
    return render_to_response(
        'teams.html',
        RequestContext(
            request, {
                "title": "Teams",
                "teams": Team.objects.all(),
                "form": TeamForm(initial={"leader": request.user}),
                "formAction": "/create_team/"
            }))
Exemplo n.º 6
0
def team(request, id):
    t = Team.objects.get(id=id)
    return render_to_response(
        "team.html",
        RequestContext(
            request, {
                "title": t.name,
                "team": t,
                "formAction": "/edit_team/" + str(id) + "/",
                "form": TeamForm(instance=t),
                "isTeam": request.user in t.members.all()
            }))