Hide navigation bar items
If there are no games/purchases/sessions, hide the related navbar items
This commit is contained in:
parent
84c92fe654
commit
5c50e059e6
|
@ -0,0 +1,2 @@
|
|||
## Unreleased
|
||||
* Hide navigation bar items if there are no games/purchases/sessions
|
|
@ -23,9 +23,15 @@
|
|||
<ul
|
||||
class="flex flex-col md:flex-row p-4 mt-4 dark:text-white">
|
||||
<li><a class="block py-2 pl-3 pr-4 hover:underline" href="{% url 'add_game' %}">New Game</a></li>
|
||||
{% if game_available and platform_available %}
|
||||
<li><a class="block py-2 pl-3 pr-4 hover:underline" href="{% url 'add_purchase' %}">New Purchase</a></li>
|
||||
{% endif %}
|
||||
{% if purchase_available %}
|
||||
<li><a class="block py-2 pl-3 pr-4 hover:underline" href="{% url 'add_session' %}">New Session</a></li>
|
||||
{% endif %}
|
||||
{% if session_count > 0 %}
|
||||
<li><a class="block py-2 pl-3 pr-4 hover:underline" href="{% url 'list_sessions' %}">All Sessions</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -3,8 +3,13 @@ from django.shortcuts import render
|
|||
from .models import Game, Platform, Purchase, Session
|
||||
from .forms import SessionForm, PurchaseForm, GameForm
|
||||
from datetime import datetime
|
||||
from django.db.models import ExpressionWrapper, F, DurationField
|
||||
import logging
|
||||
def model_counts(request):
|
||||
return {
|
||||
"game_available": Game.objects.count() != 0,
|
||||
"platform_available": Platform.objects.count() != 0,
|
||||
"purchase_available": Purchase.objects.count() != 0,
|
||||
"session_count": Session.objects.count(),
|
||||
}
|
||||
|
||||
|
||||
def add_session(request):
|
||||
|
|
|
@ -65,6 +65,7 @@ TEMPLATES = [
|
|||
"django.template.context_processors.request",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
"tracker.views.model_counts",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue