def change_status(request, page_id):
    """
    Switch the status of a page.
    """
    perm = request.user.has_perm('pages.change_page')
    if perm and request.method == 'POST':
        page = Page.objects.get(pk=page_id)
        page.status = int(request.POST['status'])
        page.invalidate()
        page.save()
        return HttpResponse(str(page.status))
    raise Http404
Switch the status of a page.