From a5a52370b2194c7a9c895a1d93dc256da12e8e5f Mon Sep 17 00:00:00 2001 From: Faaab84 Date: Sat, 22 Nov 2025 15:10:33 +0100 Subject: [PATCH 1/4] bug fix #1 --- .gitignore | 4 +- .idea/.gitignore | 8 ++ .idea/Python_Testing.iml | 19 +++++ .idea/inspectionProfiles/Project_Default.xml | 81 +++++++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ server.py | 18 ++++- templates/index.html | 12 ++- 9 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/Python_Testing.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 2cba99d87..3752854ab 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ lib .Python tests/ .envrc -__pycache__ \ No newline at end of file +__pycache__ +.git +.env \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..13566b81b --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/Python_Testing.iml b/.idea/Python_Testing.iml new file mode 100644 index 000000000..a4e902427 --- /dev/null +++ b/.idea/Python_Testing.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 000000000..2930eb9d5 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,81 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 000000000..105ce2da2 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..814b4845e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..94a25f7f4 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/server.py b/server.py index 4084baeac..95b8359e9 100644 --- a/server.py +++ b/server.py @@ -17,6 +17,10 @@ def loadCompetitions(): app = Flask(__name__) app.secret_key = 'something_special' + +if __name__ == '__main__': + app.run(debug=True) + competitions = loadCompetitions() clubs = loadClubs() @@ -24,10 +28,18 @@ def loadCompetitions(): def index(): return render_template('index.html') -@app.route('/showSummary',methods=['POST']) +@app.route('/showSummary', methods=['POST']) def showSummary(): - club = [club for club in clubs if club['email'] == request.form['email']][0] - return render_template('welcome.html',club=club,competitions=competitions) + email = request.form['email'] + club_trouve = None + for club in clubs: + if club['email'] == email: + club_trouve = club + break + if club_trouve is None: + flash("Sorry, the email is not registered in the database") + return redirect(url_for('index')) + return render_template('welcome.html', club=club_trouve, competitions=competitions) @app.route('/book//') diff --git a/templates/index.html b/templates/index.html index 926526b7d..4e97d083c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -12,5 +12,15 @@

Welcome to the GUDLFT Registration Portal!

+ + {% with messages = get_flashed_messages() %} + {% if messages %} +
    + {% for message in messages %} +
  • {{ message }}
  • + {% endfor %} +
+ {% endif %} + {% endwith %} - \ No newline at end of file + From 95514f4339e5861358c6ad14339e82bf55f30b63 Mon Sep 17 00:00:00 2001 From: Faaab84 Date: Sat, 22 Nov 2025 15:10:59 +0100 Subject: [PATCH 2/4] bug fix #1 --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3752854ab..3eba1239e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ tests/ .envrc __pycache__ .git -.env \ No newline at end of file +.env +.idea From 72a470f518a7c677fb11fd517ecb490dde9a0334 Mon Sep 17 00:00:00 2001 From: Faaab84 Date: Sat, 22 Nov 2025 15:24:45 +0100 Subject: [PATCH 3/4] fix #1 add test --- .gitignore | 1 - tests/__init__.py | 0 tests/integration/test_email_integration.py | 43 +++++++++++++++++++++ tests/unit/test_email_logic.py | 30 ++++++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 tests/__init__.py create mode 100644 tests/integration/test_email_integration.py create mode 100644 tests/unit/test_email_logic.py diff --git a/.gitignore b/.gitignore index 3eba1239e..3505a1411 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ bin include lib .Python -tests/ .envrc __pycache__ .git diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/integration/test_email_integration.py b/tests/integration/test_email_integration.py new file mode 100644 index 000000000..ffa57a1c7 --- /dev/null +++ b/tests/integration/test_email_integration.py @@ -0,0 +1,43 @@ +import os +import sys +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) +from server import app +import pytest + + +@pytest.fixture +def client(): + app.config['TESTING'] = True + with app.test_client() as client: + yield client + + +def test_email_invalide(client): + response = client.post( + '/showSummary', + data={'email': 'fabien@test.com'}, + follow_redirects=True + ) + assert response.status_code == 200 + + page = response.data.decode('utf-8') + + assert "Sorry" in page + assert "the email is not registered in the database" in page + + print("[ERREUR] Email invalide → message bien affiché") + + +def test_email_valide(client): + response = client.post( + '/showSummary', + data={'email': 'admin@irontemple.com'}, + follow_redirects=True + ) + assert response.status_code == 200 + + page = response.data.decode('utf-8') + assert "Welcome, admin@irontemple.com" in page + assert "Désolé" not in page + + print("[SUCCÈS] Email valide → connexion OK") diff --git a/tests/unit/test_email_logic.py b/tests/unit/test_email_logic.py new file mode 100644 index 000000000..0e83d32a1 --- /dev/null +++ b/tests/unit/test_email_logic.py @@ -0,0 +1,30 @@ +import pytest + +CLUBS = [ + {"name": "Iron Temple", "email": "admin@irontemple.com", "points": "4"}, + {"name": "Simply Lift", "email": "john@simplylift.co", "points": "13"} +] + + +def rechercher_email(email): + for club in CLUBS: + if club['email'] == email: + return club + return None + + +def test_email_pas_trouve(): + result = rechercher_email("fabien@faux.com") + assert result is None + print("[ERREUR] Email invalide") + + +def test_email_trouve(): + result = rechercher_email("admin@irontemple.com") + assert result is not None + assert result["name"] == "Iron Temple" + print("[SUCCÈS] Email valide") + + + + From f24aed80bc39737fc6f9508111baf2f6e3a651d9 Mon Sep 17 00:00:00 2001 From: Faaab84 Date: Sat, 22 Nov 2025 15:25:32 +0100 Subject: [PATCH 4/4] Remove .idea folder from repository and improve gitignore --- .idea/.gitignore | 8 -- .idea/Python_Testing.iml | 19 ----- .idea/inspectionProfiles/Project_Default.xml | 81 ------------------- .../inspectionProfiles/profiles_settings.xml | 6 -- .idea/modules.xml | 8 -- .idea/vcs.xml | 6 -- 6 files changed, 128 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/Python_Testing.iml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b81b..000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/Python_Testing.iml b/.idea/Python_Testing.iml deleted file mode 100644 index a4e902427..000000000 --- a/.idea/Python_Testing.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 2930eb9d5..000000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2da2..000000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 814b4845e..000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f4..000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file