def view_tag(request, username, tag_name): tag = get_object_or_404(UserTag, name=tag_name, user__username=username) increment_view_count(tag, request) if tag.published is False and tag.user != request.user: # They don't even get to see if it exists. raise Http404("This tag does not exist") # Calculate the total tag count (as we add more types of taggables, add # them here). enhanced_dockets = tag.dockets.all() total_tag_count = len(enhanced_dockets) for docket in enhanced_dockets: docket.association_id = DocketTag.objects.get(docket=docket, tag=tag).pk requested_user = get_object_or_404(User, username=username) is_page_owner = request.user == requested_user return render( request, "tag.html", { "tag": tag, "dockets": enhanced_dockets, "total_tag_count": total_tag_count, "private": False, "is_page_owner": is_page_owner, }, )
def render_visualization_page(request, pk, embed): viz = get_object_or_404(SCOTUSMap, pk=pk) increment_view_count(viz, request) status = None if viz.deleted: status = statuses.HTTP_410_GONE else: if viz.published is False and viz.user != request.user: # Not deleted, private and not the owner status = statuses.HTTP_401_UNAUTHORIZED if embed: if all([viz.published is True, viz.deleted is False]): # Log the referer if it's set, and the item is live. referer_url = request.META.get("HTTP_REFERER") if referer_url is not None: referer, created = Referer.objects.get_or_create( url=referer_url, map_id=viz.pk ) if created: # Spawn a task to try to get the title of the page. get_title.delay(referer.pk) template = "visualization_embedded.html" else: template = "visualization.html" return render( request, template, {"viz": viz, "private": False}, status=status )
def view_tag(request, username, tag_name): tag = get_object_or_404(UserTag, name=tag_name, user__username=username) increment_view_count(tag, request) if tag.published is False and tag.user != request.user: # They don't even get to see if it exists. raise Http404("This tag does not exist") # Calculate the total tag count (as we add more types of taggables, add # them here). total_tag_count = tag.dockets.all().count() return render( request, "tag.html", {"tag": tag, "total_tag_count": total_tag_count, "private": False}, )
def view_docket(request: HttpRequest, pk: int, slug: str) -> HttpResponse: docket, context = core_docket_data(request, pk) increment_view_count(docket, request) de_list = docket.docket_entries.all().prefetch_related("recap_documents") form = DocketEntryFilterForm(request.GET) if form.is_valid(): cd = form.cleaned_data if cd.get("entry_gte"): de_list = de_list.filter(entry_number__gte=cd["entry_gte"]) if cd.get("entry_lte"): de_list = de_list.filter(entry_number__lte=cd["entry_lte"]) if cd.get("filed_after"): de_list = de_list.filter(date_filed__gte=cd["filed_after"]) if cd.get("filed_before"): de_list = de_list.filter(date_filed__lte=cd["filed_before"]) if cd.get("order_by") == DocketEntryFilterForm.DESCENDING: de_list = de_list.order_by( "-recap_sequence_number", "-entry_number" ) paginator = Paginator(de_list, 200, orphans=10) page = request.GET.get("page", 1) try: docket_entries = paginator.page(page) except PageNotAnInteger: docket_entries = paginator.page(1) except EmptyPage: docket_entries = paginator.page(paginator.num_pages) context.update( { "parties": docket.parties.exists(), # Needed to show/hide parties tab. "docket_entries": docket_entries, "form": form, "get_string": make_get_string(request), } ) return render(request, "view_docket.html", context)