Generic request view.  Parameters:
        request is the HTTP request
        requestType is URL name of a RequestType.
            e.g. "food", "maintenance", "network", "site"

def requests_view(request, requestType):
    '''
    Generic request view.  Parameters:
        request is the HTTP request
        requestType is URL name of a RequestType.
            e.g. "food", "maintenance", "network", "site"
    '''
    userProfile = UserProfile.objects.get(user=request.user)
    request_type = get_object_or_404(RequestType, url_name=requestType)
    page_name = "{0} Requests".format(request_type.name.title())
    if not request_type.enabled:
        message = "{0} requests have been disabled.".format(request_type.name.title())
        return red_home(request, message)
    relevant_managers = request_type.managers.filter(active=True)
    manager = any(i.incumbent == userProfile for i in relevant_managers)
    request_form = RequestForm(
        request.POST if "submit_request" in request.POST else None,
        profile=userProfile,
        request_type=request_type,
        )
    if request_form.is_valid():
        request_form.save()
        return HttpResponseRedirect(reverse('managers:requests', kwargs={'requestType': requestType}))
    # number of requests loaded
    x = 0
    # A pseudo-dictionary, actually a list with items of form (request,
    # [request_responses_list], response_form, upvote, vote_form)
    requests_dict = list()
    requests = Request.objects.filter(request_type=request_type)
    if not request_type.managers.filter(incumbent__user=request.user):
        requests = requests.exclude(
            ~Q(owner__user=request.user), private=True,
            )
    for req in requests:
        request_responses = Response.objects.filter(request=req)
        if manager:
            response_form = ManagerResponseForm(
                request.POST if "add_response-{0}".format(req.pk) in request.POST else None,
                initial={'action': Response.NONE},
                prefix="{0}".format(req.pk),
                profile=userProfile,
                request=req,
                )
        else:
            response_form = ResponseForm(
                request.POST if "add_response-{0}".format(req.pk) in request.POST else None,
                prefix="{0}".format(req.pk),
                profile=userProfile,
                request=req,
                )
        upvote = userProfile in req.upvotes.all()
        vote_form = VoteForm(
            request.POST if "vote-{0}".format(req.pk) in request.POST else None,
            profile=userProfile,
            request=req,
            )
        if response_form.is_valid():
            response_form.save()
            return HttpResponseRedirect(reverse('managers:requests',
                                                kwargs={'requestType': requestType}))
        if vote_form.is_valid():
            vote_form.save()
            return HttpResponseRedirect(reverse('managers:requests',
                                                kwargs={'requestType': requestType}))
        requests_dict.append((req, request_responses, response_form, upvote, vote_form))
        x += 1
        if x >= settings.MAX_REQUESTS:
            break
    return render_to_response('requests.html', {
        'manager': manager,
        'request_type': request_type,
        'page_name': page_name,
        'request_form': request_form,
        'requests_dict': requests_dict,
        'relevant_managers': relevant_managers,
        }, context_instance=RequestContext(request))