Ejemplo n.º 1
0
def duel_detail(request, duel_id):
    """ Index of story objects in a backlog
    """
    current_duel = get_object_or_404(Duel, pk=duel_id)
    if request.method == "POST":
        form = DuelForm(request.POST.copy(), instance=current_duel)
        
        if form.is_valid():
            current_object = form.save()
            return HttpResponseRedirect("/duel/")
        else:
            form_error(request, form)
    if current_duel.avatar_1.user == request.user:
        current_avatar = current_duel.avatar_1
        is_1_current = True
        is_2_current = False
    else:
        current_avatar = current_duel.avatar_2
        is_1_current = False
        is_2_current = True

    avatar_1 = render_to_string('duel/avatar.html', {'avatar': current_duel.avatar_1, 'is_current': is_1_current})
    avatar_2 = render_to_string('duel/avatar.html', {'avatar': current_duel.avatar_2, 'is_current': is_2_current})
    template = "duel/detail.html"
    return locals()
Ejemplo n.º 2
0
def duel_index(request):
    """ Index of story objects in a backlog
    """
    if request.method == "POST":
        data = request.POST.copy()
        if data.has_key("avatar_1"):
            avatar_1 = Avatar.objects.create(name=data.pop("avatar_1")[0], user=request.user)
            data['avatar_1'] = avatar_1.id
        create_form = DuelForm(data)
        if create_form.is_valid():
            current_object = create_form.save()
            return HttpResponseRedirect('/duel/')
        else:
            form_error(request, create_form)
    else:
        create_form = DuelForm()

    duels = Duel.objects.all()
    
    template = "duel/index.html"
    return locals()