Files
Django_TasksApp/main/planner/context_processors.py
T

15 lines
577 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Template context shared by Tasknest pages."""
from .models import UserSettings
def appearance(request):
"""Expose the signed-in user’s saved colour preference without creating settings."""
user = getattr(request, "user", None)
if user is not None and user.is_authenticated:
saved_appearance = (
UserSettings.objects.filter(user=user).values_list("appearance", flat=True).first()
)
return {"user_appearance": saved_appearance or UserSettings.Appearance.LIGHT}
return {"user_appearance": UserSettings.Appearance.LIGHT}