Skip to content

Commit

Permalink
Merge branch 'main' into 3033-develop-v4-recap-search-api
Browse files Browse the repository at this point in the history
  • Loading branch information
albertisfu committed Apr 25, 2024
2 parents 738d65f + 26340b5 commit 102e7fc
Show file tree
Hide file tree
Showing 24 changed files with 777 additions and 37 deletions.
4 changes: 4 additions & 0 deletions cl/assets/static-global/css/override.css
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@ a.black-link:focus {
cursor: hand;
}

.open_buy_acms_modal.cursor{
cursor: pointer;
}

.cursor-help {
cursor: help;
}
Expand Down
4 changes: 2 additions & 2 deletions cl/citations/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet

from cl.api.utils import CitationCountRateThrottle
from cl.api.utils import CitationCountRateThrottle, LoggingMixin
from cl.citations.api_serializers import (
CitationAPIRequestSerializer,
CitationAPIResponseSerializer,
Expand All @@ -24,7 +24,7 @@
from cl.search.selectors import get_clusters_from_citation_str


class CitationLookupViewSet(CreateModelMixin, GenericViewSet):
class CitationLookupViewSet(LoggingMixin, CreateModelMixin, GenericViewSet):
queryset = OpinionCluster.objects.all()
serializer_class = CitationAPIRequestSerializer
permission_classes = [IsAuthenticated]
Expand Down
1 change: 1 addition & 0 deletions cl/favorites/templates/tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ <h3 class="v-offset-above-3" id="tag-list-title"><i class="fa-list fa grey" titl
<ul>
{% endif %}
{% include "includes/buy_pacer_modal.html" %}
{% include "includes/buy_acms_modal.html" %}
{% include "includes/docket_li.html" %}
{% if forloop.last %}
</ul>
Expand Down
16 changes: 15 additions & 1 deletion cl/lib/timezone_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import date, datetime, time

import pytz
from django.utils.timezone import is_naive

from cl.recap.constants import COURT_TIMEZONES

Expand All @@ -26,12 +27,25 @@ def localize_date_and_time(
"""Localize the date and time into local court timezone, split it into
date and time.
If given a "naive datetime" (no timezone information), assume the
time is in the court's local time. and return timezone-aware date
and time objects. If given a timezone-aware datetime, convert it
to the court's local timezone and return timezone-aware date and
time objects.
:param court_id: The court_id to get the timezone from.
:param date_filed: The date or datetime instance provided by the source.
:return: A tuple of date_filed and time_filed or None if no time available.
"""
if isinstance(date_filed, datetime):
datetime_filed_local = convert_to_court_timezone(court_id, date_filed)
if is_naive(date_filed):
datetime_filed_local = localize_naive_datetime_to_court_timezone(
court_id, date_filed
)
else:
datetime_filed_local = convert_to_court_timezone(
court_id, date_filed
)
time_filed = datetime_filed_local.time()
date_filed = datetime_filed_local.date()
return date_filed, time_filed
Expand Down
21 changes: 20 additions & 1 deletion cl/opinion_page/static/js/buy_pacer_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ $(document).ready(function () {
}
});


$('.open_buy_acms_modal').on('click', function (e) {
//Modal clicked
//check if ctrl or shift key pressed
if (e.metaKey || e.shiftKey) {
//prevent modal from opening, go directly to href link
e.stopPropagation();
}else {
//otherwise open modal and concatenate pacer URL to button
let pacer_url = $(this).attr('href');
$('#acms_url').attr('href', pacer_url);
}
});

//////////////////////////
// Modal Cookie Handling//
//////////////////////////
Expand All @@ -23,6 +37,11 @@ $(document).ready(function () {
document.cookie = 'buy_on_pacer_modal=true' + expires + '; samesite=lax; path=/';

///Close Modal
$('#modal-buy-pacer ').modal('toggle');
$('#modal-buy-pacer').modal('toggle');
});

$('#acms_url').on('click', function (e) {
///Close Modal
$('#modal-buy-acms').modal('toggle');
});
});
1 change: 1 addition & 0 deletions cl/opinion_page/templates/docket_tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
src="{% static "js/buy_pacer_modal.js" %}"></script>

{% include "includes/buy_pacer_modal.html" %}
{% include "includes/buy_acms_modal.html" %}
{% include "includes/date_picker.html" %}

<script type="text/javascript"
Expand Down
26 changes: 26 additions & 0 deletions cl/opinion_page/templates/includes/buy_acms_modal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% load humanize %}
<div id="modal-buy-acms"
class="modal hidden-print text-left"
data-remote="{# prevent bs.model from loading PACER content #}"
role="dialog"
aria-hidden="true"
tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<h2 class="modal-title">ACMS Document URL Unavailable</h2>
</div>
<div class="modal-body">
<p>This document is filed in the new <strong>Appellate Case Management System (ACMS)</strong>, which does not have direct document access. You must buy the docket sheet from the system and then buy the documents from there.</p>
</div>
<div class="modal-footer">
<p>
<a href="#" id="acms_url" target="_blank" class="btn btn-primary">Buy Docket in ACMS</a>
</p>
</div>
</div>
</div>
</div>
35 changes: 29 additions & 6 deletions cl/opinion_page/templates/includes/de_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,25 @@
<li role="separator" class="divider"></li>
<li>
<a href="{{ rd.pacer_url }}"
{% if not request.COOKIES.buy_on_pacer_modal and not request.COOKIES.recap_install_plea %}
{% if '-' in rd.pacer_doc_id %}
class="open_buy_acms_modal"
data-toggle="modal"
data-target="#modal-buy-acms"
{% elif not request.COOKIES.buy_on_pacer_modal and not request.COOKIES.recap_install_plea %}
class="open_buy_pacer_modal"
data-toggle="modal"
data-target="#modal-buy-pacer"
{% endif %}
target="_blank"
rel="nofollow">
{% if rd.is_free_on_pacer %}From PACER{% else %}Buy on PACER{% endif %} {% if rd.page_count %}(${{ rd|price }}){% endif %}
{% if '-' in rd.pacer_doc_id %}
Direct Link Unavailable
{% else %}
{% if rd.is_free_on_pacer %}From PACER{% else %}Buy on PACER{% endif %} {% if rd.page_count %}(${{ rd|price }}){% endif %}
{% endif %}
</a>
</li>
</li>
{% endif %}
</ul>
{% else %}
Expand All @@ -119,14 +128,23 @@
{% else %}
{% if rd.pacer_url %}
<a href="{{ rd.pacer_url }}"
{% if not request.COOKIES.buy_on_pacer_modal and not request.COOKIES.recap_install_plea %}
{% if '-' in rd.pacer_doc_id %}
class="disabled open_buy_acms_modal cursor btn btn-default btn-xs"
data-toggle="modal" data-target="#modal-buy-acms"
style="pointer-events: all;"
{% elif not request.COOKIES.buy_on_pacer_modal and not request.COOKIES.recap_install_plea %}
class="open_buy_pacer_modal btn btn-default btn-xs"
data-toggle="modal" data-target="#modal-buy-pacer"
{% else%}
class="btn btn-default btn-xs"
{% endif %}
target="_blank"
rel="nofollow">Buy on PACER {% if rd.page_count %}(${{ rd|price }}){% endif %}
rel="nofollow">
{% if '-' in rd.pacer_doc_id %}
Direct Link Unavailable
{% else %}
Buy on PACER {% if rd.page_count %}(${{ rd|price }}){% endif %}
{% endif %}
</a>
{% endif %}
{% endif %}
Expand All @@ -150,7 +168,12 @@
{% else %}
{% if rd.pacer_url %}
<a href="{{ rd.pacer_url }}"
{% if not request.COOKIES.buy_on_pacer_modal and not request.COOKIES.recap_install_plea %}
{% if '-' in rd.pacer_doc_id %}
data-toggle="modal"
data-target="#modal-buy-acms"
class="disabled open_buy_acms_modal cursor btn btn-default btn-xs"
style="pointer-events: all;"
{% elif not request.COOKIES.buy_on_pacer_modal and not request.COOKIES.recap_install_plea %}
data-toggle="modal"
data-target="#modal-buy-pacer"
class="open_buy_pacer_modal btn btn-default btn-xs"
Expand All @@ -159,7 +182,7 @@
{% endif %}
target="_blank"
rel="nofollow"
title="Buy on PACER {% if rd.page_count %}(${{ rd|price }}){% endif %}"><i class="fa fa-download"></i>
title="{% if '-' in rd.pacer_doc_id %}Direct Link Unavailable{% else%}Buy on PACER {% if rd.page_count %}(${{ rd|price }}){% endif %}{% endif %}"><i class="fa fa-download"></i>
</a>
{% endif %}
{% endif %}
Expand Down
28 changes: 20 additions & 8 deletions cl/opinion_page/templates/includes/rd_download_button.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,20 @@
</li>
<li role="separator" class="divider"></li>
{% endif %}
{% if rd.pacer_url %}
{% if rd.pacer_url or '-' in rd.pacer_doc_id%}
<li>
<a href="{{ rd.pacer_url }}"
{% if not request.COOKIES.buy_on_pacer_modal and not request.COOKIES.recap_install_plea %}
{% if '-' in rd.pacer_doc_id %}
data-toggle="modal" data-target="#modal-buy-acms"
class="open_buy_acms_modal"
{% elif not request.COOKIES.buy_on_pacer_modal and not request.COOKIES.recap_install_plea %}
data-toggle="modal" data-target="#modal-buy-pacer"
class="open_buy_pacer_modal"
{% endif %}
{% endif %}
target="_blank"
rel="nofollow">Buy on PACER</a>
rel="nofollow">
{% if '-' in rd.pacer_doc_id %}Direct Link Unavailable{% else %}Buy on PACER{% endif %}
</a>
</li>
{% endif %}
</ul>
Expand All @@ -42,16 +47,23 @@
{% if rd.is_sealed %}
<span class="btn btn-primary disabled">This Item is Sealed</span>
{% else %}
{% if rd.pacer_url %}
{% if rd.pacer_url or '-' in rd.pacer_doc_id%}
<a href="{{ rd.pacer_url }}"
{% if not request.COOKIES.buy_on_pacer_modal and not request.COOKIES.recap_install_plea %}
{% if '-' in rd.pacer_doc_id %}
data-toggle="modal" data-target="#modal-buy-acms"
class="disabled open_buy_acms_modal cursor btn btn-primary"
style="pointer-events: all;"
{% elif not request.COOKIES.buy_on_pacer_modal and not request.COOKIES.recap_install_plea %}
data-toggle="modal" data-target="#modal-buy-pacer"
class="open_buy_pacer_modal btn btn-primary"
{% else%}
{% else %}
class="btn btn-primary"
{% endif %}
target="_blank"
rel="nofollow"><i class="fa fa-external-link"></i> Buy on PACER</a>
rel="nofollow">
<i class="fa fa-external-link"></i>
{% if '-' in rd.pacer_doc_id %}Direct Link Unavailable{% else %}Buy on PACER{% endif %}
</a>
{% endif %}
{% endif %}
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions cl/opinion_page/templates/recap_document.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ <h2 class="inline"><a
class="no-underline black-link">{{ rd.docket_entry.docket|best_case_name|safe|v_wrapper }}</a></h2>
{% include "includes/notes_modal.html" %}
{% include "includes/buy_pacer_modal.html" %}
{% include "includes/buy_acms_modal.html" %}
{% if redirect_to_pacer_modal %}
{% include "includes/redirect_to_pacer_modal.html" %}
{% endif %}
Expand Down
15 changes: 11 additions & 4 deletions cl/recap/api_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ def validate(self, attrs):
"uploads."
)

if "-" in attrs.get("pacer_case_id"):
dashes = attrs.get("pacer_case_id").count("-")
if dashes == 1:
raise ValidationError(
"PACER case ID can not contains dashes -"
"PACER case ID can not contain a single (-); "
"that looks like a docket number."
)

return attrs
Expand Down Expand Up @@ -287,8 +289,13 @@ def validate(self, attrs):
"without 'court' parameter."
)

if attrs.get("pacer_case_id") and "-" in attrs.get("pacer_case_id"):
raise ValidationError("PACER case ID can not contains dashes -")
if attrs.get("pacer_case_id"):
dashes = attrs.get("pacer_case_id").count("-")
if dashes == 1:
raise ValidationError(
"PACER case ID can not contain a single (-); "
"that looks like a docket number."
)

if attrs.get("docket_number") and not attrs.get("court"):
# If a docket_number is included, is a court also?
Expand Down
1 change: 1 addition & 0 deletions cl/recap/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,5 @@ class DocketDataFactory(DictFactory):
case_name = Faker("case_name")
docket_entries = List([SubFactory(MinuteDocketEntryDataFactory)])
docket_number = Faker("federal_district_docket_number")
date_filed = Faker("date_object")
ordered_by = "date_filed"
Loading

0 comments on commit 102e7fc

Please sign in to comment.