Ejemplo n.º 1
0
def view_recap_document(request, docket_id=None, doc_num=None,  att_num=None,
                        slug=''):
    """This view can either load an attachment or a regular document,
    depending on the URL pattern that is matched.
    """
    item = get_object_or_404(
        RECAPDocument,
        docket_entry__docket__id=docket_id,
        document_number=doc_num,
        attachment_number=att_num,
    )
    title = make_rd_title(item)
    if is_og_bot(request):
        make_thumb_if_needed(item)
        item.refresh_from_db()
    try:
        fave = Favorite.objects.get(recap_doc_id=item.pk, user=request.user)
    except (ObjectDoesNotExist, TypeError):
        # Not favorited or anonymous user
        favorite_form = FavoriteForm(initial={
            'recap_doc_id': item.pk,
            'name': trunc(title, 100, ellipsis='...'),
        })
    else:
        favorite_form = FavoriteForm(instance=fave)

    return render(request, 'recap_document.html', {
        'document': item,
        'title': title,
        'favorite_form': favorite_form,
        'private': True,  # Always True for RECAP docs.
    })
Ejemplo n.º 2
0
def view_recap_document(request, docket_id=None, doc_num=None,  att_num=None,
                        slug=''):
    """This view can either load an attachment or a regular document,
    depending on the URL pattern that is matched.
    """
    item = get_object_or_404(
        RECAPDocument,
        docket_entry__docket__id=docket_id,
        document_number=doc_num,
        attachment_number=att_num,
    )
    title = make_rd_title(item)
    if is_og_bot(request):
        make_thumb_if_needed(item)
        item.refresh_from_db()
    try:
        fave = Favorite.objects.get(recap_doc_id=item.pk, user=request.user)
    except (ObjectDoesNotExist, TypeError):
        # Not favorited or anonymous user
        favorite_form = FavoriteForm(initial={
            'recap_doc_id': item.pk,
            'name': trunc(title, 100, ellipsis='...'),
        })
    else:
        favorite_form = FavoriteForm(instance=fave)

    return render(request, 'recap_document.html', {
        'document': item,
        'title': title,
        'favorite_form': favorite_form,
        'private': True,  # Always True for RECAP docs.
    })
Ejemplo n.º 3
0
def view_recap_document(request,
                        docket_id=None,
                        doc_num=None,
                        att_num=None,
                        slug=""):
    """This view can either load an attachment or a regular document,
    depending on the URL pattern that is matched.
    """
    item = get_object_or_404(
        RECAPDocument,
        docket_entry__docket__id=docket_id,
        document_number=doc_num,
        attachment_number=att_num,
    )

    # Check if the user has requested automatic redirection to the document
    redirectToDownload = request.GET.get("redirectToDownload", False)
    if redirectToDownload:
        # Check if the document is available from Court Listener and
        # if it is, redirect the user to that
        # if it isn't, redirect the user to PACER
        if item.is_available:
            response = redirect(item.filepath_local)
        else:
            response = redirect(item.pacer_url)
        return response

    title = make_rd_title(item)
    if is_og_bot(request):
        make_thumb_if_needed(item)
        item.refresh_from_db()
    try:
        fave = Favorite.objects.get(recap_doc_id=item.pk, user=request.user)
    except (ObjectDoesNotExist, TypeError):
        # Not favorited or anonymous user
        favorite_form = FavoriteForm(initial={
            "recap_doc_id": item.pk,
            "name": trunc(title, 100, ellipsis="..."),
        })
    else:
        favorite_form = FavoriteForm(instance=fave)

    return render(
        request,
        "recap_document.html",
        {
            "document": item,
            "title": title,
            "favorite_form": favorite_form,
            "private": True,  # Always True for RECAP docs.
        },
    )
Ejemplo n.º 4
0
def view_recap_document(
    request: HttpRequest,
    docket_id: Optional[int] = None,
    doc_num: Optional[int] = None,
    att_num: Optional[int] = None,
    slug: str = "",
) -> HttpResponse:
    """This view can either load an attachment or a regular document,
    depending on the URL pattern that is matched.
    """
    try:
        item = RECAPDocument.objects.filter(
            docket_entry__docket__id=docket_id,
            document_number=doc_num,
            attachment_number=att_num,
        ).order_by("pk")[0]
    except IndexError:
        raise Http404("No RECAPDocument matches the given query.")

    title = make_rd_title(item)
    item = make_thumb_if_needed(request, item)
    try:
        fave = Favorite.objects.get(recap_doc_id=item.pk, user=request.user)
    except (ObjectDoesNotExist, TypeError):
        # Not favorited or anonymous user
        favorite_form = FavoriteForm(initial={
            "recap_doc_id": item.pk,
            "name": trunc(title, 100, ellipsis="..."),
        })
    else:
        favorite_form = FavoriteForm(instance=fave)

    return render(
        request,
        "recap_document.html",
        {
            "document": item,
            "title": title,
            "favorite_form": favorite_form,
            "private": True,  # Always True for RECAP docs.
        },
    )