Browse Source

Resolves #35

master
Kevin Mok 7 years ago
parent
commit
3aa49cc4e1
  1. 0
      spotifyvis/templates/spotifyvis/genre_graph.html
  2. 8
      spotifyvis/templates/spotifyvis/index.html
  3. 9
      spotifyvis/templates/spotifyvis/logged_in.html
  4. 6
      spotifyvis/urls.py
  5. 2
      spotifyvis/utils.py
  6. 17
      spotifyvis/views.py

0
spotifyvis/templates/spotifyvis/test_db.html → spotifyvis/templates/spotifyvis/genre_graph.html

8
spotifyvis/templates/spotifyvis/index.html

@ -21,13 +21,7 @@
<div id="login"> <div id="login">
<h1>spotify-lib-vis</h1> <h1>spotify-lib-vis</h1>
<a href="/login" class="btn btn-primary">Scan Library</a> <a href="/login" class="btn btn-primary">Scan Library</a>
<a href="/test_db" class="btn btn-primary">Test DB</a>
</div>
<div id="data-container">
<ul id="data-list">
</ul>
<a href="{% url "admin_graphs" %}" class="btn btn-primary">Admin Graphs</a>
</div> </div>
</div> </div>

9
spotifyvis/templates/spotifyvis/logged_in.html

@ -5,8 +5,13 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Logged In</title> <title>Logged In</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="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'spotifyvis/css/dark_bg.css' %}">
</head> </head>
<body> <body>
<a class="btn btn-primary" href="/audio_features/{{ user_secret }}" role="button">Audio Features</a>
<h1>{{ user_id }}'s Graphs</h1>
<a class="btn btn-primary" href="/audio_features/{{ user_secret }}"
role="button">Audio Features</a>
<a class="btn btn-primary" href="{% url "display_genre_graph" user_secret %}"
role="button">Genres</a>
</body> </body>
</html>
</html>

6
spotifyvis/urls.py

@ -8,9 +8,11 @@ urlpatterns = [
path('login', login, name='login'), path('login', login, name='login'),
path('callback', callback, name='callback'), path('callback', callback, name='callback'),
path('user_data', user_data, name='user_data'), path('user_data', user_data, name='user_data'),
path('test_db', test_db, name='test_db'),
path('admin_graphs', admin_graphs, name='admin_graphs'),
path('user_artists/<str:user_id>', get_artist_data, name='get_artist_data'), path('user_artists/<str:user_id>', get_artist_data, name='get_artist_data'),
path('user_genres/<str:user_secret>', get_genre_data, name='get_genre_data'),
path('api/user_genres/<str:user_secret>', get_genre_data, name='get_genre_data'),
path('graphs/genre/<str:client_secret>', display_genre_graph,
name='display_genre_graph'),
path('audio_features/<str:client_secret>', audio_features, name='audio_features'), path('audio_features/<str:client_secret>', audio_features, name='audio_features'),
path('audio_features/<str:audio_feature>/<str:client_secret>', path('audio_features/<str:audio_feature>/<str:client_secret>',
get_audio_feature_data, name='get_audio_feature_data'), get_audio_feature_data, name='get_audio_feature_data'),

2
spotifyvis/utils.py

@ -63,7 +63,7 @@ def parse_library(headers, tracks, user):
# }}} add artists # # }}} add artists #
# WIP: get most common genre
# TODO: fix this, don't need any more
top_genre = "" top_genre = ""
track_obj, track_created = save_track_obj(track_dict['track'], track_obj, track_created = save_track_obj(track_dict['track'],
track_artists, top_genre, user) track_artists, top_genre, user)

17
spotifyvis/views.py

@ -161,6 +161,7 @@ def user_data(request):
# }}} create user obj # # }}} create user obj #
context = { context = {
'user_id': user.user_id,
'user_secret': user.user_secret, 'user_secret': user.user_secret,
} }
@ -169,21 +170,18 @@ def user_data(request):
# }}} user_data # # }}} user_data #
# test_db {{{ #
def test_db(request):
def admin_graphs(request):
"""TODO """TODO
""" """
user_id = "polarbier" user_id = "polarbier"
# user_id = "chrisshyi13" # user_id = "chrisshyi13"
user_obj = User.objects.get(user_id=user_id) user_obj = User.objects.get(user_id=user_id)
context = { context = {
'user_id': user_id,
'user_secret': user_obj.user_secret, 'user_secret': user_obj.user_secret,
} }
update_track_genres(user_obj) update_track_genres(user_obj)
return render(request, 'spotifyvis/test_db.html', context)
# }}} test_db #
return render(request, 'spotifyvis/logged_in.html', context)
# get_artist_data {{{ # # get_artist_data {{{ #
@ -199,6 +197,13 @@ def get_artist_data(request, user_secret):
# }}} get_artist_data # # }}} get_artist_data #
def display_genre_graph(request, client_secret):
user = User.objects.get(user_secret=client_secret)
context = {
'user_secret': client_secret,
}
return render(request, "spotifyvis/genre_graph.html", context)
def audio_features(request, client_secret): def audio_features(request, client_secret):
user = User.objects.get(user_secret=client_secret) user = User.objects.get(user_secret=client_secret)
context = { context = {

Loading…
Cancel
Save