diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7499672..1ac4a6f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,3 +2,4 @@
* Hide navigation bar items if there are no games/purchases/sessions
* Set default version to "git-main" to indicate development environment
* Add homepage, link to it from the logo
+* Make it possible to add a new platform
diff --git a/src/web/tracker/forms.py b/src/web/tracker/forms.py
index ad35efd..13f0165 100644
--- a/src/web/tracker/forms.py
+++ b/src/web/tracker/forms.py
@@ -1,5 +1,5 @@
from django import forms
-from .models import Session, Purchase, Game
+from .models import Session, Purchase, Game, Platform
class SessionForm(forms.ModelForm):
@@ -24,3 +24,9 @@ class GameForm(forms.ModelForm):
class Meta:
model = Game
fields = ["name", "wikidata"]
+
+
+class PlatformForm(forms.ModelForm):
+ class Meta:
+ model = Platform
+ fields = ["name", "group"]
diff --git a/src/web/tracker/templates/base.html b/src/web/tracker/templates/base.html
index 495b840..dcd7d4a 100644
--- a/src/web/tracker/templates/base.html
+++ b/src/web/tracker/templates/base.html
@@ -23,6 +23,7 @@
- New Game
+ - New Platform
{% if game_available and platform_available %}
- New Purchase
{% endif %}
diff --git a/src/web/tracker/urls.py b/src/web/tracker/urls.py
index 73fcb69..1fb56e8 100644
--- a/src/web/tracker/urls.py
+++ b/src/web/tracker/urls.py
@@ -5,6 +5,7 @@ from . import views
urlpatterns = [
path("", views.index, name="index"),
path("add-game/", views.add_game, name="add_game"),
+ path("add-platform/", views.add_platform, name="add_platform"),
path("add-session/", views.add_session, name="add_session"),
path("add-purchase/", views.add_purchase, name="add_purchase"),
path("list-sessions/", views.list_sessions, name="list_sessions"),
diff --git a/src/web/tracker/views.py b/src/web/tracker/views.py
index 8c20b94..8ea4e86 100644
--- a/src/web/tracker/views.py
+++ b/src/web/tracker/views.py
@@ -1,7 +1,7 @@
from django.shortcuts import render
from .models import Game, Platform, Purchase, Session
-from .forms import SessionForm, PurchaseForm, GameForm
+from .forms import SessionForm, PurchaseForm, GameForm, PlatformForm
from datetime import datetime
def model_counts(request):
return {
@@ -66,6 +66,18 @@ def add_game(request):
context["title"] = "Add New Game"
return render(request, "add.html", context)
+
+def add_platform(request):
+ context = {}
+ form = PlatformForm(request.POST or None)
+ if form.is_valid():
+ form.save()
+
+ context["form"] = form
+ context["title"] = "Add New Platform"
+ return render(request, "add.html", context)
+
+
def index(request):
context = {}
return render(request, "index.html", context)