From 5c538d395e3bc83a5c212ca30e94b7a19e641091 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Tue, 5 Feb 2013 15:06:31 -0500 Subject: [PATCH] Enable playlist listing, fix various javascript errors --- web/views/index.py | 6 ++++-- web/views/templates/base | 3 ++- web/views/templates/components/playlist_sidebar | 4 ++-- web/web_utils.py | 11 +++++++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/web/views/index.py b/web/views/index.py index cb36d67..273fd8c 100644 --- a/web/views/index.py +++ b/web/views/index.py @@ -6,8 +6,10 @@ from django.template import RequestContext from django.shortcuts import render_to_response, redirect #Melodia-specific utilities -from web_utils import json_response as json +import web_utils @login_required 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() + )) diff --git a/web/views/templates/base b/web/views/templates/base index 7ac7570..7556ca5 100644 --- a/web/views/templates/base +++ b/web/views/templates/base @@ -74,7 +74,6 @@ List of block elements in this page: {% endblock %} - {# General scripts #} {% block scripts %} @@ -94,4 +93,6 @@ List of block elements in this page: {% endblock %} {% endblock %}{# endblock scripts #} + + diff --git a/web/views/templates/components/playlist_sidebar b/web/views/templates/components/playlist_sidebar index c3e70d0..be01a96 100644 --- a/web/views/templates/components/playlist_sidebar +++ b/web/views/templates/components/playlist_sidebar @@ -3,7 +3,7 @@ diff --git a/web/web_utils.py b/web/web_utils.py index 994f480..f5c7ee6 100644 --- a/web/web_utils.py +++ b/web/web_utils.py @@ -2,6 +2,8 @@ from django.utils import simplejson from django.http import HttpResponse +from archiver.playlist import Playlist + def json_response(**kwargs): #This is used to make sure that we have a standard json response response = {} @@ -13,3 +15,12 @@ def json_response(**kwargs): response["success"] = True 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