1
0
mirror of https://github.com/bspeice/Melodia synced 2024-12-26 00:28:13 -05:00

Enable playlist listing, fix various javascript errors

This commit is contained in:
Bradlee Speice 2013-02-05 15:06:31 -05:00
parent 75b678d56c
commit 5c538d395e
4 changed files with 19 additions and 5 deletions

View File

@ -6,8 +6,10 @@ from django.template import RequestContext
from django.shortcuts import render_to_response, redirect from django.shortcuts import render_to_response, redirect
#Melodia-specific utilities #Melodia-specific utilities
from web_utils import json_response as json import web_utils
@login_required @login_required
def main(request): def main(request):
return render_to_response("index", context_instance = RequestContext(request)) return render_to_response("index", context_instance = RequestContext(request,
web_utils.template_resources()
))

View File

@ -74,7 +74,6 @@ List of block elements in this page:
{% endblock %} {% endblock %}
</div> </div>
</div> </div>
</body>
{# General scripts #} {# General scripts #}
{% block scripts %} {% block scripts %}
@ -94,4 +93,6 @@ List of block elements in this page:
{% endblock %} {% endblock %}
</script> </script>
{% endblock %}{# endblock scripts #} {% endblock %}{# endblock scripts #}
</body>
</html> </html>

View File

@ -3,7 +3,7 @@
<ul class="nav nav-list"> <ul class="nav nav-list">
<li class="nav-header">Playlists</li> <li class="nav-header">Playlists</li>
{% for playlist in Playlist.objects.all %} {% for playlist in playlist_list %}
<li>{{ playlist.name }}</li> <li><a href="#" data-playlist-name="{{ playlist.name }}">{{ playlist.name }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -2,6 +2,8 @@
from django.utils import simplejson from django.utils import simplejson
from django.http import HttpResponse from django.http import HttpResponse
from archiver.playlist import Playlist
def json_response(**kwargs): def json_response(**kwargs):
#This is used to make sure that we have a standard json response #This is used to make sure that we have a standard json response
response = {} response = {}
@ -13,3 +15,12 @@ def json_response(**kwargs):
response["success"] = True response["success"] = True
return HttpResponse(simplejson.dumps(response)) return HttpResponse(simplejson.dumps(response))
def template_resources():
"Return a dictionary of resources templates will need"
#For example, giving templates a reference to all playlists.
resource_dict = {}
resource_dict.update({"playlist_list": Playlist.objects.all()})
return resource_dict