Skip to content

Commit

Permalink
Merge pull request #4580 from v-anne/4507-pray-and-pay-API
Browse files Browse the repository at this point in the history
feat(favorites): frontend revisions to pray and pay project
  • Loading branch information
mlissner authored Dec 19, 2024
2 parents 77f47e2 + 128de7c commit 5c54b88
Show file tree
Hide file tree
Showing 24 changed files with 817 additions and 141 deletions.
8 changes: 8 additions & 0 deletions cl/assets/static-global/css/override.css
Original file line number Diff line number Diff line change
Expand Up @@ -1829,3 +1829,11 @@ rect.series-segment {
.prayer-button[data-gap-size="large"]{
margin-left: 44px;
}

.gap-1 {
gap: 0.25rem
}

.gap-2 {
gap: 0.5rem
}
2 changes: 1 addition & 1 deletion cl/assets/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ <h1>You did not supply the "private" variable to your template.
</li>
{% flag "pray-and-pay" %}
<li>
<a href="{% url "top_prayers" %}#recap-alerts" tabindex="203">Pray and Pay Project</a>
<a href="{% url "top_prayers" %}" tabindex="203">Pray and Pay Project</a>
</li>
{% endflag %}
<li>
Expand Down
7 changes: 4 additions & 3 deletions cl/favorites/templates/prayer_email.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% load text_filters %}
{% load humanize %}
{% load extras %}
{% load tz %}

<!DOCTYPE html>
Expand Down Expand Up @@ -44,7 +45,7 @@ <h3 class="alt bottom" style="font-size: 1.5em; font-weight: normal; line-height
<td style="text-align: center">{{ docket_entry.entry_number }}{% if rd.attachment_number %}-{{ rd.attachment_number }}{% endif %}</td>
<td>
{% if docket_entry.datetime_filed %}
<span title="{{ docket_entry.datetime_filed|timezone:timezone}}">{{ docket_entry.datetime_filed|timezone:timezone|date:"M j, Y" }}</span>
<span title="{{ docket_entry.datetime_filed|utc}}">{{ docket_entry.datetime_filed|utc|date:"M j, Y" }}</span>
{% else %}
{{ docket_entry.date_filed|date:"M j, Y"|default:'<em class="gray">Unknown</em>' }}
{% endif %}
Expand All @@ -64,8 +65,8 @@ <h3 class="alt bottom" style="font-size: 1.5em; font-weight: normal; line-height
</tbody>
</table>

<p>You requested it on {{ date_created|date:"M j, Y" }}
<p>{{num_waiting}} people were also waiting for it.</p>
<p>You requested it on {{ date_created|date:"F j, Y" }}.</p>
<p>{{num_waiting}} {{ num_waiting|pluralize:"person was,people were" }} waiting for it.</p>
{% if price %}<p>Somebody paid ${{ price }} to make it available to all of us.</p>{% endif %}

<p style="font-size: 1em; font-weight: inherit; font-family: inherit; border: 0; vertical-align: baseline; font-style: inherit; margin: 0 0 1.5em; padding: 0;">
Expand Down
8 changes: 4 additions & 4 deletions cl/favorites/templates/prayer_email.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load text_filters %}{% load humanize %}{% load tz %}*****************
{% load text_filters %}{% load humanize %}{% load tz %}{% load extras %}*****************
CourtListener.com
*****************
-------------------------------------------------------
Expand All @@ -14,12 +14,12 @@ The document you were waiting for is now available in RECAP.
View Docket: https://www.courtlistener.com{{ docket.get_absolute_url }}?order_by=desc

Document Number: {{ docket_entry.entry_number }}{% if rd.attachment_number %}-{{ rd.attachment_number }}{% endif %}
Date Filed: {% if docket_entry.datetime_filed %}{{ docket_entry.datetime_filed|timezone:timezone|date:"M j, Y" }}{% else %}{{ docket_entry.date_filed|date:"M j, Y"|default:'Unknown' }}{% endif %}
Date Filed: {% if docket_entry.datetime_filed %}{{ docket_entry.datetime_filed|utc|date:"M j, Y" }}{% else %}{{ docket_entry.date_filed|date:"M j, Y"|default:'Unknown' }}{% endif %}
Description: {% if rd.description %}{{ rd.description|safe|wordwrap:80 }}{% else %}{{ docket_entry.description|default:"Unknown docket entry description"|safe|wordwrap:80 }}{% endif %}
View Document: https://www.courtlistener.com{{document_url}}
~~~
You requested it on {{ date_created|date:"M j, Y" }}
{{num_waiting}} people were also waiting for it.
You requested it on {{ date_created|date:"F j, Y" }}.
{{num_waiting}} {{ num_waiting|pluralize:"person was,people were" }} waiting for it.
Somebody paid ${{ price }} to make it available to all of us.

************************
Expand Down
43 changes: 35 additions & 8 deletions cl/favorites/templates/top_prayers.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% load text_filters %}
{% load static %}
{% load pacer %}
{% load humanize %}

{% block title %}RECAP Requests – CourtListener.com{% endblock %}
{% block og_title %}RECAP Requests – CourtListener.com{% endblock %}
Expand All @@ -12,28 +13,54 @@


{% block content %}
<div class="col-xs-12">
<h1 class="text-center">Community's Most Requested Documents</h1>
</div>


<div class="col-xs-12">
<div class="well well-sm">
<p>There have been <b>{{ granted_stats.prayer_count|intcomma }}</b> requests granted for <b>{{ granted_stats.distinct_count|intcomma }}</b> unique documents that cost <b>${{ granted_stats.total_cost }}</b>.</p>
<br>
<p>There are <b>{{ waiting_stats.prayer_count|intcomma }}</b> requests pending for <b>{{ waiting_stats.distinct_count|intcomma }}</b> unique documents that cost at least <b>${{ waiting_stats.total_cost }}</b>.</p>
<br>
<p>{% if user.is_authenticated %}
<a href="{% url 'user_prayers' user.username %}">View your prayers</a>
{% else %}
<a href="{% url 'sign-in' %}?next={% url 'top_prayers' %}">Sign in to view your prayers</a>
{% endif %}</p>
</div>
</div>

<div class="col-xs-12">
<div class="table-responsive">
<table class="settings-table table">
<thead>
<tr>
<th>User Preference</th>
<th>Document Description</th>
<th>Court</th>
<th>Case Name</th>
<th>Document Number</th>
<th>PACER Doc ID</th>
<th>Document Court</th>
<th>Document Description</th>
<th>Buy on Pacer</th>
</tr>
</thead>
<tbody>
{% for prayer in top_prayers %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ prayer.docket_entry.docket.court.citation_string }}</td>
{% with docket=prayer.docket_entry.docket %}
<td>
<a href="{% url "view_docket" docket.pk docket.slug %}">
{{ prayer.docket_entry.docket|best_case_name|safe|v_wrapper }} ({{ prayer.docket_entry.docket.docket_number }})
</a>
</td>
<td>
<a href="{% url "view_docket" docket.pk docket.slug %}#entry-{{ prayer.docket_entry.entry_number }}">
{{ prayer.document_number }}
</a>
</td>
{% endwith %}
<td>{{ prayer.description }}</td>
<td>{{ prayer.document_number }}</td>
<td>{{ prayer.pacer_doc_id }}</td>
<td>{{ prayer.docket_entry.docket.court_id }}</td>
<td><a href="{{ prayer.pacer_url }}"
{% if not request.COOKIES.buy_on_pacer_modal and not request.COOKIES.recap_install_plea %}
class="open_buy_pacer_modal btn btn-default btn-xs"
Expand Down
145 changes: 145 additions & 0 deletions cl/favorites/templates/user_prayers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{% extends "base.html" %}
{% load extras %}
{% load text_filters %}
{% load static %}
{% load pacer %}
{% load tz %}
{% load humanize %}

{% block title %}{% if is_page_owner %}Your RECAP Requests {% else %}RECAP Requests for: {{ requested_user }}{% endif %} – CourtListener.com{% endblock %}
{% block og_title %}{% if is_page_owner %}Your RECAP Requests {% else %}RECAP Requests for: {{ requested_user }}{% endif %} – CourtListener.com{% endblock %}
{% block description %}CourtListener lets you request purchase of legal documents. View the document requests for {{ requested_user }}.{% endblock %}
{% block og_description %}CourtListener lets you request purchase of legal documents. View the document requests for {{ requested_user }}.{% endblock %}

{% block content %}
<div class="col-xs-12">
<h1 class="text-center">{% if is_page_owner %}Your RECAP Requests {% else %}RECAP Requests for: {{ requested_user }}{% endif %}</h1>
</div>

<div class="col-xs-12" id="prayer_summary" hx-swap-oob="true"
{% if request.user.is_authenticated %}
hx-get="{% url 'user_prayers' request.user.username %}"
hx-trigger="prayersListChanged from:body" hx-swap="none"
{%endif %}
>
<div class="well well-sm">
{% if is_page_owner %}
<p>
You have had <b>{{ count|intcomma }}</b> requests fulfilled for documents that cost <b>${{total_cost|floatformat:2 }}</b>.
</p>
<p>
{% if is_eligible %}You are eligible to make document requests.{% else %}You have reached your daily limit; wait 24 hours to make new requests.{% endif %}
</p>
{% endif %}
</div>
</div>

<div class="col-xs-12" id="prayer_list" hx-swap-oob="true">
<div class="table-responsive">
<table class="settings-table table">
<thead>
<tr>
<th>Court</th>
<th>Case Name</th>
<th>Document Number</th>
<th>Document Description</th>
<th>Requested On</th>
<th>Status</th>
{% if is_page_owner %}<th>Action</th>{% endif %}
</tr>
</thead>
<tbody>
{% for rd in rd_with_prayers %}
<tr>
<td>{{ rd.docket_entry.docket.court.citation_string }}</td>
{% with docket=rd.docket_entry.docket %}
<td>
<a href="{% url "view_docket" docket.pk docket.slug %}">
{{ docket|best_case_name|safe|v_wrapper }} ({{ docket.docket_number }})
</a>
</td>
<td>
<a href="{% url "view_docket" docket.pk docket.slug %}#entry-{{ rd.docket_entry.entry_number }}">
{{ rd.document_number }}
</a>
</td>
{% endwith %}
<td>{{ rd.description }}</td>
<td>{{ rd.prayer_date_created|date:"M j, Y" }}</td>
<td>{% if rd.prayer_status == 1 %} Pending {% elif rd.prayer_status == 2 %}
<div class="btn-group hidden-xs col-sm-4 col-md-3 hidden-print flex">
{% if rd.filepath_local %}
<a href="{{ rd.filepath_local.url }}"
rel="nofollow"
role="button"
class="btn btn-primary btn-xs"
{% if rd.date_upload %}
title="Uploaded {{ rd.date_upload|datetime_in_utc }}"
{% endif %}>
Download PDF
</a>
<button type="button"
class="btn btn-primary btn-xs dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li>
<a href="{{ rd.filepath_local.url }}" rel="nofollow">From
CourtListener</a>
</li>
{% if rd.filepath_ia %}
<li>
<a href="{{ rd.filepath_ia }}"
rel="nofollow">From
Internet Archive</a>
</li>
{% endif %}
</ul>
{% endif %}
</div>
{% endif %}
</td>
{% if is_page_owner and rd.prayer_status != 2 %}
<td>
<div class="flex justify-content-center">
<form id="pray_{{rd.pk}}" hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-swap="none"
hx-post="{% url 'delete_prayer' rd.pk %}" hx-indicator="#delete-spinner-{{rd.pk}}">
<input type="hidden" name="source" value="user_prayer_list">
<button class="btn btn-danger btn-xs">
<i class="fa fa-trash-o"></i>
</button>
</form>
&nbsp;
<span id="delete-spinner-{{rd.pk}}" class="htmx-hidden-indicator" >
<i class="fa fa-spinner fa-spin fa-lg"></i>
</span>
</div>
</td>
{% endif %}
</tr>
{% empty %}
<tr>
<td colspan="2">No document requests made. Consider making one!</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}

{% block footer-scripts %}
<script defer type="text/javascript"
src="{% static "js/buy_pacer_modal.js" %}"></script>
{% if DEBUG %}
<script src="{% static "js/htmx.js" %}"></script>
<script src="{% static "js/fix-toolbar-for-htmx.js" %}"></script>
{% else %}
<script src="{% static "js/htmx.min.js" %}"></script>
{% endif %}
{% include "includes/buy_pacer_modal.html" %}
{% endblock %}
Loading

0 comments on commit 5c54b88

Please sign in to comment.