예제 #1
0
def view_authorities(request, pk, case_name):
    pk = ascii_to_num(pk)

    doc = get_object_or_404(Document, pk=pk)
    title = '%s, %s' % (trunc(doc.citation.case_name, 100), make_citation_string(doc))

    # Ordering is by case name is the norm.
    authorities = doc.cases_cited.all().select_related(
        'document').order_by('case_name')

    private = False
    if doc.blocked:
        private = True
    else:
        for case in authorities:
            if case.parent_documents.all()[0].blocked:
                private = True
                break

    return render_to_response('view_case_authorities.html',
                              {'title': title,
                               'doc': doc,
                               'private': private,
                               'authorities': authorities},
                              RequestContext(request))
예제 #2
0
def redirect_opinion_pages(request, pk, slug):
    pk = ascii_to_num(pk)
    path = reverse('view_case', args=[pk, slug])
    if request.path.endswith('/authorities/'):
        path += 'authorities/'
    elif request.path.endswith('/cited-by/'):
        path += 'cited-by/'
    if request.META['QUERY_STRING']:
        path = '%s?%s' % (path, request.META['QUERY_STRING'])
    return HttpResponsePermanentRedirect(path)
예제 #3
0
def redirect_opinion_pages(request, pk, slug):
    pk = ascii_to_num(pk)
    path = reverse('view_case', args=[pk, slug])
    if request.path.endswith('/authorities/'):
        path += 'authorities/'
    elif request.path.endswith('/cited-by/'):
        path += 'cited-by/'
    if request.META['QUERY_STRING']:
        path = '%s?%s' % (path, request.META['QUERY_STRING'])
    return HttpResponsePermanentRedirect(path)
예제 #4
0
def redirect_opinion_pages(request, pk, slug):
    pk = ascii_to_num(pk)
    path = reverse("view_case", args=[pk, slug])
    if request.path.endswith("/authorities/"):
        path += "authorities/"
    elif request.path.endswith("/cited-by/"):
        path += "cited-by/"
    if request.META["QUERY_STRING"]:
        path = "%s?%s" % (path, request.META["QUERY_STRING"])
    return HttpResponsePermanentRedirect(path)
예제 #5
0
def view_case(request, court, pk, casename):
    """Take a court and an ID, and return the document.

    We also test if the document ID is a favorite for the user, and send data
    as such. If it's a favorite, we send the bound form for the favorite so
    it can populate the form on the page. If it is not a favorite, we send the
    unbound form.
    """
    # Look up the court, document, title and favorite information
    doc = get_object_or_404(Document, pk=ascii_to_num(pk))
    ct = get_object_or_404(Court, pk=court)
    citation_string = make_citation_string(doc)
    title = '%s, %s' % (trunc(doc.citation.case_name, 100), citation_string)
    get_string = search_utils.make_get_string(request)

    try:
        # Get the favorite, if possible
        fave = Favorite.objects.get(doc_id=doc.pk, users__user=request.user)
        favorite_form = FavoriteForm(instance=fave)
    except (ObjectDoesNotExist, TypeError):
        # Not favorited or anonymous user
        favorite_form = FavoriteForm(initial={'doc_id': doc.pk,
            'name': doc.citation.case_name})

    # get most influential cases that cite this case
    cited_by_trunc = doc.citation.citing_cases.select_related(
          'citation').order_by('-citation_count', '-date_filed')[:5]

    authorities_trunc = doc.cases_cited.all().select_related(
        'document').order_by('case_name')[:5]
    authorities_count = doc.cases_cited.all().count()

    return render_to_response(
        'view_case.html',
        {'title': title,
         'citation_string': citation_string,
         'doc': doc,
         'court': ct,
         'favorite_form': favorite_form,
         'get_string': get_string,
         'private': doc.blocked,
         'cited_by_trunc': cited_by_trunc,
         'authorities_trunc': authorities_trunc,
         'authorities_count': authorities_count},
        RequestContext(request)
    )
예제 #6
0
def view_case_citations(request, pk, case_name):
    pk = ascii_to_num(pk)

    # Look up the document, title
    doc = get_object_or_404(Document, pk=pk)
    title = '%s, %s' % (trunc(doc.citation.case_name, 100), make_citation_string(doc))

    # Get list of cases we cite, ordered by citation count
    citing_cases = doc.citation.citing_cases.select_related(
            'citation', 'court').order_by('-citation_count', '-date_filed')

    paginator = Paginator(citing_cases, 20, orphans=2)
    page = request.GET.get('page')
    try:
        citing_cases = paginator.page(page)
    except (TypeError, PageNotAnInteger):
        # TypeError can be removed in Django 1.4, where it properly will be
        # caught upstream.
        citing_cases = paginator.page(1)
    except EmptyPage:
        citing_cases = paginator.page(paginator.num_pages)

    private = False
    if doc.blocked:
        private = True
    else:
        for case in citing_cases.object_list:
            if case.blocked:
                private = True
                break

    return render_to_response('view_case_citations.html',
                              {'title': title,
                               'doc': doc,
                               'private': private,
                               'citing_cases': citing_cases},
                              RequestContext(request))
예제 #7
0
def redirect_cited_by_feeds(request, pk):
    pk = ascii_to_num(pk)
    path = reverse('cited_by_feed', kwargs={'doc_id': pk})
    return HttpResponsePermanentRedirect(path)
예제 #8
0
def redirect_cited_by_feeds(request, pk):
    pk = ascii_to_num(pk)
    path = reverse('cited_by_feed', kwargs={'doc_id': pk})
    return HttpResponsePermanentRedirect(path)
예제 #9
0
 def get_object(self, request, doc_id):
     return get_object_or_404(Document, pk=ascii_to_num(doc_id))