Merge branch 'main' of github.com:Kum1ta/PTME_Transcendence

This commit is contained in:
Misthaa
2024-10-01 02:35:17 +02:00
13 changed files with 115 additions and 29 deletions

View File

@ -6,7 +6,7 @@
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/09/13 16:20:58 by tomoron #+# #+# #
# Updated: 2024/09/30 19:55:24 by tomoron ### ########.fr #
# Updated: 2024/10/01 00:46:17 by tomoron ### ########.fr #
# #
# **************************************************************************** #
@ -461,7 +461,7 @@ class Game:
def saveResults(self):
try:
if(self.winner == None):
print("unkown winner, settings to 1")
print("unkown winner, setting to 1")
self.winner = 1
print("saving results")
p1DbUser = User.objects.get(id=self.p1.id)

View File

@ -0,0 +1,11 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# __init__.py :+: :+: :+: #
# +:+ +:+ +:+ #
# By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/10/01 00:41:32 by tomoron #+# #+# #
# Updated: 2024/10/01 01:05:30 by tomoron ### ########.fr #
# #
# **************************************************************************** #

View File

@ -13,11 +13,27 @@ from channels.routing import ProtocolTypeRouter, URLRouter
from django.urls import path
from django.core.asgi import get_asgi_application
from channels.sessions import SessionMiddlewareStack
from django.utils import timezone
from datetime import timedelta
from django.db import transaction
import threading
import time
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
from .websocket import WebsocketHandler
def deleteLoop():
while(True):
from .models import User
time.sleep(60 * 60)
limit = timezone.now() - timedelta(days=2 * 365)
with transaction.atomic():
User.objects.using('second').filter(last_login__lt=limit).delete()
threading.Thread(target=deleteLoop, daemon=True).start()
django = get_asgi_application()
application = ProtocolTypeRouter({

View File

@ -81,6 +81,14 @@ DATABASES = {
"NAME":"VAR_DB_NAME",
"USER":"VAR_DB_USERNAME",
"PASSWORD":"VAR_DB_PASSWORD"
},
"second": {
"ENGINE": "django.db.backends.postgresql",
"HOST":"VAR_DB_HOST",
"PORT":5432,
"NAME":"VAR_DB_NAME",
"USER":"VAR_DB_USERNAME",
"PASSWORD":"VAR_DB_PASSWORD"
}
}
@ -132,7 +140,7 @@ STATIC_ROOT = BASE_DIR / 'staticfiles'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
ASGI_APPLICATION = 'server.asgi.applicatio'
ASGI_APPLICATION = 'server.asgi.application'
SESSION_SAVE_EVERY_REQUEST = True
SESSION_COOKIE_NAME = 'sessionid'
SESSION_COOKIE_SECURE = False

View File

@ -91,10 +91,10 @@
</div>
<div class="skin-select">
<div id="bar">
<div class="barSelection" id="bar">
</div>
<div id="goal">
<div class="goalSelection" id="goal">
</div>
</div>
@ -102,23 +102,38 @@
<div class="menuSelected" id="rankedSelected">
<div id="whatGame">
<p>Bonsoir non ?</p>
<p>AAAAAAAAAA</p>
<span class="line"></span>
<p>BBBBBBBBBB</p>
</div>
<div class="skin-select">
<!-- Make sure you have ids and classes to make multiple "bars" and "goals" -->
<div class="barSelection" id="bar1">
</div>
<div class="goalSelection" id="goal1">
</div>
</div>
</div>
<div class="menuSelected" id="tournamentSelected">
<div id="whatGame">
<p>Bonsoir non ?</p>
<p>CCCCCCCCCC</p>
<span class="line"></span>
<p>DDDDDDDDDD</p>
</div>
<div class="skin-select">
<!-- Make sure you have ids and classes to make multiple "bars" and "goals" -->
<div class="barSelection" id="bar2">
</div>
<div class="goalSelection" id="goal2">
</div>
</div>
</div>
<!--------------------- END OF CHANGES --------------------->
</div>
</div>
<div class="bottom">

View File

@ -28,7 +28,7 @@
</div>
</div>
<div class="history" id="history">
<h3>History</h3>
<h3 style="margin-top: 20px;">History</h3>
<div id="scroll-match"></div>
</div>
</div>