fix: test-email actually sends; vote page pre-checks existing votes; lowercase MealPlanItemStatus everywhere

- /api/admin/test-email now calls get_email_backend().send() instead of only logging.
- /api/meals/vote/{id} GET now queries MealPlanVote and renders 'already voted' confirmation if found.
- api/meals.py: fix remaining uppercase MealPlanItemStatus enum ref (DENIED, APPROVED, PENDING).
- Fixes the 'all meals show as pending' status regression and the 'Error: Already voted' bug.
This commit is contained in:
2026-05-14 12:17:44 -07:00
parent 26d9985433
commit 6323eadc86
6 changed files with 77 additions and 27 deletions
+21 -3
View File
@@ -135,10 +135,27 @@ def get_all_meal_plans(
@router.post("/test-email")
def test_email(email: str, db: Session = Depends(get_db)):
from app.services.email import get_email_backend
html = "<html><body><h1>MealPlanner Test Email</h1><p>This is a test email from MealPlanner.</p></body></html>"
text = "MealPlanner Test Email\n\nThis is a test email from MealPlanner."
try:
backend = get_email_backend()
backend.send(
to=email,
subject="MealPlanner Test Email",
html=html,
text=text,
)
status = "sent"
except Exception as e:
status = f"failed: {e}"
email_log = EmailLog(
recipient_email=email,
template="test",
status="sent",
status=status,
created_at=datetime.now()
)
db.add(email_log)
@@ -146,9 +163,10 @@ def test_email(email: str, db: Session = Depends(get_db)):
db.refresh(email_log)
return {
"message": "Test email logged",
"message": f"Test email {status}",
"email_log_id": str(email_log.id),
"recipient": email
"recipient": email,
"status": status,
}