Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4507 pray and pay api #4519

Merged
merged 96 commits into from
Oct 15, 2024
Merged

Conversation

v-anne
Copy link
Contributor

@v-anne v-anne commented Oct 1, 2024

This is the PR for #4507, adding the API and frontend for the pray-and-pay project. It follows up on #4386 and #4498.

cl/favorites/tests.py Outdated Show resolved Hide resolved
@v-anne
Copy link
Contributor Author

v-anne commented Oct 1, 2024

@albertisfu @mlissner I think a rough version of the API endpoint is done. Apologies for any errors, I mostly followed DocketAlertViewSet and made some changes when I thought appropriate.

@mlissner mlissner marked this pull request as ready for review October 1, 2024 22:19
@mlissner
Copy link
Member

mlissner commented Oct 1, 2024

Very cool. Thanks @v-anne. I'll put it on Alberto's backlog for review.

@v-anne
Copy link
Contributor Author

v-anne commented Oct 14, 2024

Sorry about that @ERosendo. I didn't catch that issue in my local testing.

I suspect it was caused by the following line in de_list.html:

class="btn btn-default btn-xs prayer-button {% if not prayer_eligible %}disabled{% endif %}"

@ERosendo
Copy link
Contributor

Sorry about that @ERosendo. I didn't catch that issue in my local testing.

Don't worry @v-anne

@mlissner check out this GIF showing the button's functionality with htmx. This refactor addresses the issues highlighted in #4519 (comment).

Screen Recording 2024-10-15 at 12 18 17 AM

Let me know your thoughts.

@v-anne
Copy link
Contributor Author

v-anne commented Oct 15, 2024

I like your changes to it. It's easier to see which documents a user has requested. The only suggestion I have is to more clearly disable the button (perhaps by making it unclickable) for documents that users haven't previously requested once their quota is exhausted.

This is referring to Attachment 5 and Document 2 in your gif.

Also, do the different states of the button have corresponding mouseover text?

Replaces inline styles on the pray button with class-based styles in `override.css` for better maintainability and consistency.
Creates a reusable HTML fragment for the pray button
Updates the pray_button.html fragment to use the prayer_exists context variable. This provides a visual cue to users by changing the button's style when a document has already been requested.
Adds a custom JS script to the pray button element to provide immediate visual feedback to users upon interaction. This includes updating the button's appearance and incrementing/decrementing a counter to display the total number of prayers.
@ERosendo
Copy link
Contributor

Also, do the different states of the button have corresponding mouseover text?

Yes @v-anne. Here are screenshots:

Screenshot 2024-10-15 at 4 59 28 PM Screenshot 2024-10-15 at 4 59 59 PM

Removes `user_prayer_count` and `user_prayer_cost` variables from the `open_prayers` view as they are no longer used in the template.
@v-anne
Copy link
Contributor Author

v-anne commented Oct 15, 2024

This looks great!

Just want to note a bug I found when testing locally: when trying to toggle a button that is currently untoggled, the mouseover reads "You have reached your daily request limit" even if I haven't exhausted the quota.

I can't figure out what's wrong with this code, but for some reason the if statement never trips the "Click to request this document" case.

    <button type="submit"
            class="btn btn-xs {% if prayer_exists %}btn-primary{% else %}btn-default{% endif %}"
            data-document-id="{{ document_id }}"
            title="{% if prayer_exists %}Click to remove your request.{% elif not prayer_eligible %}You have reached your daily request limit.{% else %}Click to request this document.{% endif %}"
            >

Edit: never mind, I think it's a limitation of not refreshing the page between each interaction with a button. I think that's fine.

@v-anne
Copy link
Contributor Author

v-anne commented Oct 15, 2024

One last thing -- I think it would be helpful to have an explanation on top_prayers.html that explains to users how all of this works. I'm open to adding that in a subsequent PR with any API documentation (if needed), assuming the feature will gradually be rolled out to users.

@mlissner
Copy link
Member

I finally caught up here. I haven't looked at the code, but if everybody's happy and it's behind a waffle, let's merge. @ERosendo or @albertisfu, one of you want to go for it?

I think this feature needs a lot of explanation to users before we launch it, both on the top-prayers page, and on the docket pages themselves, but let's get this merged and then we can play with that with some feedback from others.

@ERosendo
Copy link
Contributor

@mlissner @v-anne Here's a little enhancement to the button:

Screen Recording 2024-10-15 at 6 44 45 PM

@mlissner I created the flag using the admin panel. I'll add one last commit and then merge this PR

Adds logic to check the prayers flag before computing prayer counts and adding them to the recap records.
This commit updates the prayer button template to add a tooltip that displays a message informing the user that they have reached their daily limit.
@mlissner mlissner merged commit 710ff4b into freelawproject:main Oct 15, 2024
9 checks passed
This was referenced Oct 16, 2024
@mlissner
Copy link
Member

I revered this PR in #4582 to fix #4581. No idea what was going on, but reverting fixed it. Let's see if we can figure that out, get a fix, and then do another PR.

@v-anne
Copy link
Contributor Author

v-anne commented Oct 16, 2024

That's disappointing, but we'll figure it out.

Mike, do you know if this PR also created issues with the RECAP extension? On PACER I no longer see the button to save a document to CourtListener.

@ERosendo
Copy link
Contributor

ERosendo commented Oct 16, 2024

Sorry @v-anne :( .

@mlissner I found the issue. In commit 09a9dd7, I added HTMX by updating the footer-scripts section of one of the templates we use on the docket page. However, I overlooked that this template extends from another HTML file that already includes scripts. As a result, my code overwrote the scripts section of the parent template, causing the issue described in #4581.

To avoid this conflict, we should simply include the pay_and_pray.js file directly in the parent template, which is the file named docket_tabs.html.

@mlissner
Copy link
Member

I thought it would be something like that, thanks.

I don't think this would also affect the extension, but we could open a new issue if needed for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants