Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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
Пример #4
0
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