def item_title(self, item: DocketEntry) -> SafeText: docket_title = make_docket_title(item.docket) entry_number = item.entry_number if entry_number: preface = f"Entry #{entry_number}" else: preface = f"Minute entry from {item.date_filed}" return mark_safe(f"{preface} in {docket_title}")
def new_docket_alert(request: AuthenticatedHttpRequest) -> HttpResponse: """Allow users to create docket alerts based on case and court ID""" pacer_case_id = request.GET.get("pacer_case_id") court_id = request.GET.get("court_id") if not pacer_case_id or not court_id: return render( request, "docket_alert_new.html", { "docket": None, "title": "400: Invalid request creating docket alert", "private": True, }, status=HTTP_400_BAD_REQUEST, ) try: docket = Docket.objects.get( pacer_case_id=pacer_case_id, court_id=court_id ) except Docket.DoesNotExist: return render( request, "docket_alert_new.html", { "docket": None, "title": "New Docket Alert for Unknown Case", "private": True, }, status=HTTP_404_NOT_FOUND, ) except Docket.MultipleObjectsReturned as exc: docket = Docket.objects.filter( pacer_case_id=pacer_case_id, court_id=court_id ).earliest("date_created") title = "New Docket Alert for %s" % make_docket_title(docket) has_alert = user_has_alert(request.user, docket) return render( request, "docket_alert_new.html", { "title": title, "has_alert": has_alert, "docket": docket, "private": True, }, )
def test_make_title_no_docket_number(self) -> None: """Can we make titles?""" # No docket number d = Docket(case_name="foo", docket_number=None) self.assertEqual(make_docket_title(d), "foo")