Compare commits
No commits in common. "bug/issue2" and "main" have entirely different histories.
bug/issue2
...
main
21
server.py
21
server.py
@ -26,11 +26,9 @@ def index():
|
|||||||
|
|
||||||
@app.route('/showSummary',methods=['POST'])
|
@app.route('/showSummary',methods=['POST'])
|
||||||
def showSummary():
|
def showSummary():
|
||||||
club = [club for club in clubs if club['email'] == request.form['email']]
|
club = [club for club in clubs if club['email'] == request.form['email']][0]
|
||||||
if club:
|
return render_template('welcome.html',club=club,competitions=competitions)
|
||||||
return render_template('welcome.html', club=club[0], competitions=competitions)
|
|
||||||
flash("Sorry, that email wasn't found")
|
|
||||||
return redirect(url_for('index'))
|
|
||||||
|
|
||||||
@app.route('/book/<competition>/<club>')
|
@app.route('/book/<competition>/<club>')
|
||||||
def book(competition,club):
|
def book(competition,club):
|
||||||
@ -48,21 +46,14 @@ def purchasePlaces():
|
|||||||
competition = [c for c in competitions if c['name'] == request.form['competition']][0]
|
competition = [c for c in competitions if c['name'] == request.form['competition']][0]
|
||||||
club = [c for c in clubs if c['name'] == request.form['club']][0]
|
club = [c for c in clubs if c['name'] == request.form['club']][0]
|
||||||
placesRequired = int(request.form['places'])
|
placesRequired = int(request.form['places'])
|
||||||
points = int(club['points'])
|
competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired
|
||||||
if placesRequired <= points:
|
flash('Great-booking complete!')
|
||||||
competition['numberOfPlaces'] = int(competition['numberOfPlaces']) - placesRequired
|
|
||||||
if competition['numberOfPlaces'] < 0:
|
|
||||||
competition['numberOfPlaces'] = 0
|
|
||||||
flash("Great-booking complete!")
|
|
||||||
else:
|
|
||||||
flash("You don't have enough points")
|
|
||||||
return render_template('welcome.html', club=club, competitions=competitions)
|
return render_template('welcome.html', club=club, competitions=competitions)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: Add route for points display
|
# TODO: Add route for points display
|
||||||
|
|
||||||
|
|
||||||
@app.route('/logout')
|
@app.route('/logout')
|
||||||
def logout():
|
def logout():
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
@ -6,16 +6,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Welcome to the GUDLFT Registration Portal!</h1>
|
<h1>Welcome to the GUDLFT Registration Portal!</h1>
|
||||||
{% with messages = get_flashed_messages()%}
|
|
||||||
{% if messages %}
|
|
||||||
<ul>
|
|
||||||
{% for message in messages %}
|
|
||||||
<li>{{message}}</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif%}
|
|
||||||
{% endwith %}
|
|
||||||
|
|
||||||
Please enter your secretary email to continue:
|
Please enter your secretary email to continue:
|
||||||
<form action="showSummary" method="post">
|
<form action="showSummary" method="post">
|
||||||
<label for="email">Email:</label>
|
<label for="email">Email:</label>
|
||||||
@ -23,4 +13,4 @@
|
|||||||
<button type="submit">Enter</button>
|
<button type="submit">Enter</button>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -5,7 +5,7 @@
|
|||||||
<title>Summary | GUDLFT Registration</title>
|
<title>Summary | GUDLFT Registration</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h2>Welcome, {{club['email']}}</h2><a href="{{url_for('logout')}}">Logout</a>
|
<h2>Welcome, {{club['email']}} </h2><a href="{{url_for('logout')}}">Logout</a>
|
||||||
|
|
||||||
{% with messages = get_flashed_messages()%}
|
{% with messages = get_flashed_messages()%}
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
@ -15,7 +15,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif%}
|
{% endif%}
|
||||||
<b id="points">Points available: </b><span>{{club['points']}}</span>
|
Points available: {{club['points']}}
|
||||||
<h3>Competitions:</h3>
|
<h3>Competitions:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{% for comp in competitions%}
|
{% for comp in competitions%}
|
||||||
@ -33,4 +33,4 @@
|
|||||||
{%endwith%}
|
{%endwith%}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -1,28 +0,0 @@
|
|||||||
import pytest
|
|
||||||
from server import app
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
|
|
||||||
|
|
||||||
EMAIL1 = "admin@irontemple.com"
|
|
||||||
EMAIL2 = "john@simplylift.co"
|
|
||||||
@pytest.fixture
|
|
||||||
def club1():
|
|
||||||
data = {"competition": "Spring Festival", "club": "Iron Temple"}
|
|
||||||
return data
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def club2():
|
|
||||||
data = {"competition": "Fall Classic", "club": "Iron Temple"}
|
|
||||||
return data
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def client():
|
|
||||||
with app.test_client() as client:
|
|
||||||
yield client
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def connect(client):
|
|
||||||
response = client.post('/showSummary', data={"email": EMAIL1})
|
|
||||||
soup = BeautifulSoup(response.data, 'html.parser')
|
|
||||||
return soup
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
|||||||
from flask import session
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
|
|
||||||
|
|
||||||
def test_should_status_code_ok(client):
|
|
||||||
response = client.get('/')
|
|
||||||
assert response.status_code == 200
|
|
||||||
|
|
||||||
|
|
||||||
def test_should_display_sorry_with_unknown_email(client):
|
|
||||||
email = "test@test.com"
|
|
||||||
response = client.post('/showSummary', data={"email": email})
|
|
||||||
print(session)
|
|
||||||
assert "_flashes" in session
|
|
||||||
assert session["_flashes"] == [("message", "Sorry, that email wasn't found")]
|
|
||||||
|
|
||||||
|
|
||||||
def test_shoul_display_page_on_known_email(client):
|
|
||||||
email = "admin@irontemple.com"
|
|
||||||
response = client.post('/showSummary', data={"email": email})
|
|
||||||
print(session)
|
|
||||||
soup = BeautifulSoup(response.data, 'html.parser')
|
|
||||||
assert soup.h2.text == "Welcome, "+email
|
|
||||||
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
|||||||
from bs4 import BeautifulSoup
|
|
||||||
from flask import session
|
|
||||||
|
|
||||||
|
|
||||||
class TestPoints:
|
|
||||||
|
|
||||||
def test_should_nok_when_too_much_points(self, client, connect, club1):
|
|
||||||
points = int(connect.span.text)
|
|
||||||
club1.update({"places": points+1})
|
|
||||||
response = client.post('/purchasePlaces', data=club1)
|
|
||||||
soup = BeautifulSoup(response.data, "html.parser")
|
|
||||||
assert "You don't have enough points" == soup.li.text
|
|
||||||
|
|
||||||
def test_should_ok_when_enough_points(self, client, connect, club1):
|
|
||||||
points = int(connect.span.text)
|
|
||||||
data = club1.update({"places": points-1})
|
|
||||||
response = client.post('/purchasePlaces', data=club1)
|
|
||||||
soup = BeautifulSoup(response.data, "html.parser")
|
|
||||||
assert "Great-booking complete!" == soup.li.text
|
|
Loading…
x
Reference in New Issue
Block a user