Graphs and tables for your Spotify account.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.6 KiB

  1. # imports {{{ #
  2. import math
  3. import random
  4. import requests
  5. import os
  6. import urllib
  7. import secrets
  8. from pprint import pprint
  9. import string
  10. from datetime import datetime
  11. from django.shortcuts import render, redirect
  12. from .utils import *
  13. from django_tables2 import RequestConfig
  14. # }}} imports #
  15. def display_artist_graph(request, user_secret):
  16. """Renders the artist data graph display page
  17. :param request: the HTTP request
  18. :param user_secret: the user secret used for identification
  19. :return: render the artist data graph display page
  20. """
  21. return render(request, "graphs/artist_graph.html",
  22. get_secret_context(user_secret))
  23. def display_genre_graph(request, user_secret):
  24. return render(request, "graphs/genre_graph.html",
  25. get_secret_context(user_secret))
  26. def display_features_graphs(request, user_secret):
  27. """Renders the audio features page
  28. :param request: the HTTP request
  29. :param user_secret: user secret used for identification
  30. :return: renders the audio features page
  31. """
  32. return render(request, "graphs/features_graphs.html",
  33. get_secret_context(user_secret))
  34. def display_history_table(request, user_secret):
  35. """Renders the user history page
  36. :param request: the HTTP request
  37. :param user_secret: user secret used for identification
  38. :return: renders the user history page
  39. """
  40. context = get_secret_context(user_secret)
  41. context.update(get_user_history(user_secret))
  42. RequestConfig(request).configure(context['user_history_table'])
  43. return render(request, "graphs/user_history.html", context)