Beispiel #1
0
def group_add(request):
    if request.method == 'POST':
        form = TeamForm(request.POST)
        if form.is_valid():
            form.save()
            return render_to_response('common/success.html')
    else:
        form = TeamForm()

    variables = RequestContext(request, {'form': form})
    return render_to_response('crud/group/group_add.html', variables)
Beispiel #2
0
def group_add(request):
    if request.method == "POST":
        form = TeamForm(request.POST)
        if form.is_valid():
            form.save()
            return render_to_response("common/success.html")
    else:
        form = TeamForm()

    variables = RequestContext(request, {"form": form})
    return render_to_response("crud/group/group_add.html", variables)
Beispiel #3
0
def group_edit(request, id):
    team = Team.objects.get(pk=id)
    if request.method == "POST":
        form = TeamForm(request.POST, instance=team)
        if form.is_valid():
            form.save()
            return render_to_response('common/success.html')
    else:
        form = TeamForm(instance=team)

    variables = RequestContext(request, {'form': form})

    return render_to_response("crud/group/group_edit.html", variables)
Beispiel #4
0
def group_edit(request, id):
    team = Team.objects.get(pk=id)
    if request.method == "POST":
        form = TeamForm(request.POST, instance=team)
        if form.is_valid():
            form.save()
            return render_to_response("common/success.html")
    else:
        form = TeamForm(instance=team)

    variables = RequestContext(request, {"form": form})

    return render_to_response("crud/group/group_edit.html", variables)
Beispiel #5
0
def team(request, team_id):
    club = Club.objects.get(usuario=request.user.id)
    team = Team.objects.get(id=team_id)
    if team.club_id != request.user.id:
        return HttpResponseRedirect('/accounts/logout/')
    else:
        if request.method == 'POST':
            form = TeamForm(request.POST, instance=team)
            if form.is_valid():
                tam = form.save(commit=False)
                tam.club_id = request.user.id
                tam.save()
                return HttpResponseRedirect('/team/%d' %team.id)
            else:
                form = TeamForm(instance=team)
        else:
            form = TeamForm(instance=team)
    return render_to_response('team/team.html', locals(),
        context_instance=RequestContext(request),)