Browse Source

Setup new page for user history

master
Kevin Mok 6 years ago
parent
commit
b4ffddb24d
  1. 8
      api/views.py
  2. 3
      graphs/templates/graphs/logged_in.html
  3. 13
      graphs/templates/graphs/user_history.html
  4. 2
      graphs/urls.py
  5. 12
      graphs/utils.py
  6. 11
      graphs/views.py

8
api/views.py

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

3
graphs/templates/graphs/logged_in.html

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

13
graphs/templates/graphs/user_history.html

@ -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>

2
graphs/urls.py

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

12
graphs/utils.py

@ -6,3 +6,15 @@ def get_secret_context(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

11
graphs/views.py

@ -40,3 +40,14 @@ def display_features_graphs(request, user_secret):
"""
return render(request, "graphs/features_graphs.html",
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))
Loading…
Cancel
Save