From ad15ad35766d548dbbcb554ef292165adfedac32 Mon Sep 17 00:00:00 2001 From: Joshua Laymon Date: Thu, 14 Aug 2025 17:57:13 +0000 Subject: [PATCH] Update web/core/views.py --- web/core/views.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/web/core/views.py b/web/core/views.py index 58af611..58d8dd8 100644 --- a/web/core/views.py +++ b/web/core/views.py @@ -8,6 +8,7 @@ from django.views.decorators.http import require_http_methods from datetime import date, timedelta import csv import re +import random from .models import Entry from .forms import ImportForm, EntryForm @@ -563,4 +564,27 @@ def stats_page(request): "top_refs": top_refs, "book_distribution": book_distribution, }, + ) + +@login_required +def search_page(request): + # ... your existing search logic above ... + + # --- Illustration of the Day (simple, no persistence required) --- + illustration_entry = None + qs_day = Entry.objects.exclude(illustration__isnull=True).exclude(illustration="") + if qs_day.exists(): + chosen = qs_day.order_by("?").first() # simple random row + illustration_entry = { + "illustration": chosen.illustration or "", + "application": chosen.application or "", + } + + return render( + request, + "search.html", + { + # ... your existing context keys ... + "illustration_of_the_day": illustration_entry, # << add this + }, ) \ No newline at end of file