-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
feat(favorites): frontend revisions to pray and pay project #4580
Conversation
@ERosendo this is the PR I'm going to build off of. |
for more information, see https://pre-commit.ci
Seeing some commit messages around the user-prayer page. Reminds me that it doesn't have to be available in the profile section, just like tags aren't. The user prayers page could just be linked from the mouseover for each emoji or from the most-wanted page, for example. |
Yeah, tags are what I am aiming to emulate. |
@ERosendo, do you think you could help, please? |
@mlissner sure! 👍 |
for more information, see https://pre-commit.ci
…rtlistener into 4507-pray-and-pay-API
@ERosendo in addition to those two issues with the buttons, I've mostly finished a MVP of the This is what it currently looks like. The status column is broken; I can't figure out why the backend isn't passing the information through to the template. I intend to add a button to allow users to delete requests and one for them to download available documents as well. |
4318237
to
141f78a
Compare
3e182c3
to
97fba33
Compare
@albertisfu Thanks for your feedback. I've implemented all your suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ERosendo this looks great.
Just left a couple of additional comments and suggestions.
@@ -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|datetime_in_utc}}">{{ docket_entry.datetime_filed|datetime_in_utc|date:"M j, Y" }}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this line: {{ docket_entry.datetime_filed|datetime_in_utc|date:"M j, Y" }}
, an empty value is displayed.
I believe the issue is that the datetime_in_utc
filter handles the date format internally, so applying an additional format causes it to fail. If we want to display a different format here, we might need to use a different approach, such as modifying datetime_in_utc
to accept an optional custom format.
Same for the .txt version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can pass timezone
as a template variable instead of using the datetime_in_utc
filter and use this custom format, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that's also a valid approach!
cl/favorites/utils.py
Outdated
filtered_list.values("recap_document") | ||
.distinct() | ||
.annotate( | ||
price=Case( | ||
When(recap_document__is_free_on_pacer=True, then=Value(0.0)), | ||
When( | ||
recap_document__page_count__gt=0, | ||
then=Least( | ||
Value(3.0), | ||
F("recap_document__page_count") * Value(0.10), | ||
), | ||
), | ||
default=Value(0.0), | ||
) | ||
) | ||
.aaggregate(Sum("price", default=0.0)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can avoid the duplicate code in this method and in get_lifetime_prayer_stats
by encapsulating the shared logic into a separate method, something like:
async def compute_cost(queryset):
return await (
queryset.values("recap_document")
.distinct()
.annotate(
price=Case(
When(recap_document__is_free_on_pacer=True, then=Value(0.0)),
When(
recap_document__page_count__gt=0,
then=Least(
Value(3.0),
F("recap_document__page_count") * Value(0.10),
),
),
default=Value(0.0),
)
)
.aaggregate(Sum("price", default=0.0))
)
And then just using:
cost = await compute_cost(filtered_list)
OR:
total_cost = await compute_cost(prayer_by_status.select_related("recap_document"))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct! I'll create this new helper function.
cl/favorites/utils.py
Outdated
"count": prayer_count, | ||
"num_distinct_purchases": distinct_prayers, | ||
"total_cost": f"{total_cost:,.2f}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the same key names here as in PrayerStats
?
I believe if we do something like:
"count": prayer_count, | |
"num_distinct_purchases": distinct_prayers, | |
"total_cost": f"{total_cost:,.2f}", | |
"prayer_count": prayer_count, | |
"distinct_count": distinct_prayers, | |
"total_cost": f"{total_cost:,.2f}", |
Then in both returns we can do:
return PrayerStats(**data)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct! Thanks for bringing this to my attention.
@albertisfu Ready for another review 😃 |
74215f3
to
128de7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! this now looks good to me
Right on. Into the maw it goes!! Thank you all for the teamwork polishing and refining this one. I'm looking forward to giving it a try. |
This is the PR for making frontend changes to the pray and pay user interface.
Mike had some great comments in #4507, so we'll start with them and see what's needed once the low-hanging fruit is done.
Additions include:
recap_document.html
page.top_prayers.html
to provide better UX.user_prayers.html
page to allow users to see their open and fulfilled prayers, and also summary statistics about how many requests they've had fulfilled. In a future PR, this will be made similar to tags to allow people (e.g., freelance journalists) to share documents they've requested.