Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ def index():

@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)
matching_clubs = [c for c in clubs if c['email'] == request.form['email']]
if not matching_clubs:
flash("Sorry, that email was not found.")
return redirect(url_for('index'))
club = matching_clubs[0]
return render_template('welcome.html', club=club, competitions=competitions)


@app.route('/book/<competition>/<club>')
Expand Down
9 changes: 9 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
<title>GUDLFT Registration</title>
</head>
<body>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
<h1>Welcome to the GUDLFT Registration Portal!</h1>
Please enter your secretary email to continue:
<form action="showSummary" method="post">
Expand Down
19 changes: 19 additions & 0 deletions tests/integration/test_login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def test_login_with_valid_email_shows_summary(client):
"""Happy path : un email connu doit afficher la page de résumé."""
response = client.post(
"/showSummary",
data={"email": "john@simplylift.co"},
)
assert response.status_code == 200
assert b"john@simplylift.co" in response.data


def test_login_with_unknown_email_does_not_crash(client):
"""Sad path (bug #1) : un email inconnu ne doit pas faire planter l'appli."""
response = client.post(
"/showSummary",
data={"email": "inconnu@test.com"},
follow_redirects=True,
)
assert response.status_code == 200
assert b"Sorry, that email was not found." in response.data