diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..81d6b66
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,2 @@
+## Unreleased
+* Hide navigation bar items if there are no games/purchases/sessions
diff --git a/src/web/tracker/templates/base.html b/src/web/tracker/templates/base.html
index 54a855e..31109ca 100644
--- a/src/web/tracker/templates/base.html
+++ b/src/web/tracker/templates/base.html
@@ -23,9 +23,15 @@
- New Game
+ {% if game_available and platform_available %}
- New Purchase
+ {% endif %}
+ {% if purchase_available %}
- New Session
+ {% endif %}
+ {% if session_count > 0 %}
- All Sessions
+ {% endif %}
diff --git a/src/web/tracker/views.py b/src/web/tracker/views.py
index 3a27817..66130cb 100644
--- a/src/web/tracker/views.py
+++ b/src/web/tracker/views.py
@@ -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):
diff --git a/src/web/web/settings.py b/src/web/web/settings.py
index de91566..e5f7e47 100644
--- a/src/web/web/settings.py
+++ b/src/web/web/settings.py
@@ -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",
],
},
},