From 71a8a19491b35fd8babefa6bce987460170d8883 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sun, 8 Jan 2023 16:49:13 -0500 Subject: [PATCH] Add context processors for base template --- vrobbler/apps/music/context_processors.py | 8 ++++++++ vrobbler/apps/videos/context_processors.py | 8 ++++++++ vrobbler/settings.py | 2 ++ vrobbler/templates/base.html | 8 ++++---- 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 vrobbler/apps/music/context_processors.py create mode 100644 vrobbler/apps/videos/context_processors.py diff --git a/vrobbler/apps/music/context_processors.py b/vrobbler/apps/music/context_processors.py new file mode 100644 index 0000000..3db98e0 --- /dev/null +++ b/vrobbler/apps/music/context_processors.py @@ -0,0 +1,8 @@ +from music.models import Artist, Album + + +def music_lists(request): + return { + "artist_list": Artist.objects.all(), + "album_list": Album.objects.all(), + } diff --git a/vrobbler/apps/videos/context_processors.py b/vrobbler/apps/videos/context_processors.py new file mode 100644 index 0000000..34be4aa --- /dev/null +++ b/vrobbler/apps/videos/context_processors.py @@ -0,0 +1,8 @@ +from videos.models import Video, Series + + +def video_lists(request): + return { + "movie_list": Video.objects.filter(video_type=Video.VideoType.MOVIE), + "series_list": Series.objects.all(), + } diff --git a/vrobbler/settings.py b/vrobbler/settings.py index 6cd4db5..bb4f415 100644 --- a/vrobbler/settings.py +++ b/vrobbler/settings.py @@ -119,6 +119,8 @@ TEMPLATES = [ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + "videos.context_processors.video_lists", + "music.context_processors.music_lists", ], }, }, diff --git a/vrobbler/templates/base.html b/vrobbler/templates/base.html index a487c74..59e6ad9 100644 --- a/vrobbler/templates/base.html +++ b/vrobbler/templates/base.html @@ -89,8 +89,8 @@ @@ -98,8 +98,8 @@