Skip to content

Commit 612c8b4

Browse files
committed
Merge branch 'main' into 3643-fix-recap-rss-feeds-unserializable-content-error
2 parents 49a0e8d + 51b2f7a commit 612c8b4

File tree

95 files changed

+1468
-2654
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1468
-2654
lines changed

cl/alerts/forms.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@ def __init__(self, *args, **kwargs):
1515

1616
def clean_rate(self):
1717
rate = self.cleaned_data["rate"]
18-
not_donated_enough = (
19-
self.user.profile.total_donated_last_year
20-
< settings.MIN_DONATION["rt_alerts"]
21-
)
22-
if rate == "rt" and not_donated_enough:
18+
is_a_member = self.user.profile.is_member
19+
if rate == "rt" and not is_a_member:
2320
# Somebody is trying to hack past the JS/HTML block on the front
2421
# end. Don't let them create the alert until they've donated.
2522
raise ValidationError(
26-
"You must donate more than $10 per year to create Real Time "
27-
"alerts."
23+
"You must be a Member to create Real Time alerts."
2824
)
2925
else:
3026
return rate

cl/alerts/management/commands/cl_send_alerts.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from django.utils.timezone import now
1414

1515
from cl.alerts.models import Alert, RealTimeQueue
16-
from cl.alerts.utils import InvalidDateError, user_has_donated_enough
16+
from cl.alerts.utils import InvalidDateError
1717
from cl.api.models import WebhookEventType
1818
from cl.api.webhooks import send_search_alert_webhook
1919
from cl.lib import search_utils
@@ -201,10 +201,7 @@ def send_emails_and_webhooks(self, rate):
201201
logger.info(f"Running alerts for user '{user}': {alerts}")
202202

203203
if rate == Alert.REAL_TIME:
204-
user_donated_enough = user_has_donated_enough(
205-
user, alerts.count()
206-
)
207-
if not user_donated_enough:
204+
if not user.profile.is_member:
208205
continue
209206

210207
hits = []

cl/alerts/tasks.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
alert_hits_limit_reached,
2020
override_alert_query,
2121
percolate_document,
22-
user_has_donated_enough,
2322
)
2423
from cl.api.models import WebhookEventType
2524
from cl.api.tasks import (
@@ -556,10 +555,7 @@ def process_percolator_response(response: PercolatorResponseType) -> None:
556555

557556
# Send RT Alerts
558557
if alert_triggered.rate == Alert.REAL_TIME:
559-
user_donated_enough = user_has_donated_enough(
560-
alert_user, alerts_count=1
561-
)
562-
if not user_donated_enough:
558+
if not alert_user.profile.is_member:
563559
continue
564560

565561
# Append alert RT email to be sent.

cl/alerts/templates/alert_email.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ <h3 class="alt bottom" style="font-size: 1.5em; font-weight: normal; line-height
6565
{% endfor %}
6666
<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;">
6767
<strong>This alert brought to you by the non-profit Free Law Project.
68-
<a href="https://www.courtlistener.com{% url "donate" %}?referrer=email" style="font-size: 100%; font-weight: inherit; font-family: inherit; color: #009; border: 0; font-style: inherit; padding: 0; text-decoration: none; vertical-align: baseline; margin: 0;">
68+
<a href="https://donate.free.law/forms/supportflp" style="font-size: 100%; font-weight: inherit; font-family: inherit; color: #009; border: 0; font-style: inherit; padding: 0; text-decoration: none; vertical-align: baseline; margin: 0;">
6969
Please donate to support our work</a>.
7070
</strong>
7171
</p>

cl/alerts/templates/alert_email.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Disable this Alert (one click): https://www.courtlistener.com{% url "disable_ale
2727
This alert brought to you by the 501(c)(3) non-profit Free Law Project
2828
- Blog: https://free.law
2929
- Twitter: http://twitter.com/freelawproject
30-
- Donate: https://www.courtlistener.com{% url "donate" %}?referrer=pt-email
30+
- Donate: https://donate.free.law/forms/supportflp
31+
- Become a Member: https://donate.free.law/forms/membership
3132

3233
Please donate to support our work.

cl/alerts/templates/alert_email_es.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ <h3 class="alt bottom" style="font-size: 1.5em; font-weight: normal; line-height
9090
{% endfor %}
9191
<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;">
9292
<strong>This alert brought to you by the non-profit Free Law Project.
93-
<a href="https://www.courtlistener.com{% url "donate" %}?referrer=email" style="font-size: 100%; font-weight: inherit; font-family: inherit; color: #009; border: 0; font-style: inherit; padding: 0; text-decoration: none; vertical-align: baseline; margin: 0;">
93+
<a href="https://donate.free.law/forms/supportflp" style="font-size: 100%; font-weight: inherit; font-family: inherit; color: #009; border: 0; font-style: inherit; padding: 0; text-decoration: none; vertical-align: baseline; margin: 0;">
9494
Please donate to support our work</a>.
9595
</strong>
9696
</p>

cl/alerts/templates/alert_email_es.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Disable this Alert (one click): https://www.courtlistener.com{% url "disable_ale
2828
This alert brought to you by the 501(c)(3) non-profit Free Law Project
2929
- Blog: https://free.law
3030
- Twitter: http://twitter.com/freelawproject
31-
- Donate: https://www.courtlistener.com{% url "donate" %}?referrer=pt-email
31+
- Donate: https://donate.free.law/forms/supportflp
32+
- Become a Member: https://donate.free.law/forms/membership
3233

3334
Please donate to support our work.

cl/alerts/templates/docket_alert_email.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ <h3 class="alt bottom" style="font-size: 1.5em; font-weight: normal; line-height
137137
{% endif %}
138138
<p style="font-size: 110%; font-weight: inherit; font-family: inherit; border: 0; vertical-align: baseline; font-style: inherit; margin: 0 0 1.5em; padding: 0;">
139139
<strong>This alert brought to you by the non-profit Free Law Project.
140-
<a href="https://www.courtlistener.com{% url "donate" %}?referrer=email" style="font-size: 100%; font-weight: inherit; font-family: inherit; color: #009; border: 0; font-style: inherit; padding: 0; text-decoration: none; vertical-align: baseline; margin: 0;">
140+
<a href="https://donate.free.law/forms/supportflp" style="font-size: 100%; font-weight: inherit; font-family: inherit; color: #009; border: 0; font-style: inherit; padding: 0; text-decoration: none; vertical-align: baseline; margin: 0;">
141141
Please donate to support our work</a>.
142142
</strong>
143143
</p>

cl/alerts/templates/docket_alert_email.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ This alert brought to you by the 501(c)(3) non-profit Free Law Project
4646

4747
- Blog: https://free.law
4848
- Twitter: http://twitter.com/freelawproject
49-
- Donate: https://www.courtlistener.com{% url "donate" %}?referrer=pt-email
49+
- Donate: https://donate.free.law/forms/supportflp
50+
- Become a Member: https://donate.free.law/forms/membership
5051

5152
Please donate to support our work.

cl/alerts/templates/docket_alert_unsubscription_email.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h2 style="font-size: 2em; font-weight: normal; font-family: inherit; color: #11
4848

4949
<p style="font-size: 110%; font-weight: inherit; font-family: inherit; border: 0; vertical-align: baseline; font-style: inherit; margin: 0 0 1.5em; padding: 0;">
5050
<strong>This alert brought to you by the non-profit Free Law Project.
51-
<a href="https://www.courtlistener.com{% url "donate" %}?referrer=email" style="font-size: 100%; font-weight: inherit; font-family: inherit; color: #009; border: 0; font-style: inherit; padding: 0; text-decoration: none; vertical-align: baseline; margin: 0;">
51+
<a href="https://donate.free.law/forms/supportflp" style="font-size: 100%; font-weight: inherit; font-family: inherit; color: #009; border: 0; font-style: inherit; padding: 0; text-decoration: none; vertical-align: baseline; margin: 0;">
5252
Please donate to support our work</a>.
5353
</strong>
5454
</p>

cl/alerts/templates/docket_alert_unsubscription_email.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This alert brought to you by the 501(c)(3) non-profit Free Law Project
1212

1313
- Blog: https://free.law
1414
- Twitter: http://twitter.com/freelawproject
15-
- Donate: https://www.courtlistener.com{% url "donate" %}?referrer=pt-email
15+
- Donate: https://donate.free.law/forms/supportflp
16+
- Become a Member: https://donate.free.law/forms/membership
1617

1718
Please donate to support our work.

cl/alerts/templates/emails/old_alert_email.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ <h2 style="font-size: 1.5em; font-weight: normal; font-family: inherit; color: #
5454
<strong>This message brought to you by the non-profit Free Law Project.</strong>
5555
</p>
5656
<p style="font-size: 110%; font-weight: inherit; font-family: inherit; border: 0; vertical-align: baseline; font-style: inherit; margin: 0 0 1.5em; padding: 0;">
57-
<a href="https://www.courtlistener.com{% url "donate" %}?referrer=disable-email" style="font-size: 100%; font-weight: inherit; font-family: inherit; color: #009; border: 0; font-style: inherit; padding: 0; text-decoration: none; vertical-align: baseline; margin: 0;">
57+
<a href="https://donate.free.law/forms/supportflp" style="font-size: 100%; font-weight: inherit; font-family: inherit; color: #009; border: 0; font-style: inherit; padding: 0; text-decoration: none; vertical-align: baseline; margin: 0;">
5858
Please donate to support our work</a>.
5959
</p>
6060
</body>

cl/alerts/templates/emails/old_alert_email.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ This message brought to you by the 501(c)(3) non-profit Free Law Project
4444

4545
- Twitter: http://twitter.com/freelawproject/
4646

47-
- Donate: https://www.courtlistener.com{% url "donate" %}?referrer=disable-email
47+
- Donate: https://donate.free.law/forms/supportflp
48+
49+
- Become a Member: https://donate.free.law/forms/membership
4850

4951
Please donate to support our work.

cl/alerts/templates/includes/docket_alert_donation.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h3 class="top text-center">Support Services Like this One</h3>
88
<div class="hidden-xs col-sm-1 col-md-2 col-lg-3"></div>
99
<div class="col-xs-12 col-sm-10 col-md-8 col-lg-6">
1010
<p class="text-center">
11-
<a href="{% url "donate" %}?referrer={{ request.path }}" class="btn btn-lg btn-block btn-danger"><i class="fa fa-heart-o"></i> Donate Now</a>
11+
<a href="https://donate.free.law/forms/supportflp" class="btn btn-lg btn-block btn-danger"><i class="fa fa-heart-o"></i> Donate Now</a>
1212
</p>
1313
</div>
1414
</div>

cl/alerts/templates/pacer_alert_email.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The PG&E bankruptcy appears to be available on PACER:
1313
This alert brought to you by the 501(c)(3) non-profit Free Law Project
1414
- Blog: https://free.law
1515
- Twitter: http://twitter.com/freelawproject
16-
- Donate: https://www.courtlistener.com{% url "donate" %}?referrer=pacer-alert-service
16+
- Donate: https://donate.free.law/forms/supportflp
17+
- Become a Member: https://donate.free.law/forms/membership
1718

1819
Thank you for supporting our work.

cl/alerts/tests.py

+14-31
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
from cl.audio.factories import AudioWithParentsFactory
5858
from cl.audio.models import Audio
5959
from cl.donate.factories import DonationFactory
60-
from cl.donate.models import Donation
60+
from cl.donate.models import Donation, NeonMembership
6161
from cl.favorites.factories import NoteFactory, UserTagFactory
6262
from cl.lib.test_helpers import EmptySolrTestCase, SimpleUserDataMixin
6363
from cl.search.documents import AudioDocument, AudioPercolator
@@ -307,10 +307,6 @@ def test_email_grantlist(self) -> None:
307307
up.email_grants_unlimited_docket_alerts,
308308
msg="Grantlist allowed even though email should not be on list.",
309309
)
310-
self.assertFalse(
311-
up.is_monthly_donor,
312-
msg="User is marked as monthly donor, but isn't.",
313-
)
314310
self.assertFalse(
315311
up.can_make_another_alert,
316312
msg="Was able to make alerts even though the max free "
@@ -526,11 +522,8 @@ def setUpTestData(cls):
526522
cls.rebuild_index("alerts.Alert")
527523
cls.user_profile = UserProfileWithParentsFactory()
528524
cls.user_profile_1 = UserProfileWithParentsFactory()
529-
cls.donation = DonationFactory(
530-
donor=cls.user_profile.user,
531-
amount=20,
532-
status=Donation.PROCESSED,
533-
send_annual_reminder=True,
525+
NeonMembership.objects.create(
526+
level=NeonMembership.LEGACY, user=cls.user_profile.user
534527
)
535528
cls.webhook_enabled = WebhookFactory(
536529
user=cls.user_profile.user,
@@ -1566,18 +1559,12 @@ def setUpTestData(cls):
15661559
citation_string="Bankr. C.D. Cal.",
15671560
)
15681561
cls.user_profile = UserProfileWithParentsFactory()
1569-
cls.donation = DonationFactory(
1570-
donor=cls.user_profile.user,
1571-
amount=20,
1572-
status=Donation.PROCESSED,
1573-
send_annual_reminder=True,
1562+
NeonMembership.objects.create(
1563+
level=NeonMembership.LEGACY, user=cls.user_profile.user
15741564
)
15751565
cls.user_profile_2 = UserProfileWithParentsFactory()
1576-
cls.donation = DonationFactory(
1577-
donor=cls.user_profile_2.user,
1578-
amount=20,
1579-
status=Donation.PROCESSED,
1580-
send_annual_reminder=True,
1566+
NeonMembership.objects.create(
1567+
level=NeonMembership.LEGACY, user=cls.user_profile_2.user
15811568
)
15821569
cls.webhook_enabled = WebhookFactory(
15831570
user=cls.user_profile.user,
@@ -2162,9 +2149,8 @@ def test_send_multiple_rt_alerts(self, mock_abort_audio):
21622149
contains more than ELASTICSEARCH_PAGINATION_BATCH_SIZE results. So additional
21632150
requests are performed in order to retrieve all the available results.
21642151
"""
2165-
2166-
donations = Donation.objects.all()
2167-
self.assertEqual(donations.count(), 2)
2152+
memberships = NeonMembership.objects.all()
2153+
self.assertEqual(memberships.count(), 2)
21682154
self.assertEqual(len(mail.outbox), 0)
21692155
webhook_events = WebhookEvent.objects.all()
21702156
self.assertEqual(len(webhook_events), 0)
@@ -2175,13 +2161,10 @@ def test_send_multiple_rt_alerts(self, mock_abort_audio):
21752161
user_profile = UserProfileWithParentsFactory.create()
21762162

21772163
if i != 1:
2178-
# Avoid creating a donation for one User in order to test this
2164+
# Avoid creating a membership for one User in order to test this
21792165
# RT Alert is not sent.
2180-
DonationFactory.create(
2181-
amount=20,
2182-
donor=user_profile.user,
2183-
status=Donation.PROCESSED,
2184-
send_annual_reminder=True,
2166+
NeonMembership.objects.create(
2167+
user=user_profile.user, level=NeonMembership.LEGACY
21852168
)
21862169
WebhookFactory(
21872170
user=user_profile.user,
@@ -2199,8 +2182,8 @@ def test_send_multiple_rt_alerts(self, mock_abort_audio):
21992182

22002183
webhooks = Webhook.objects.all()
22012184
self.assertEqual(len(webhooks), 11)
2202-
donations = Donation.objects.all()
2203-
self.assertEqual(len(donations), 11)
2185+
memberships = NeonMembership.objects.all()
2186+
self.assertEqual(len(memberships), 11)
22042187
total_rt_alerts = Alert.objects.filter(rate=Alert.REAL_TIME)
22052188
# 2 created in setUpTestData + 10
22062189
self.assertEqual(total_rt_alerts.count(), 12)

cl/alerts/utils.py

-23
Original file line numberDiff line numberDiff line change
@@ -93,29 +93,6 @@ def percolate_document(
9393
return s.execute()
9494

9595

96-
def user_has_donated_enough(
97-
alert_user: UserProfile.user, alerts_count: int
98-
) -> bool:
99-
"""Check if a user has donated enough to receive real-time alerts.
100-
101-
:param alert_user: The user object associated with the alerts.
102-
:param alerts_count: The number of real-time alerts triggered for the user.
103-
:return: True if the user has donated enough, otherwise False.
104-
"""
105-
106-
not_donated_enough = (
107-
alert_user.profile.total_donated_last_year
108-
< settings.MIN_DONATION["rt_alerts"]
109-
)
110-
if not_donated_enough:
111-
logger.info(
112-
"User: %s has not donated enough for their %s "
113-
"RT alerts to be sent.\n" % (alert_user, alerts_count)
114-
)
115-
return False
116-
return True
117-
118-
11996
def override_alert_query(
12097
alert: Alert, cut_off_date: date | None = None
12198
) -> QueryDict:

cl/api/templates/bulk-data.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ <h2 class="top text-center">Please Support Open Legal Data</h2>
191191
<div class="hidden-xs col-sm-1 col-md-2 col-lg-3"></div>
192192
<div class="col-xs-12 col-sm-10 col-md-8 col-lg-6">
193193
<p class="text-center">
194-
<a href="{% url "donate" %}?referrer={{ request.path }}" class="btn btn-lg btn-block btn-danger"><i class="fa fa-heart-o"></i> Donate Now</a>
194+
<a href="https://donate.free.law/forms/supportflp" class="btn btn-lg btn-block btn-danger"><i class="fa fa-heart-o"></i> Donate Now</a>
195195
</p>
196196
</div>
197197
</div>

cl/api/templates/includes/donate_footer_plea.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ <h2 class="top text-center">Please Support Open Legal Data</h2>
44
</p>
55
<p>We have provided these services for over a decade, and we need your contributions to continue curating and enhancing them.
66
</p>
7-
<p>Will you support us today with a donation?</p>
7+
<p>Will you support us today by becoming a member?</p>
88
<div class="row">
99
<div class="hidden-xs col-sm-1 col-md-2 col-lg-3"></div>
1010
<div class="col-xs-12 col-sm-10 col-md-8 col-lg-6">
1111
<p class="text-center">
12-
<a href="{% url "donate" %}?referrer={{ request.path }}" class="btn btn-lg btn-block btn-danger"><i class="fa fa-heart-o"></i> Donate Now</a>
12+
<a href="https://donate.free.law/forms/membership" class="btn btn-lg btn-block btn-danger"><i class="fa fa-heart-o"></i> Join FLP</a>
1313
</p>
1414
</div>
1515
</div>
16-
</div>
16+
</div>

cl/api/urls.py

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from cl.api import views
99
from cl.audio import api_views as audio_views
1010
from cl.disclosures import api_views as disclosure_views
11+
from cl.donate import api_views as donate_views
1112
from cl.favorites import api_views as favorite_views
1213
from cl.people_db import api_views as people_views
1314
from cl.recap import views as recap_views
@@ -137,6 +138,13 @@
137138
r"docket-alerts", alert_views.DocketAlertViewSet, basename="docket-alert"
138139
)
139140

141+
# Neon webhooks
142+
router.register(
143+
r"memberships",
144+
donate_views.MembershipWebhookViewSet,
145+
basename="membership-webhooks",
146+
)
147+
140148
API_TITLE = "CourtListener Legal Data API"
141149

142150

cl/assets/react/DisclosureList.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ const DisclosureFooter = () => {
4141
<p>All of the information you find here is available via our APIs or by browsing our database of judges.</p>
4242
<p>
4343
Creating this database was an expensive project for our organization. If you find this work valuable, please
44-
consider making a donation
44+
consider becoming a member.
4545
</p>
4646
<p>
47-
<a href="/donate/?referrer=fds-homepage" className="btn btn-danger btn-lg">
48-
Donate Now
47+
<a href="https://donate.free.law/forms/supportflp" className="btn btn-danger btn-lg">
48+
Join Now
4949
</a>
5050
</p>
5151
</div>

cl/assets/static-global/js/base.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ $(document).ready(function () {
182182
// Alerts //
183183
////////////
184184
$('#id_rate').on("change", function () {
185-
if ($(this).val() === 'rt' && totalDonatedLastYear < priceRtAlerts) {
185+
if ($(this).val() === 'rt' && !isMember) {
186186
$('#donate-for-rt').removeClass('hidden');
187187
$('#alertSave').prop("disabled", true);
188188
} else {

0 commit comments

Comments
 (0)