-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from Danielsio/profile_page
Add Profile-Page
- Loading branch information
Showing
10 changed files
with
369 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
rel="stylesheet" | ||
/> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
{% block scripts %} {% endblock %} | ||
<link rel="shortcut icon" type="image/x-icon" href="{% static 'images/favicon.ico' %}"> | ||
<link href="/static/css/styles.css" rel="stylesheet" /> | ||
</head> | ||
|
@@ -40,6 +41,9 @@ | |
<a class="nav-link" href="/about">About</a> | ||
</li> | ||
{% if user.is_authenticated %} | ||
<li class="nav-item"> | ||
<a class="nav-link" href="/profile/{{ user.id }}">Profile</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="/logout">Logout</a> | ||
</li> | ||
|
50 changes: 50 additions & 0 deletions
50
meet_balls_app/templates/meet_balls_app/edit_profile_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
<div style="width: 40%; margin: 0 auto;"> | ||
|
||
<h1>Edit Player Profile</h1> | ||
<form method="post"> | ||
{% csrf_token %} | ||
|
||
<div class="form-group"> | ||
<label for="id_birth_date">Birth Date</label> | ||
<input type="date" class="form-control" id="id_birth_date" name="birth_date" value="{{ player.birth_date|date:'Y-m-d' }}"> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="id_favorite_ball_game">Favorite Ball Game</label> | ||
<select class="form-control" id="id_favorite_ball_game" name="favorite_ball_game"> | ||
{% for ball_game in ball_games %} | ||
<option value="{{ ball_game.0 }}" {% if player.favorite_ball_game == ball_game.0 %}selected{% endif %}>{{ ball_game.0 }}</option> | ||
{% endfor %} | ||
</select> | ||
</div> | ||
|
||
<h2>Player Ratings</h2> | ||
{% for rating in ratings %} | ||
<div class="form-group"> | ||
<label for="id_rating_{{ rating.id }}">Rating for {{ rating.ball_game }}</label> | ||
<input type="number" min="0" max="10" class="form-control" id="id_rating_{{ rating.id }}" name="rating[{{ rating.id }}]" value="{{ rating.rating }}" required> | ||
</div> | ||
{% endfor %} | ||
<button onclick="location.href='{% url 'profile' player.user.id %}'" class="round-button mt-3">Cancel</button> | ||
<button type="submit" class="round-button">Save Changes</button> | ||
</form> | ||
|
||
{% if messages %} | ||
<div class="row my-4"> | ||
<div class="col"> | ||
<div class="alert alert-danger" role="alert"> | ||
<ul class="messages"> | ||
{% for message in messages %} | ||
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{% extends 'base.html' %} {% block content %} | ||
{% if player %} | ||
<div class="text-center"> | ||
<h2>Profile Information</h2> | ||
<p>Name: {{ player.user.first_name }} {{ player.user.last_name }}</p> | ||
<p>Date of Birth: {{ player.birth_date }}</p> | ||
<p>Favorite Ball Game: {{ player.favorite_ball_game }}</p> | ||
</div> | ||
<h2 class="text-center">Player Ratings</h2> | ||
<div class="container"> | ||
<div class="row justify-content-center"> | ||
<div class="col-md-5"> | ||
<table class="table table-striped table-bordered"> | ||
<thead class="thead-dark"> | ||
<tr> | ||
<th>Ball Game</th> | ||
<th>Rating</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for rating in ratings %} | ||
<tr> | ||
<td>{{ rating.ball_game }}</td> | ||
<td>{{ rating.rating }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="text-center"> | ||
{% if user.id|stringformat:"s" == url_id %} | ||
<div> | ||
<button onclick="location.href='{% url 'edit profile' %}'" class="round-button">Edit Profile</button> | ||
</div> | ||
{% endif %} | ||
</div> | ||
|
||
<h2 class="text-center">Game History</h2> | ||
<div> | ||
<canvas id="gameHistoryChart"></canvas> | ||
</div> | ||
{% block scripts %} | ||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | ||
<script> | ||
document.addEventListener("DOMContentLoaded", function() { | ||
var gameHistoryData = { | ||
labels: [ | ||
{% for ball_game, count in game_history_data.items %} | ||
"{{ ball_game }}", | ||
{% endfor %} | ||
], | ||
datasets: [{ | ||
data: [ | ||
{% for ball_game, count in game_history_data.items %} | ||
{{ count }}, | ||
{% endfor %} | ||
], | ||
backgroundColor: [ | ||
'rgba(255, 99, 132, 0.6)', | ||
'rgba(54, 162, 235, 0.6)', | ||
'rgba(255, 206, 86, 0.6)', | ||
'rgba(75, 192, 192, 0.6)', | ||
'rgba(153, 102, 255, 0.6)', | ||
'rgba(255, 159, 64, 0.6)', | ||
'rgba(255, 99, 132, 0.6)', | ||
'rgba(54, 162, 235, 0.6)', | ||
], | ||
borderWidth: 1 | ||
}] | ||
}; | ||
|
||
var gameHistoryChart = new Chart(document.getElementById("gameHistoryChart"), { | ||
type: 'pie', | ||
data: gameHistoryData, | ||
options: { | ||
responsive: true, | ||
maintainAspectRatio: false, | ||
plugins: { | ||
legend: { | ||
position: 'bottom', | ||
}, | ||
}, | ||
layout: { | ||
padding: { | ||
left: 0, | ||
right: 0, | ||
top: 20, | ||
bottom: 20, | ||
}, | ||
}, | ||
}, | ||
}); | ||
}); | ||
</script> | ||
{% endblock %} | ||
{% else %} | ||
<div class="text-center"> | ||
<h2>Player Not Found</h2> | ||
<p>The requested player does not exist.</p> | ||
</div> | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.