diff --git a/.env b/.env index c092b44..41d604b 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ # Django settings SECRET_KEY="FollowTheWhiteRabbit" DEBUG=True -DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1] +DJANGO_ALLOWED_HOSTS=['*'] # PostgreSQL settings POSTGRES_DB=players_db diff --git a/.gitignore b/.gitignore index 3adaaf8..6ccca4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ venv/ __pycache__/ data/ +.env +makefile \ No newline at end of file diff --git a/pong/static/game.js b/pong/static/game.js index cbfb198..eacd1db 100644 --- a/pong/static/game.js +++ b/pong/static/game.js @@ -30,86 +30,6 @@ document.addEventListener('DOMContentLoaded', () => { registerButton.addEventListener('click', handleRegister); loginButton.addEventListener('click', handleLogin); - - /// THEOUCHE NOT CERTAIN /// - async function createPlayer(name, totalMatch = 0, totalWin = 0, pWin = null, mScoreMatch = null, mScoreAdvMatch = null, bestScore = 0, mNbrBallTouch = null, totalDuration = null, mDuration = null, numParticipatedTournaments = 0, numWonTournaments = 0) { - try { - const response = await fetch('/api/create_player/', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - name, - total_match: totalMatch, - total_win: totalWin, - p_win: pWin, - m_score_match: mScoreMatch, - m_score_adv_match: mScoreAdvMatch, - best_score: bestScore, - m_nbr_ball_touch: mNbrBallTouch, - total_duration: totalDuration, - m_duration: mDuration, - num_participated_tournaments: numParticipatedTournaments, - num_won_tournaments: numWonTournaments - }) - }); - - if (!response.ok) { - const errorData = await response.json(); - throw new Error(errorData.error || 'Network response was not ok'); - } - - const data = await response.json(); - return data; - - } catch (error) { - // Afficher l'erreur avec un message plus spécifique - console.error('Error creating player:', error.message); - alert(`Failed to create player: ${error.message}`); - } - } - - async function createTournoi(name, nbr_player, date, winner_id) { - try { - const response = await fetch('/api/create_tournoi/', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ name, nbr_player, date, winner_id }) - }); - if (!response.ok) { - throw new Error('Network response was not ok'); - } - const data = await response.json(); - return data; - } catch (error) { - console.error('Error creating tournoi:', error); - } - } - - async function createMatch(player1_id, player2_id, score_player1, score_player2, nbr_ball_touch_p1, nbr_ball_touch_p2, duration, is_tournoi, tournoi_id) { - try { - const response = await fetch('/api/create_match/', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ player1_id, player2_id, score_player1, score_player2, nbr_ball_touch_p1, nbr_ball_touch_p2, duration, is_tournoi, tournoi_id }) - }); - if (!response.ok) { - throw new Error('Network response was not ok'); - } - const data = await response.json(); - return data; - } catch (error) { - console.error('Error creating match:', error); - } - } - - /// THEOUCHE NOT CERTAIN /// - async function handleCheckNickname() { const nickname = nicknameInput.value.trim(); if (nickname) { @@ -172,7 +92,6 @@ document.addEventListener('DOMContentLoaded', () => { try { const result = await registerUser(nickname, password); if (result) { - //await createPlayer(nickname); registerForm.style.display = 'none'; gameContainer.style.display = 'flex'; formBlock.style.display = 'none';