Skip to content

Commit

Permalink
Merge pull request #4386 from v-anne/1346-create-recap-pray-and-pay
Browse files Browse the repository at this point in the history
1346 create recap pray and pay
  • Loading branch information
mlissner authored Sep 23, 2024
2 parents d7c6652 + 0763a68 commit 21d74fb
Show file tree
Hide file tree
Showing 14 changed files with 525 additions and 13 deletions.
8 changes: 7 additions & 1 deletion cl/favorites/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin

from cl.favorites.models import DocketTag, Note, UserTag
from cl.favorites.models import DocketTag, Note, Prayer, UserTag


class NoteInline(admin.TabularInline):
Expand Down Expand Up @@ -49,3 +49,9 @@ class UserTagAdmin(admin.ModelAdmin):
class UserTagInline(admin.StackedInline):
model = UserTag
extra = 0


@admin.register(Prayer)
class PrayerAdmin(admin.ModelAdmin):
raw_id_fields = ("user", "recap_document")
readonly_fields = ("date_created",)
17 changes: 15 additions & 2 deletions cl/favorites/factories.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from factory import Faker, SubFactory
from factory.django import DjangoModelFactory

from cl.favorites.models import Note, UserTag
from cl.search.factories import OpinionClusterWithParentsFactory
from cl.favorites.models import Note, Prayer, UserTag
from cl.search.factories import (
OpinionClusterWithParentsFactory,
RECAPDocumentFactory,
)
from cl.users.factories import UserWithChildProfileFactory


Expand All @@ -19,3 +22,13 @@ class Meta:
class UserTagFactory(DjangoModelFactory):
class Meta:
model = UserTag


class PrayerFactory(DjangoModelFactory):
class Meta:
model = Prayer

date_created = Faker("date_time_this_year")
user = SubFactory(UserWithChildProfileFactory)
recap_document = SubFactory(RECAPDocumentFactory)
status = Faker("random_element", elements=[Prayer.WAITING, Prayer.GRANTED])
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.0.8 on 2024-09-21 15:16

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
(
"favorites",
"0007_rename_prayer_recap_document_status_favorites_p_recap_d_00e8c5_idx_and_more",
),
("search", "0034_add_harvard_pdf_to_opinioncluster"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.AddConstraint(
model_name="prayer",
constraint=models.UniqueConstraint(
fields=("user", "recap_document"),
name="unique_prayer_for_user_document",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BEGIN;
--
-- Create constraint unique_prayer_for_user_document on model prayer
--
ALTER TABLE "favorites_prayer" ADD CONSTRAINT "unique_prayer_for_user_document" UNIQUE ("user_id", "recap_document_id");
COMMIT;
6 changes: 6 additions & 0 deletions cl/favorites/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ class Prayer(models.Model):
)

class Meta:
constraints = [
models.UniqueConstraint(
fields=["user", "recap_document"],
name="unique_prayer_for_user_document",
),
]
indexes = [
# When adding a new document to RECAP, we'll ask: What outstanding
# prayers do we have for this document?
Expand Down
44 changes: 44 additions & 0 deletions cl/favorites/templates/top_prayers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% extends "base.html" %}
{% load extras %}
{% load text_filters %}
{% load static %}


{% block title %}RECAP Requests – CourtListener.com{% endblock %}
{% block og_title %}RECAP Requests – CourtListener.com{% endblock %}

{% block description %}Lorem Ipsum on CourtListener.{% endblock %}
{% block og_description %}Lorem Ipsum on CourtListener.{% endblock %}

{% block content %}
<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>Document Number</th>
<th>PACER Doc ID</th>
<th>Document Court</th>
</tr>
</thead>
<tbody>
{% for prayer in top_prayers %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ prayer.description }}</td>
<td>{{ prayer.document_number }}</td>
<td>{{ prayer.pacer_doc_id }}</td>
<td>{{ prayer.docket_entry.docket.court_id }}</td>
</tr>
{% empty %}
<tr>
<td colspan="2">No document requests open. Consider making one!</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
Loading

0 comments on commit 21d74fb

Please sign in to comment.