Update web/core/views.py
This commit is contained in:
parent
e09b1c0ca9
commit
ad15ad3576
@ -8,6 +8,7 @@ from django.views.decorators.http import require_http_methods
|
|||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
import csv
|
import csv
|
||||||
import re
|
import re
|
||||||
|
import random
|
||||||
|
|
||||||
from .models import Entry
|
from .models import Entry
|
||||||
from .forms import ImportForm, EntryForm
|
from .forms import ImportForm, EntryForm
|
||||||
@ -563,4 +564,27 @@ def stats_page(request):
|
|||||||
"top_refs": top_refs,
|
"top_refs": top_refs,
|
||||||
"book_distribution": book_distribution,
|
"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
|
||||||
|
},
|
||||||
)
|
)
|
||||||
Loading…
Reference in New Issue
Block a user