From 4816bacbcedcac80cc6a1dd20305b055b423354d Mon Sep 17 00:00:00 2001
From: Neffi42 <114996380+Neffi42@users.noreply.github.com>
Date: Tue, 1 Oct 2024 12:45:15 +0200
Subject: [PATCH 01/46] replace User by get_user_model call in Pong model
---
django/src/games/models.py | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/django/src/games/models.py b/django/src/games/models.py
index a14a46b7..9733eb24 100644
--- a/django/src/games/models.py
+++ b/django/src/games/models.py
@@ -1,13 +1,12 @@
from django.db import models
-from ft_auth.models import User
-
+from django.contrib.auth import get_user_model
class Pong(models.Model):
user1 = models.ForeignKey(
- User, on_delete=models.SET_NULL, null=True, related_name="user1"
+ get_user_model(), on_delete=models.SET_NULL, null=True, related_name="user1"
)
user2 = models.ForeignKey(
- User, on_delete=models.SET_NULL, null=True, related_name="user2"
+ get_user_model(), on_delete=models.SET_NULL, null=True, related_name="user2"
)
score1 = models.PositiveSmallIntegerField()
score2 = models.PositiveSmallIntegerField()
From aa7d0f1430c66a0b3761d5e61f7de1857daa3c23 Mon Sep 17 00:00:00 2001
From: Neffi42 <114996380+Neffi42@users.noreply.github.com>
Date: Tue, 1 Oct 2024 13:18:45 +0200
Subject: [PATCH 02/46] remove join tournament button in pong.html
---
django/src/games/templates/pong.html | 1 -
1 file changed, 1 deletion(-)
diff --git a/django/src/games/templates/pong.html b/django/src/games/templates/pong.html
index 2334fd7e..90a68c4a 100644
--- a/django/src/games/templates/pong.html
+++ b/django/src/games/templates/pong.html
@@ -15,7 +15,6 @@
From 3507789fbac40cdfde1ac19ff12ea6a9884b3658 Mon Sep 17 00:00:00 2001
From: Neffi42 <114996380+Neffi42@users.noreply.github.com>
Date: Tue, 1 Oct 2024 13:19:20 +0200
Subject: [PATCH 03/46] create Tournament page
---
django/src/games/templates/tournament.html | 5 +++++
django/src/pages/templates/extends/base.html | 3 ++-
django/src/pages/urls.py | 1 +
django/src/pages/views.py | 4 ++++
4 files changed, 12 insertions(+), 1 deletion(-)
create mode 100644 django/src/games/templates/tournament.html
diff --git a/django/src/games/templates/tournament.html b/django/src/games/templates/tournament.html
new file mode 100644
index 00000000..3b85eebe
--- /dev/null
+++ b/django/src/games/templates/tournament.html
@@ -0,0 +1,5 @@
+{% extends "./extends/base.html" %}
+
+{% block content %}
+
Tournament
+{% endblock %}
diff --git a/django/src/pages/templates/extends/base.html b/django/src/pages/templates/extends/base.html
index 8f1c05de..6f273ca5 100644
--- a/django/src/pages/templates/extends/base.html
+++ b/django/src/pages/templates/extends/base.html
@@ -38,6 +38,7 @@
Home
{% if user.is_authenticated %}
Pong
+
Tournament
Logout
{% else %}
Login
@@ -69,4 +70,4 @@
document.getElementById("logout-button-navbar")?.addEventListener("click", function (e) {
logout();
})
-
\ No newline at end of file
+
diff --git a/django/src/pages/urls.py b/django/src/pages/urls.py
index afca1a70..8165b4b8 100644
--- a/django/src/pages/urls.py
+++ b/django/src/pages/urls.py
@@ -4,6 +4,7 @@
urlpatterns = [
path('index/', views.index),
path('pong/', views.pong),
+ path('tournament/', views.tournament),
path('login/', views.login),
path('register/', views.register),
path('authorize/', views.authorize),
diff --git a/django/src/pages/views.py b/django/src/pages/views.py
index 2e085598..dd6a8695 100644
--- a/django/src/pages/views.py
+++ b/django/src/pages/views.py
@@ -27,6 +27,10 @@ def index(request):
def pong(request):
return create_response(request, 'pong.html', title="Pong", need_authentication=True)
+@require_GET
+def tournament(request):
+ return create_response(request, 'tournament.html', title="Tournament", need_authentication=True)
+
@require_GET
def login(request: HttpRequest):
if (request.user.is_authenticated):
From 80f00d62e001340bf43563438d8e93cd6520b371 Mon Sep 17 00:00:00 2001
From: Neffi42 <114996380+Neffi42@users.noreply.github.com>
Date: Tue, 1 Oct 2024 13:34:51 +0200
Subject: [PATCH 04/46] create PongTournament model
---
django/src/games/models.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/django/src/games/models.py b/django/src/games/models.py
index 9733eb24..58fedb10 100644
--- a/django/src/games/models.py
+++ b/django/src/games/models.py
@@ -14,3 +14,15 @@ class Pong(models.Model):
def __str__(self):
return f"{self.user1.username} vs {self.user2.username} - {self.score1}:{self.score2}"
+
+class PongTournament(models.Model):
+ name = models.CharField(max_length=255)
+ participants = models.ManyToManyField(get_user_model(), related_name='tournaments')
+ games = models.ManyToManyField(Pong, related_name='tournaments')
+ current_round = models.PositiveSmallIntegerField(default=1)
+ max_rounds = models.PositiveSmallIntegerField()
+ created_at = models.DateTimeField(auto_now_add=True)
+ updated_at = models.DateTimeField(auto_now=True)
+
+ def __str__(self):
+ return f"Tournament: {self.name} (Round {self.current_round}/{self.max_rounds})"
From 8bb6c01ad7b671bd77d8cdd54c94258e7bcf9abf Mon Sep 17 00:00:00 2001
From: Neffi42 <114996380+Neffi42@users.noreply.github.com>
Date: Wed, 2 Oct 2024 15:03:31 +0200
Subject: [PATCH 05/46] create menu.js
---
django/src/games/templates/pong.html | 19 +++----------------
nginx/src/index.html | 1 +
nginx/src/js/menu.js | 16 ++++++++++++++++
3 files changed, 20 insertions(+), 16 deletions(-)
create mode 100644 nginx/src/js/menu.js
diff --git a/django/src/games/templates/pong.html b/django/src/games/templates/pong.html
index 972ae7be..03e7bd90 100644
--- a/django/src/games/templates/pong.html
+++ b/django/src/games/templates/pong.html
@@ -29,23 +29,9 @@
{% endblock %}
diff --git a/nginx/src/index.html b/nginx/src/index.html
index 0263dd7a..b6d87ba7 100644
--- a/nginx/src/index.html
+++ b/nginx/src/index.html
@@ -24,6 +24,7 @@
+