Setup new page for user history

This commit is contained in:
2018-11-06 12:19:28 -05:00
parent a399960a49
commit b4ffddb24d
6 changed files with 43 additions and 6 deletions

View File

@@ -176,12 +176,8 @@ def parse_history(request, user_secret):
if console_logging: if console_logging:
tracks_processed += 1 tracks_processed += 1
print("Added track #{} for user {}: {} - {}".format( print("Added history track #{}: {}".format(
tracks_processed, tracks_processed, history_obj,))
history_obj.user,
history_obj.timestamp,
history_obj.track,
))
if len(artist_genre_queue) > 0: if len(artist_genre_queue) > 0:
add_artist_genres(user_headers, artist_genre_queue) add_artist_genres(user_headers, artist_genre_queue)

View File

@@ -16,5 +16,8 @@
<a class="btn btn-primary" href="{% url "graphs:display_artist_graph" user_secret %}" role="button"> <a class="btn btn-primary" href="{% url "graphs:display_artist_graph" user_secret %}" role="button">
Artists Artists
</a> </a>
<a class="btn btn-primary" href="{% url "graphs:display_history_table" user_secret %}" role="button">
History
</a>
</body> </body>
</html> </html>

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<meta charset="UTF-8">
<title>User History</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'css/dark_bg.css' %}">
</head>
<body>
<h1>Your Listening History</h1>
</body>
</html>

View File

@@ -10,4 +10,6 @@ urlpatterns = [
name='display_genre_graph'), name='display_genre_graph'),
path('audio_features/<str:user_secret>', display_features_graphs, path('audio_features/<str:user_secret>', display_features_graphs,
name='display_audio_features'), name='display_audio_features'),
path('history/<str:user_secret>', display_history_table,
name='display_history_table'),
] ]

View File

@@ -6,3 +6,15 @@ def get_secret_context(user_secret):
""" """
return { 'user_secret': user_secret, } return { 'user_secret': user_secret, }
def get_user_history(user_secret):
"""Return all stored history for corresponding User to user_secret.
:user_secret: User secret to get history for.
:returns: list of lists of song history plus information.
"""
# TODO: pass back user id as well?
pass

View File

@@ -40,3 +40,14 @@ def display_features_graphs(request, user_secret):
""" """
return render(request, "graphs/features_graphs.html", return render(request, "graphs/features_graphs.html",
get_secret_context(user_secret)) get_secret_context(user_secret))
def display_history_table(request, user_secret):
"""Renders the user history page
:param request: the HTTP request
:param user_secret: user secret used for identification
:return: renders the user history page
"""
return render(request, "graphs/user_history.html",
get_secret_context(user_secret))