Coverage for app/notifications/routes.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-31 10:13 +0000

1""" 

2Notifications blueprint — public one-click snooze links delivered in 

3reminder emails. No @login_required: the token itself is the credential, 

4same pattern as auth.reset_password / share.public_view. 

5""" 

6 

7from datetime import UTC, datetime 

8 

9from flask import ( # pyright: ignore[reportMissingImports] 

10 Blueprint, 

11 make_response, 

12 render_template, 

13 request, 

14) 

15from flask.typing import ResponseReturnValue # pyright: ignore[reportMissingImports] 

16from models import NotificationSnooze, db # pyright: ignore[reportMissingImports] 

17 

18notifications_bp = Blueprint("notifications", __name__) 

19 

20 

21@notifications_bp.route("/notifications/snooze/<token>", methods=["GET", "POST"]) 

22def snooze(token: str) -> ResponseReturnValue: 

23 """Confirm (POST) or preview (GET) snoozing one specific reminder 

24 instance until its underlying deadline value changes.""" 

25 row = NotificationSnooze.query.filter_by(token=token).first_or_404() 

26 

27 if request.method == "POST": 

28 row.snoozed_value = row.current_value 

29 row.snoozed_at = datetime.now(UTC) 

30 db.session.commit() 

31 

32 resp = make_response(render_template("notifications/snooze.html", snooze=row)) 

33 resp.headers["X-Robots-Tag"] = "noindex, nofollow" 

34 return resp