# Path: riv/shortcuts.py
# def render_to_rest(data):
#     return RestResponse(content=data)
# 
# def render_form_error_to_rest(form):
#     return RestResponse(form=form)


from django.shortcuts import render_to_response, get_object_or_404
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, Http404
from django.template import RequestContext
from django.forms.models import modelformset_factory
from forms import PollForm, VoteForm
from models import Poll, Choice
from riv.shortcuts import render_to_rest, render_form_error_to_rest
        'form': form,
        }, context_instance=RequestContext(request)
    )

def poll_create_multiple(request):
    PollFormSet = modelformset_factory(Poll, fields="__all__")
    if request.method == 'POST':
        formset = PollFormSet(request.POST)
        if formset.is_valid():
            objects = formset.save()
            return render_to_rest(objects)
        else:
            if request.is_rest():
                return render_form_error_to_rest(formset)
    else:
        formset = PollFormSet()

    return render_to_response('update.html', {
        'formset': formset,
        }, context_instance=RequestContext(request)
    )

def poll_delete(request, id):
    p = get_object_or_404(Poll, pk=id)
    p.delete()
    if request.is_rest():
        return HttpResponse(status=204)
    return render_to_response('deleted.html')

@login_required

# Path: riv/shortcuts.py
# def render_to_rest(data):
#     return RestResponse(content=data)
# 
# def render_form_error_to_rest(form):
#     return RestResponse(form=form)


# Path: tests/polls/views.py
from django.shortcuts import render_to_response, get_object_or_404
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, Http404
from django.template import RequestContext
from django.forms.models import modelformset_factory
from forms import PollForm, VoteForm
from models import Poll, Choice
from riv.shortcuts import render_to_rest, render_form_error_to_rest

        'form': form,
        }, context_instance=RequestContext(request)
    )

def poll_create_multiple(request):
    PollFormSet = modelformset_factory(Poll, fields="__all__")
    if request.method == 'POST':
        formset = PollFormSet(request.POST)
        if formset.is_valid():
            objects = formset.save()
            return render_to_rest(objects)
        else:
            if request.is_rest():
                return render_form_error_to_rest(formset)
    else:
        formset = PollFormSet()

    return render_to_response('update.html', {
        'formset': formset,
        }, context_instance=RequestContext(request)
    )

def poll_delete(request, id):
    p = get_object_or_404(Poll, pk=id)
    p.delete()
    if request.is_rest():
        return HttpResponse(status=204)
    return render_to_response('deleted.html')

@login_required

def results(request, id):