Beispiel #1
0
def list_requests(request, status=None, topic=None, tag=None, jurisdiction=None):
    context = {
        'filtered': True
    }
    topic_list = PublicBodyTopic.objects.get_list()
    if status is not None:
        status = FoiRequest.STATUS_URLS_DICT[status]
        foi_requests = FoiRequest.published.for_list_view().filter(status=status)
        context.update({
            'status': FoiRequest.get_readable_status(status),
            'status_description': FoiRequest.get_status_description(status)
        })
    elif topic is not None:
        topic = get_object_or_404(PublicBodyTopic, slug=topic)
        foi_requests = FoiRequest.published.for_list_view().filter(public_body__topic=topic)
        context.update({
            'topic': topic,
            })
    elif tag is not None:
        tag_object = get_object_or_404(Tag, slug=tag)
        foi_requests = FoiRequest.published.for_list_view().filter(tags=tag_object)
        context.update({
            'tag': tag_object
        })
    else:
        foi_requests = FoiRequest.published.for_list_view()
        context['filtered'] = False

    if jurisdiction is not None:
        jurisdiction_object = get_object_or_404(Jurisdiction, slug=jurisdiction)
        foi_requests = foi_requests.filter(jurisdiction=jurisdiction_object)
        context.update({
            'jurisdiction': jurisdiction_object
        })
    else:
        context['jurisdiction_list'] = Jurisdiction.objects.get_visible()

    context.update({
        'page_title': _("FoI Requests"),
        'count': foi_requests.count(),
        'object_list': foi_requests,
        'status_list': [(x[0],
            FoiRequest.get_readable_status(x[1]), x[1]) for x in FoiRequest.STATUS_URLS],
        'topic_list': topic_list
    })

    return render(request, 'foirequest/list.html', context)
Beispiel #2
0
def list_requests_not_foi(request):
    context = {}
    context.update({
        'page_title': _("Non-FoI Requests"),
        'not_foi': True,
        'count': FoiRequest.published_not_foi.for_list_view().count(),
        'object_list': FoiRequest.published_not_foi.for_list_view(),
        'status_list': [(x[0],
            FoiRequest.get_readable_status(x[1]), x[1]) for x in FoiRequest.STATUS_URLS],
        'topic_list': PublicBodyTopic.objects.get_list()
    })
    return render(request, 'foirequest/list.html', context)
Beispiel #3
0
def create_event_status_changed(sender, **kwargs):
    status = kwargs['status']
    data = kwargs['data']
    if data['costs'] > 0:
        FoiEvent.objects.create_event("reported_costs", sender,
                user=sender.user,
                public_body=sender.public_body, amount=data['costs'])
    elif status == "refused" and data['refusal_reason']:
        FoiEvent.objects.create_event("request_refused", sender,
                user=sender.user,
                public_body=sender.public_body, reason=data['refusal_reason'])
    elif status == "partially_successful" and data['refusal_reason']:
        FoiEvent.objects.create_event("partially_successful", sender,
                user=sender.user,
                public_body=sender.public_body, reason=data['refusal_reason'])
    elif status == "request_redirected":
        FoiEvent.objects.create_event("request_redirected", sender,
                user=sender.user,
                public_body=sender.public_body)
    else:
        FoiEvent.objects.create_event("status_changed", sender, user=sender.user,
            public_body=sender.public_body,
            status=FoiRequest.get_readable_status(status))