Skip to content

Commit acf85f6

Browse files
Merge pull request #6 from githubstevemas/enhancement/display-full-booked-message
Display when competition is full
2 parents e350c66 + 59d2611 commit acf85f6

File tree

4 files changed

+46
-15
lines changed

4 files changed

+46
-15
lines changed

templates/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ <h1>Welcome to the GUDLFT Registration Portal!</h1>
1414
<input type="email" name="email" id=""/>
1515
<button type="submit">Enter</button>
1616
</form>
17-
17+
1818
{% with messages = get_flashed_messages()%}
1919
{% if messages %}
2020
{% for message in messages %}
2121
{{message}}
2222
{% endfor %}
2323
{% endif %}
2424
{% endwith %}
25+
2526
</body>
2627
</html>

templates/welcome.html

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,32 @@
77
<body>
88
<h2>Welcome, {{club['email']}} </h2><a href="{{url_for('logout')}}">Logout</a>
99

10-
{% with messages = get_flashed_messages()%}
10+
{% with messages = get_flashed_messages() %}
1111
{% if messages %}
1212
<ul>
1313
{% for message in messages %}
1414
<li>{{message}}</li>
1515
{% endfor %}
1616
</ul>
1717
{% endif%}
18-
Points available: {{club['points']}}
18+
Points available: {{ club['points'] }}
1919
<h3>Competitions:</h3>
2020
<ul>
21-
{% for comp in competitions%}
21+
{% for comp in competitions %}
2222
<li>
23-
{{comp['name']}}<br />
24-
Date: {{comp['date']}}</br>
25-
Number of Places: {{comp['numberOfPlaces']}}
26-
{%if comp['numberOfPlaces']|int >0%}
27-
<a href="{{ url_for('book',competition=comp['name'],club=club['name']) }}">Book Places</a>
28-
{%endif%}
23+
<p>{{ comp['name'] }}</p>
24+
<p>Date: {{ comp['date'] }}</p>
25+
<p>Number of Places: {{ comp['numberOfPlaces'] }}</p>
26+
{% if comp['numberOfPlaces']|int >0 %}
27+
<a href="{{ url_for('book',competition=comp['name'],club=club['name']) }}">Book Places</a>
28+
{% else %}
29+
<span>- Competition complete</span>
30+
{% endif %}
2931
</li>
30-
<hr />
32+
<hr>
3133
{% endfor %}
3234
</ul>
33-
{%endwith%}
35+
{% endwith %}
3436

3537
</body>
3638
</html>

tests/conftest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import copy
21
import pytest
32
import json
43

5-
from server import app
4+
from server import app, competitions
65

76

87
@pytest.fixture
@@ -22,3 +21,12 @@ def test_clubs():
2221
def test_competitions():
2322
with open('competitions.json') as comps:
2423
return json.load(comps)['competitions']
24+
25+
26+
@pytest.fixture
27+
def test_competition_full():
28+
competitions[:] = [
29+
{'name': 'Spring Festival',
30+
'date': '2020-03-27 10:00:00',
31+
'numberOfPlaces': '0'}
32+
]

tests/test_server.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def test_has_sufficient_points(client):
5252

5353

5454
def test_update_points_after_purchase(client, test_clubs, test_competitions, mocker):
55-
5655
mocker.patch('server.loadClubs', return_value=test_clubs)
5756
mocker.patch('server.loadCompetitions', return_value=test_competitions)
5857
mock_save_club = mocker.patch('server.saveClub')
@@ -87,3 +86,24 @@ def test_wrong_login(client):
8786
})
8887
assert response.status_code == 200
8988
assert b'Wrong email-please try again' in response.data
89+
90+
91+
def test_display_book_available(client):
92+
test_club = loadClubs()[0]
93+
test_competitions = loadCompetitions()
94+
95+
response = client.post('/showSummary', data={'email': test_club['email']})
96+
97+
assert response.status_code == 200
98+
assert b'Number of Places: 25' in response.data
99+
100+
101+
def test_display_book_non_available(client, test_competition_full):
102+
103+
test_club = loadClubs()[0]
104+
105+
response = client.post('/showSummary', data={'email': test_club['email']})
106+
107+
assert response.status_code == 200
108+
assert b'Spring Festival' in response.data
109+
assert b'- Competition complete' in response.data

0 commit comments

Comments
 (0)