diff --git a/api/views.py b/api/views.py index 21aa2bd..94d1c13 100644 --- a/api/views.py +++ b/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) diff --git a/graphs/templates/graphs/logged_in.html b/graphs/templates/graphs/logged_in.html index d553f92..a804be1 100644 --- a/graphs/templates/graphs/logged_in.html +++ b/graphs/templates/graphs/logged_in.html @@ -16,5 +16,8 @@ Artists + + History + diff --git a/graphs/templates/graphs/user_history.html b/graphs/templates/graphs/user_history.html new file mode 100644 index 0000000..f07e954 --- /dev/null +++ b/graphs/templates/graphs/user_history.html @@ -0,0 +1,13 @@ + +{% load static %} + + + + User History + + + + +

Your Listening History

+ + diff --git a/graphs/urls.py b/graphs/urls.py index e1bf0b2..3d9c0c8 100644 --- a/graphs/urls.py +++ b/graphs/urls.py @@ -10,4 +10,6 @@ urlpatterns = [ name='display_genre_graph'), path('audio_features/', display_features_graphs, name='display_audio_features'), + path('history/', display_history_table, + name='display_history_table'), ] diff --git a/graphs/utils.py b/graphs/utils.py index d2cf67c..e866585 100644 --- a/graphs/utils.py +++ b/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 + diff --git a/graphs/views.py b/graphs/views.py index 25c8177..f4d6b44 100644 --- a/graphs/views.py +++ b/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)) +