settings: digest opt-in + tone (PATCH /api/settings/digest + UI)
Adds DigestPrefsIn/Out models, PATCH /api/settings/digest endpoint, email digest section in settings.html, and last_email_send context in pages.py. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5c89f4d04a
commit
14fe47103f
4 changed files with 176 additions and 1 deletions
|
|
@ -11,7 +11,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||
from app.auth import CurrentUser, maybe_current_user, require_auth, require_token
|
||||
from app.config import get_settings, load_groups
|
||||
from app.db import get_session
|
||||
from app.models import Referral, StrategicLog, User
|
||||
from app.models import EmailSend, Referral, StrategicLog, User
|
||||
from app.services.access import paid_status
|
||||
from app.services.referral_service import assign_code_if_missing
|
||||
from app.templates_env import templates
|
||||
|
|
@ -147,6 +147,13 @@ async def settings_page(
|
|||
|
||||
invite_url = str(request.url_for("login_page")) + f"?ref={user.referral_code}"
|
||||
|
||||
last_email_send = (await session.execute(
|
||||
select(EmailSend)
|
||||
.where(EmailSend.user_id == user.id)
|
||||
.order_by(desc(EmailSend.sent_at))
|
||||
.limit(1)
|
||||
)).scalar_one_or_none()
|
||||
|
||||
return templates.TemplateResponse(
|
||||
request, "settings.html",
|
||||
{
|
||||
|
|
@ -155,5 +162,6 @@ async def settings_page(
|
|||
"pending_count": int(pending_count),
|
||||
"converted_count": int(converted_count),
|
||||
"paid": paid_status(user),
|
||||
"last_email_send": last_email_send,
|
||||
},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue