From c32c8cb0e6b670b1d8f3b92eb347af1828646641 Mon Sep 17 00:00:00 2001 From: Joshua Laymon Date: Sun, 24 Aug 2025 19:18:16 +0000 Subject: [PATCH] Update web/core/context_processors.py --- web/core/context_processors.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/web/core/context_processors.py b/web/core/context_processors.py index 8060316..5e3f4ad 100644 --- a/web/core/context_processors.py +++ b/web/core/context_processors.py @@ -1,4 +1,5 @@ from pathlib import Path +from .models_ann import Announcement, AnnouncementDismissal def app_version(request): version_file = Path(__file__).resolve().parent.parent / "version.txt" @@ -7,4 +8,21 @@ def app_version(request): version = f.read().strip() except FileNotFoundError: version = "v0.0.0" - return {"APP_VERSION": version} \ No newline at end of file + return {"APP_VERSION": version} + + + +def pending_announcement(request): + """ + Expose the latest active, current announcement the user has not dismissed. + We'll only use it on the Search page via include. + """ + user = getattr(request, "user", None) + if not (user and user.is_authenticated): + return {"pending_announcement": None} + + current = [a for a in Announcement.objects.all() if a.is_current()] + for a in current: + if not AnnouncementDismissal.objects.filter(user=user, announcement=a).exists(): + return {"pending_announcement": a} + return {"pending_announcement": None} \ No newline at end of file