Esempio n. 1
0
def album_search_json(request):
    if len(request.POST['query']) < settings.IMAGE_SEARCH_LENGTH:
        return HttpResponse('[]')

    albums = Album.objects.filter(name__icontains=request.POST['query']).order_by('name')
    items = []
    for album in albums:
        items.append(list_parents_values(album))
    return HttpResponse(json.dumps({'items': items}))
Esempio n. 2
0
def album_content_json(request, album):
    if album is not None:
        current_album = Album.objects.get(id=album)
        albums = Album.objects.filter(parent=album).order_by('name')
        path = list_parents_values(current_album)
    else:
        albums = Album.objects.filter(parent=None).order_by('name')
        path = []
    return HttpResponse(json.dumps({'albums': list(albums.values()), 'path': path}))