Skip to content

Commit

Permalink
prayer help page
Browse files Browse the repository at this point in the history
  • Loading branch information
v-anne committed Oct 17, 2024
1 parent b63b27b commit 4eb6484
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cl/simple_pages/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
markdown_help,
old_terms,
podcasts,
prayer_help,
recap_email_help,
tag_notes_help,
validate_for_wot,
Expand Down Expand Up @@ -59,6 +60,7 @@
path("help/search-operators/", advanced_search, name="advanced_search"), # type: ignore[arg-type]
path("help/recap/email/", recap_email_help, name="recap_email_help"), # type: ignore[arg-type]
path("help/broken-email/", broken_email_help, name="broken_email_help"), # type: ignore[arg-type]
path("help/pray-and-pay/", prayer_help, name="pray_and_pay_help"), # type: ignore[arg-type]
# Added 2018-10-23
path(
"search/advanced-techniques/",
Expand Down
25 changes: 25 additions & 0 deletions cl/simple_pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Reimbursement,
SpouseIncome,
)
from cl.favorites.utils import get_lifetime_prayer_stats
from cl.people_db.models import Person
from cl.search.models import (
SOURCES,
Expand Down Expand Up @@ -132,6 +133,30 @@ async def markdown_help(request: HttpRequest) -> HttpResponse:
)


async def prayer_help(request: HttpRequest) -> HttpResponse:
cache_key = "prayer-help-stats"
data = await cache.aget(cache_key)
if data is None:
count, num_distinct_purchases, total_cost = await get_lifetime_prayer_stats()
data = {
"count": count,
"num_distinct_purchases": num_distinct_purchases,
"total_cost": total_cost,
"daily_quota": await settings.ALLOWED_PRAYER_COUNT
}
one_day = 60 * 60 * 24
await cache.aset(cache_key, data, one_day)

context = {
"private": False,
}
context.update(data)

return TemplateResponse(
request, "help/prayer_help.html", context
)


async def tag_notes_help(request: HttpRequest) -> HttpResponse:
return TemplateResponse(request, "help/tags_help.html", {"private": False})

Expand Down

0 comments on commit 4eb6484

Please sign in to comment.