def jsonize_ringtones(ringtones): 'Convert the ringtone list to JSON array.' ringtone_list = [] for ringtone in ringtones: ringtone_dict = { "Id": ringtone.id, "Name": ringtone.name, "MimeType": ringtone.mime_type, "FileSize": ringtone.file_size, "Duration": ringtone.duration, "Url": ringtone.url, "LastModify": timestamp(ringtone.last_modify), "CategoryId": ringtone.category.id, "CategoryName": ringtone.category.name, "UserId": ringtone.upload_user.id, } ringtone_list.append(ringtone_dict) return simplejson.dumps(ringtone_list)
def jsonize_ringtones(ringtones): 'Convert the ringtone list to JSON array.' ringtone_list = [] for ringtone in ringtones: ringtone_dict = { "Id" : ringtone.id, "Name" : ringtone.name, "MimeType" : ringtone.mime_type, "FileSize" : ringtone.file_size, "Duration" : ringtone.duration, "Url" : ringtone.url, "LastModify" : timestamp(ringtone.last_modify), "CategoryId" : ringtone.category.id, "CategoryName" : ringtone.category.name, "UserId" : ringtone.upload_user.id, } ringtone_list.append(ringtone_dict) return simplejson.dumps(ringtone_list)
def retrieve_categories(request): 'Retrieve all categories.' response = HttpResponse() if request.method == 'GET': categories = Category.objects.all() category_list = [] for category in categories: category_dict = { 'Id': category.id, 'Name': category.name, 'IconUrl': category.icon_url, 'ContentLevel': category.content_level, 'LastModify': timestamp(category.last_modify), } category_list.append(category_dict) response.write(simplejson.dumps(category_list)) else: response.status_code = 405 return response
def retrieve_categories(request): 'Retrieve all categories.' response = HttpResponse() if request.method == 'GET': categories = Category.objects.all() category_list = [] for category in categories: category_dict = { 'Id' : category.id, 'Name' : category.name, 'IconUrl' : category.icon_url, 'ContentLevel' : category.content_level, 'LastModify' : timestamp(category.last_modify), } category_list.append(category_dict) response.write(simplejson.dumps(category_list)) else: response.status_code = 405 return response