2013-01-24 19:04:29 -05:00
|
|
|
#Utilities file for the web client
|
|
|
|
from django.utils import simplejson
|
|
|
|
from django.http import HttpResponse
|
|
|
|
|
2013-02-05 15:06:31 -05:00
|
|
|
from archiver.playlist import Playlist
|
|
|
|
|
2013-01-24 19:04:29 -05:00
|
|
|
def json_response(**kwargs):
|
|
|
|
#This is used to make sure that we have a standard json response
|
2013-02-05 14:20:26 -05:00
|
|
|
response = {}
|
2013-01-24 19:04:29 -05:00
|
|
|
for key, value in kwargs.iteritems():
|
|
|
|
response[key] = value
|
|
|
|
|
|
|
|
#After including anything specified in our arguments, make sure that we have a "success" parameter
|
|
|
|
if not "success" in response:
|
|
|
|
response["success"] = True
|
|
|
|
|
|
|
|
return HttpResponse(simplejson.dumps(response))
|
2013-02-05 15:06:31 -05:00
|
|
|
|
|
|
|
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
|