Add context processors for base template

This commit is contained in:
2023-01-08 16:49:13 -05:00
parent 1ec4333856
commit 71a8a19491
4 changed files with 22 additions and 4 deletions

View File

@ -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(),
}

View File

@ -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(),
}

View File

@ -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",
],
},
},

View File

@ -89,8 +89,8 @@
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Movies</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{ url "games:gamesystem_list" %}">All</a>
{% for system in game_systems %}
<a class="dropdown-item" href="{{system.get_absolute_url}}">{{system.name}} ({{system.game_set.count}})</a>
{% for movie in movie_list %}
<a class="dropdown-item" href="{{movie.get_absolute_url}}">{{movie.title}}</a>
{% endfor %}
</div>
</li>
@ -98,8 +98,8 @@
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Shows</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{ url "games:gamecollection_list" %}">All</a>
{% for collection in game_collections %}
<a class="dropdown-item" href="{{collection.get_absolute_url}}">{{collection.name}} ({{collection.games.count}})</a>
{% for series in series_list %}
<a class="dropdown-item" href="{{series.get_absolute_url}}">{{series.name}}</a>
{% endfor %}
</div>
</li>