diff --git a/conftest.py b/conftest.py index 75303c3..6dda5b9 100644 --- a/conftest.py +++ b/conftest.py @@ -4,6 +4,9 @@ from notification.models import Notification, NotificationType from django.utils import timezone from decimal import Decimal +from player_rating.models import PlayerRating +from game_event.models import GameEvent +from game_event_player.models import GameEventPlayer import pytest @@ -17,6 +20,11 @@ def player(): return player +@pytest.fixture +def player_rating(player): + return PlayerRating.objects.create(ball_game="Basketball", player=player, rating=5) + + @pytest.fixture def court(): court = Court.objects.create(x=Decimal('11'), y=Decimal('22'), @@ -39,3 +47,19 @@ def notification(player): notification_type=NotificationType.WEBSITE, is_read=False ) + + +@pytest.fixture +def game_event(court, court_ball_game): + return GameEvent.objects.create( + id=20, + time=timezone.now(), + level_of_game=5, + min_number_of_players=3, + max_number_of_players=5, + court=court, ball_game="Basketball") + + +@pytest.fixture +def game_event_player(game_event, player): + return GameEventPlayer.objects.create(game_event=game_event, player=player, ball_responsible=False) diff --git a/meet_balls_app/templates/base.html b/meet_balls_app/templates/base.html index ef1edd6..a5eab2d 100644 --- a/meet_balls_app/templates/base.html +++ b/meet_balls_app/templates/base.html @@ -10,6 +10,7 @@ rel="stylesheet" /> + {% block scripts %} {% endblock %} @@ -40,6 +41,9 @@ About {% if user.is_authenticated %} + diff --git a/meet_balls_app/templates/meet_balls_app/edit_profile_form.html b/meet_balls_app/templates/meet_balls_app/edit_profile_form.html new file mode 100644 index 0000000..b98820d --- /dev/null +++ b/meet_balls_app/templates/meet_balls_app/edit_profile_form.html @@ -0,0 +1,50 @@ +{% extends 'base.html' %} + +{% block content %} +
+ +

Edit Player Profile

+
+ {% csrf_token %} + +
+ + +
+ +
+ + +
+ +

Player Ratings

+ {% for rating in ratings %} +
+ + +
+ {% endfor %} + + +
+ + {% if messages %} +
+
+ +
+
+{% endif %} +
+ +{% endblock %} diff --git a/meet_balls_app/templates/meet_balls_app/profile.html b/meet_balls_app/templates/meet_balls_app/profile.html new file mode 100644 index 0000000..f65d79b --- /dev/null +++ b/meet_balls_app/templates/meet_balls_app/profile.html @@ -0,0 +1,105 @@ +{% extends 'base.html' %} {% block content %} +{% if player %} +
+

Profile Information

+

Name: {{ player.user.first_name }} {{ player.user.last_name }}

+

Date of Birth: {{ player.birth_date }}

+

Favorite Ball Game: {{ player.favorite_ball_game }}

+
+

Player Ratings

+
+
+
+ + + + + + + + + {% for rating in ratings %} + + + + + {% endfor %} + +
Ball GameRating
{{ rating.ball_game }}{{ rating.rating }}
+
+
+
+ +
+ {% if user.id|stringformat:"s" == url_id %} +
+ +
+ {% endif %} +
+ +

Game History

+
+ +
+ {% block scripts %} + + +{% endblock %} +{% else %} +
+

Player Not Found

+

The requested player does not exist.

+
+ {% endif %} +{% endblock %} diff --git a/meet_balls_app/tests.py b/meet_balls_app/tests.py index e59bff9..6288971 100644 --- a/meet_balls_app/tests.py +++ b/meet_balls_app/tests.py @@ -3,6 +3,7 @@ import pytest from django.urls import reverse from django.utils import timezone +from player.models import BallGame class TestUi: @@ -195,3 +196,84 @@ def test_login_page_navigation(self, client): response = client.get(login_url) assert response.status_code == 200 assert response.request['PATH_INFO'] == '/login/' + + +@pytest.mark.django_db +class TestProfile: + + def test_profile_view(self, client, player, player_rating, court, court_ball_game, game_event, game_event_player): + url = reverse('profile', kwargs={'id': player.user.id}) + client.force_login(player.user) + response = client.get(url) + assert response.status_code == 200 + assert player.user.username in response.content.decode() + assert player.favorite_ball_game in response.content.decode() + assert '' + str(player_rating.rating) + '' in response.content.decode() + assert '' + str(game_event.ball_game) + '' in response.content.decode() + assert b'