def index(request):
    EmbedVideo = get_embed_video_model()

    # Get embed videos
    embed_videos = EmbedVideo.objects.order_by('-created_at')

    # Permissions
    if not request.user.has_perm('wagtail_embed_videos.change_embedvideo'):
        # restrict to the user's own embed videos
        embed_videos = embed_videos.filter(uploaded_by_user=request.user)

    # Search
    query_string = None
    if 'q' in request.GET:
        form = SearchForm(request.GET, placeholder=_("Search videos"))
        if form.is_valid():
            query_string = form.cleaned_data['q']

            if not request.user.has_perm(
                    'wagtail_embed_videos.change_embedvideo'):
                # restrict to the user's own embed videos
                embed_videos = EmbedVideo.objects.search(
                    query_string,
                    filters={'uploaded_by_user_id': request.user.id})
            else:
                embed_videos = EmbedVideo.objects.search(query_string)
    else:
        form = SearchForm(placeholder=_("Search videos"))

    # Pagination
    p = request.GET.get('p', 1)
    paginator = Paginator(embed_videos, 20)

    try:
        embed_videos = paginator.page(p)
    except PageNotAnInteger:
        embed_videos = paginator.page(1)
    except EmptyPage:
        embed_videos = paginator.page(paginator.num_pages)

    # Create response
    if request.is_ajax():
        return render(
            request, 'wagtail_embed_videos/embed_videos/results.html', {
                'embed_videos': embed_videos,
                'query_string': query_string,
                'is_searching': bool(query_string),
            })
    else:
        return render(
            request, 'wagtail_embed_videos/embed_videos/index.html', {
                'embed_videos': embed_videos,
                'query_string': query_string,
                'is_searching': bool(query_string),
                'search_form': form,
                'popular_tags': popular_tags_for_model(EmbedVideo),
            })
Example #2
0
def index(request):
    Image = get_image_model()

    # Get images (filtered by user permission)
    images = permission_policy.instances_user_has_any_permission_for(request.user, ["change", "delete"]).order_by(
        "-created_at"
    )

    # Search
    query_string = None
    if "q" in request.GET:
        form = SearchForm(request.GET, placeholder=_("Search images"))
        if form.is_valid():
            query_string = form.cleaned_data["q"]

            images = images.search(query_string)
    else:
        form = SearchForm(placeholder=_("Search images"))

    # Filter by collection
    current_collection = None
    collection_id = request.GET.get("collection_id")
    if collection_id:
        try:
            current_collection = Collection.objects.get(id=collection_id)
            images = images.filter(collection=current_collection)
        except (ValueError, Collection.DoesNotExist):
            pass

    paginator, images = paginate(request, images)

    collections = permission_policy.collections_user_has_any_permission_for(request.user, ["add", "change"])
    if len(collections) < 2:
        collections = None

    # Create response
    if request.is_ajax():
        return render(
            request,
            "wagtailimages/images/results.html",
            {"images": images, "query_string": query_string, "is_searching": bool(query_string)},
        )
    else:
        return render(
            request,
            "wagtailimages/images/index.html",
            {
                "images": images,
                "query_string": query_string,
                "is_searching": bool(query_string),
                "search_form": form,
                "popular_tags": popular_tags_for_model(Image),
                "collections": collections,
                "current_collection": current_collection,
                "user_can_add": permission_policy.user_has_permission(request.user, "add"),
            },
        )
Example #3
0
def chooser(request):
    VideoForm = get_video_form(Video)
    uploadform = VideoForm()

    videos = Video.objects.order_by('-created_at')

    q = None
    if ('q' in request.GET or 'p' in request.GET or 'tag' in request.GET
            or 'collection_id' in request.GET):
        # this request is triggered from search, pagination or 'popular tags';
        # we will just render the results.html fragment
        collection_id = request.GET.get('collection_id')
        if collection_id:
            videos = videos.filter(collection=collection_id)

        searchform = SearchForm(request.GET)
        if searchform.is_valid():
            q = searchform.cleaned_data['q']

            videos = videos.search(q)
            is_searching = True
        else:
            is_searching = False

            tag_name = request.GET.get('tag')
            if tag_name:
                videos = videos.filter(tags__name=tag_name)

        # Pagination
        paginator, videos = paginate(request, videos, per_page=12)

        return render(request, "wagtailvideos/chooser/results.html", {
            'videos': videos,
            'is_searching': is_searching,
            'query_string': q,
        })
    else:
        searchform = SearchForm()

        collections = Collection.objects.all()
        if len(collections) < 2:
            collections = None

        paginator, videos = paginate(request, videos, per_page=12)

    return render_modal_workflow(
        request, 'wagtailvideos/chooser/chooser.html',
        'wagtailvideos/chooser/chooser.js', {
            'videos': videos,
            'uploadform': uploadform,
            'searchform': searchform,
            'is_searching': False,
            'query_string': q,
            'popular_tags': popular_tags_for_model(Video),
            'collections': collections,
        })
Example #4
0
def index(request):
    Image = get_image_model()

    # Get images (filtered by user permission)
    images = permission_policy.instances_user_has_any_permission_for(
        request.user, ['change', 'delete']
    ).order_by('-created_at')

    # Search
    query_string = None
    if 'q' in request.GET:
        form = SearchForm(request.GET, placeholder=_("Search images"))
        if form.is_valid():
            query_string = form.cleaned_data['q']

            images = images.search(query_string)
    else:
        form = SearchForm(placeholder=_("Search images"))

    # Filter by collection
    current_collection = None
    collection_id = request.GET.get('collection_id')
    if collection_id:
        try:
            current_collection = Collection.objects.get(id=collection_id)
            images = images.filter(collection=current_collection)
        except (ValueError, Collection.DoesNotExist):
            pass

    paginator, images = paginate(request, images)

    collections = permission_policy.collections_user_has_any_permission_for(
        request.user, ['add', 'change']
    )
    if len(collections) < 2:
        collections = None

    # Create response
    if request.is_ajax():
        return render(request, 'wagtailimages/images/results.html', {
            'images': images,
            'query_string': query_string,
            'is_searching': bool(query_string),
        })
    else:
        return render(request, 'wagtailimages/images/index.html', {
            'images': images,
            'query_string': query_string,
            'is_searching': bool(query_string),

            'search_form': form,
            'popular_tags': popular_tags_for_model(Image),
            'collections': collections,
            'current_collection': current_collection,
            'user_can_add': permission_policy.user_has_permission(request.user, 'add'),
        })
Example #5
0
def get_chooser_context(request):
    """Helper function to return common template context variables for the main chooser view"""

    collections = Collection.objects.all()
    if len(collections) < 2:
        collections = None

    return {
        'searchform': SearchForm(),
        'is_searching': False,
        'query_string': None,
        'will_select_format': request.GET.get('select_format'),
        'popular_tags': popular_tags_for_model(get_giphy_model()),
        'collections': collections,
    }
Example #6
0
def index(request):
    # Get Videos (filtered by user permission)
    videos = Video.objects.all()

    # Search
    query_string = None
    if 'q' in request.GET:
        form = SearchForm(request.GET, placeholder=_("Search videos"))
        if form.is_valid():
            query_string = form.cleaned_data['q']

            videos = videos.search(query_string)
    else:
        form = SearchForm(placeholder=_("Search videos"))

    # Filter by collection
    current_collection = None
    collection_id = request.GET.get('collection_id')
    if collection_id:
        try:
            current_collection = Collection.objects.get(id=collection_id)
            videos = videos.filter(collection=current_collection)
        except (ValueError, Collection.DoesNotExist):
            pass

    paginator, videos = paginate(request, videos)

    # Create response
    if request.is_ajax():
        response = render(request, 'wagtailvideos/videos/results.html', {
            'vidoes': videos,
            'query_string': query_string,
            'is_searching': bool(query_string),
        })
        return response
    else:
        response = render(request, 'wagtailvideos/videos/index.html', {
            'videos': videos,
            'query_string': query_string,
            'is_searching': bool(query_string),

            'search_form': form,
            'popular_tags': popular_tags_for_model(Video),
            'current_collection': current_collection,
        })
        return response
Example #7
0
def chooser(request):
    Image = get_image_model()

    if permission_policy.user_has_permission(request.user, 'add'):
        ImageForm = get_image_form(Image)
        uploadform = ImageForm(user=request.user)
    else:
        uploadform = None

    images = Image.objects.order_by('-created_at')

    # allow hooks to modify the queryset
    for hook in hooks.get_hooks('construct_image_chooser_queryset'):
        images = hook(images, request)

    q = None
    if ('q' in request.GET or 'p' in request.GET or 'tag' in request.GET
            or 'collection_id' in request.GET):
        # this request is triggered from search, pagination or 'popular tags';
        # we will just render the results.html fragment
        collection_id = request.GET.get('collection_id')
        if collection_id:
            images = images.filter(collection=collection_id)

        searchform = SearchForm(request.GET)
        if searchform.is_valid():
            q = searchform.cleaned_data['q']

            images = images.search(q)
            is_searching = True
        else:
            is_searching = False

            tag_name = request.GET.get('tag')
            if tag_name:
                images = images.filter(tags__name=tag_name)

        # Pagination
        paginator, images = paginate(request, images, per_page=12)

        return render(
            request, "wagtailimages/chooser/results.html", {
                'images': images,
                'is_searching': is_searching,
                'query_string': q,
                'will_select_format': request.GET.get('select_format')
            })
    else:
        searchform = SearchForm()

        collections = Collection.objects.all()
        if len(collections) < 2:
            collections = None

        paginator, images = paginate(request, images, per_page=12)

        return render_modal_workflow(
            request, 'wagtailimages/chooser/chooser.html',
            'wagtailimages/chooser/chooser.js', {
                'images': images,
                'uploadform': uploadform,
                'searchform': searchform,
                'is_searching': False,
                'query_string': q,
                'will_select_format': request.GET.get('select_format'),
                'popular_tags': popular_tags_for_model(Image),
                'collections': collections,
            })
Example #8
0
def index(request):
    Image = get_image_model()

    # Get images (filtered by user permission)
    images = permission_policy.instances_user_has_any_permission_for(
        request.user, ['change', 'delete']).order_by('-created_at')

    # Search
    query_string = None
    if 'q' in request.GET:
        form = SearchForm(request.GET, placeholder=_("Search images"))
        if form.is_valid():
            query_string = form.cleaned_data['q']

            images = images.search(query_string)
    else:
        form = SearchForm(placeholder=_("Search images"))

    # Filter by collection
    current_collection = None
    collection_id = request.GET.get('collection_id')
    if collection_id:
        try:
            current_collection = Collection.objects.get(id=collection_id)
            images = images.filter(collection=current_collection)
        except (ValueError, Collection.DoesNotExist):
            pass

    paginator, images = paginate(request, images)

    collections = permission_policy.collections_user_has_any_permission_for(
        request.user, ['add', 'change'])
    if len(collections) < 2:
        collections = None

    # Create response
    if request.is_ajax():
        return render(
            request, 'wagtailimages/images/results.html', {
                'images': images,
                'query_string': query_string,
                'is_searching': bool(query_string),
            })
    else:
        return render(
            request, 'wagtailimages/images/index.html', {
                'images':
                images,
                'query_string':
                query_string,
                'is_searching':
                bool(query_string),
                'search_form':
                form,
                'popular_tags':
                popular_tags_for_model(Image),
                'collections':
                collections,
                'current_collection':
                current_collection,
                'user_can_add':
                permission_policy.user_has_permission(request.user, 'add'),
            })
Example #9
0
def chooser(request):
    EmbedVideo = get_embed_video_model()

    if permission_policy.user_has_permission(request.user, 'add'):
        EmbedVideoForm = get_embed_video_form(EmbedVideo)
        uploadform = EmbedVideoForm(user=request.user)
    else:
        uploadform = None

    embed_videos = EmbedVideo.objects.order_by('-created_at')

    q = None
    if 'q' in request.GET or 'p' in request.GET or 'tag' in request.GET or 'collection_id' in request.GET:
        collection_id = request.GET.get('collection_id')
        if collection_id:
            embed_videos = embed_videos.filter(collection=collection_id)

        searchform = SearchForm(request.GET)
        if searchform.is_valid():
            q = searchform.cleaned_data['q']

            embed_videos = embed_videos.search(q)
            is_searching = True

        else:
            is_searching = False

            tag_name = request.GET.get('tag')
            if tag_name:
                embed_videos = embed_videos.filter(tags__name=tag_name)

        paginator, embed_videos = paginate(request, embed_videos, per_page=12)

        return render(request, "wagtail_embed_videos/chooser/results.html", {
            'embed_videos': embed_videos,
            'is_searching': is_searching,
            'query_string': q,
        })
    else:
        searchform = SearchForm()

        collections = Collection.objects.all()
        if len(collections) < 2:
            collections = None

        paginator, embed_videos = paginate(request, embed_videos, per_page=12)

    return render_modal_workflow(
        request,
        'wagtail_embed_videos/chooser/chooser.html',
        'wagtail_embed_videos/chooser/chooser.js',
        {
            'embed_videos': embed_videos,
            'uploadform': uploadform,
            'searchform': searchform,
            'is_searching': False,
            'query_string': q,
            'popular_tags': popular_tags_for_model(EmbedVideo),
            'collections': collections,
        }
    )
Example #10
0
def index(request):
    Document = get_document_model()

    # Get documents (filtered by user permission)
    documents = permission_policy.instances_user_has_any_permission_for(
        request.user, ['change', 'delete']
    )

    # Ordering
    if 'ordering' in request.GET and request.GET['ordering'] in ['title', '-created_at']:
        ordering = request.GET['ordering']
    else:
        ordering = '-created_at'
    documents = documents.order_by(ordering)

    # Filter by collection
    current_collection = None
    collection_id = request.GET.get('collection_id')
    if collection_id:
        try:
            current_collection = Collection.objects.get(id=collection_id)
            documents = documents.filter(collection=current_collection)
        except (ValueError, Collection.DoesNotExist):
            pass

    # Search
    query_string = None
    if 'q' in request.GET:
        form = SearchForm(request.GET, placeholder=_("Search documents"))
        if form.is_valid():
            query_string = form.cleaned_data['q']
            documents = documents.search(query_string)
    else:
        form = SearchForm(placeholder=_("Search documents"))

    # Pagination
    paginator, documents = paginate(request, documents)

    collections = permission_policy.collections_user_has_any_permission_for(
        request.user, ['add', 'change']
    )
    if len(collections) < 2:
        collections = None

    # Create response
    if request.is_ajax():
        return render(request, 'wagtaildocs/documents/results.html', {
            'ordering': ordering,
            'documents': documents,
            'query_string': query_string,
            'is_searching': bool(query_string),
        })
    else:
        return render(request, 'wagtaildocs/documents/index.html', {
            'ordering': ordering,
            'documents': documents,
            'query_string': query_string,
            'is_searching': bool(query_string),

            'search_form': form,
            'popular_tags': popular_tags_for_model(Document),
            'user_can_add': permission_policy.user_has_permission(request.user, 'add'),
            'collections': collections,
            'current_collection': current_collection,
        })
Example #11
0
def chooser(request):
    Image = get_image_model()

    if permission_policy.user_has_permission(request.user, 'add'):
        ImageForm = get_image_form(Image)
        uploadform = ImageForm(user=request.user)
    else:
        uploadform = None

    images = Image.objects.order_by('-created_at')

    q = None
    if (
        'q' in request.GET or 'p' in request.GET or 'tag' in request.GET or
        'collection_id' in request.GET
    ):
        # this request is triggered from search, pagination or 'popular tags';
        # we will just render the results.html fragment
        collection_id = request.GET.get('collection_id')
        if collection_id:
            images = images.filter(collection=collection_id)

        searchform = SearchForm(request.GET)
        if searchform.is_valid():
            q = searchform.cleaned_data['q']

            images = images.search(q)
            is_searching = True
        else:
            is_searching = False

            tag_name = request.GET.get('tag')
            if tag_name:
                images = images.filter(tags__name=tag_name)

        # Pagination
        paginator, images = paginate(request, images, per_page=12)

        return render(request, "wagtailimages/chooser/results.html", {
            'images': images,
            'is_searching': is_searching,
            'query_string': q,
            'will_select_format': request.GET.get('select_format')
        })
    else:
        searchform = SearchForm()

        collections = Collection.objects.all()
        if len(collections) < 2:
            collections = None

        paginator, images = paginate(request, images, per_page=12)

    return render_modal_workflow(request, 'wagtailimages/chooser/chooser.html', 'wagtailimages/chooser/chooser.js', {
        'images': images,
        'uploadform': uploadform,
        'searchform': searchform,
        'is_searching': False,
        'query_string': q,
        'will_select_format': request.GET.get('select_format'),
        'popular_tags': popular_tags_for_model(Image),
        'collections': collections,
    })
def chooser(request):
    Image = get_image_model()
    ImageFolder = get_folder_model()

    if permission_policy.user_has_permission(request.user, 'add'):
        ImageForm = get_image_form(Image)
        uploadform = ImageForm(user=request.user)
        ImageFolderForm = get_folder_form(ImageFolder)
    else:
        uploadform = None

    # Get images (filtered by user permission)
    images = permission_policy.instances_user_has_any_permission_for(
        request.user, ['change', 'delete']
    ).order_by('-created_at')

    # Check if folders_only
    folders_only = request.GET.get('folders_only')
    if folders_only:
        folders_only = True
    else:
        folders_only = False

    # Filter by folder
    folders = ImageFolder.objects.filter(folder__isnull = True)
    current_folder = None
    folder_id = request.GET.get('folder')
    if folder_id:
        try:
            current_folder = ImageFolder.objects.get(id=folder_id)
            images = Image.objects.filter(folder=current_folder)
        except (ValueError, ImageFolder.DoesNotExist):
            pass

    q = None
    if (
        'q' in request.GET or 'p' in request.GET or 'tag' in request.GET or
        'collection_id' in request.GET or
        'folder' in request.GET
    ):
        # this request is triggered from search, pagination or 'popular tags';
        # we will just render the results.html fragment
        collection_id = request.GET.get('collection_id')
        if collection_id:
            images = images.filter(collection=collection_id)

        searchform = SearchForm(request.GET)
        if searchform.is_valid():
            q = searchform.cleaned_data['q']

            images = images.search(q)
            is_searching = True
        else:
            is_searching = False

            tag_name = request.GET.get('tag')
            if tag_name:
                images = images.filter(tags__name=tag_name)

        # Pagination
        paginator, images = paginate(request, images, per_page=12)

        if not folders_only:
            return render(request, "wagtailimages/chooser/results.html", {
                'images': images,
                'folders' : folders,
                'current_folder' : current_folder,
                'is_searching': is_searching,
                'query_string': q,
                'will_select_format': request.GET.get('select_format')
            })
        else:
            return render(request, "wagtailimages/chooser/folders.html", {
                'images': images,
                'folders': folders,
                'current_folder': current_folder,
                'is_searching': is_searching,
                'query_string': q,
                'will_select_format': request.GET.get('select_format')
            })
    else:
        searchform = SearchForm()

        collections = Collection.objects.all()
        if len(collections) < 2:
            collections = None

        paginator, images = paginate(request, images, per_page=12)

    return render_modal_workflow(request, 'wagtailimages/chooser/chooser.html', 'wagtailimages/chooser/chooser.js', {
        'images': images,
        'folders' : folders,
        'current_folder' : current_folder,
        'uploadform': uploadform,
        'searchform': searchform,
        'is_searching': False,
        'query_string': q,
        'will_select_format': request.GET.get('select_format'),
        'popular_tags': popular_tags_for_model(Image),
        'collections': collections,
    })
Example #13
0
def chooser(request):
    EmbedVideo = get_embed_video_model()

    if request.user.has_perm('wagtail_embed_videos.add_embedvideo'):
        can_add = True
    else:
        can_add = False

    q = None
    if 'q' in request.GET or 'p' in request.GET:
        searchform = SearchForm(request.GET)
        if searchform.is_valid():
            q = searchform.cleaned_data['q']

            # page number
            p = request.GET.get("p", 1)

            embed_videos = EmbedVideo.search(q, results_per_page=10, page=p)

            is_searching = True

        else:
            embed_videos = EmbedVideo.objects.order_by('-created_at')
            p = request.GET.get("p", 1)
            paginator = Paginator(embed_videos, 10)

            try:
                embed_videos = paginator.page(p)
            except PageNotAnInteger:
                embed_videos = paginator.page(1)
            except EmptyPage:
                embed_videos = paginator.page(paginator.num_pages)

            is_searching = False
        return render(
            request, "wagtail_embed_videos/chooser/results.html", {
                'embed_videos': embed_videos,
                'is_searching': is_searching,
                'can_add': can_add,
                'query_string': q,
            })
    else:
        searchform = SearchForm()

        embed_videos = EmbedVideo.objects.order_by('-created_at')
        p = request.GET.get("p", 1)
        paginator = Paginator(embed_videos, 10)

        try:
            embed_videos = paginator.page(p)
        except PageNotAnInteger:
            embed_videos = paginator.page(1)
        except EmptyPage:
            embed_videos = paginator.page(paginator.num_pages)
    print(can_add)
    return render_modal_workflow(
        request, 'wagtail_embed_videos/chooser/chooser.html',
        'wagtail_embed_videos/chooser/chooser.js', {
            'embed_videos': embed_videos,
            'searchform': searchform,
            'is_searching': False,
            'can_add': can_add,
            'query_string': q,
            'popular_tags': popular_tags_for_model(EmbedVideo),
        })
Example #14
0
def index(request):
    Document = get_document_model()

    # Get documents (filtered by user permission)
    documents = permission_policy.instances_user_has_any_permission_for(
        request.user, ['change', 'delete']
    )

    # Ordering
    if 'ordering' in request.GET and request.GET['ordering'] in ['title', '-created_at']:
        ordering = request.GET['ordering']
    else:
        ordering = '-created_at'
    documents = documents.order_by(ordering)

    # Filter by collection
    current_collection = None
    collection_id = request.GET.get('collection_id')
    if collection_id:
        try:
            current_collection = Collection.objects.get(id=collection_id)
            documents = documents.filter(collection=current_collection)
        except (ValueError, Collection.DoesNotExist):
            pass

    # Search
    query_string = None
    if 'q' in request.GET:
        form = SearchForm(request.GET, placeholder=_("Search documents"))
        if form.is_valid():
            query_string = form.cleaned_data['q']
            documents = documents.search(query_string)
    else:
        form = SearchForm(placeholder=_("Search documents"))

    # Pagination
    paginator, documents = paginate(request, documents)

    collections = permission_policy.collections_user_has_any_permission_for(
        request.user, ['add', 'change']
    )
    if len(collections) < 2:
        collections = None

    # Create response
    if request.is_ajax():
        return render(request, 'wagtaildocs/documents/results.html', {
            'ordering': ordering,
            'documents': documents,
            'query_string': query_string,
            'is_searching': bool(query_string),
        })
    else:
        return render(request, 'wagtaildocs/documents/index.html', {
            'ordering': ordering,
            'documents': documents,
            'query_string': query_string,
            'is_searching': bool(query_string),

            'search_form': form,
            'popular_tags': popular_tags_for_model(Document),
            'user_can_add': permission_policy.user_has_permission(request.user, 'add'),
            'collections': collections,
            'current_collection': current_collection,
        })
Example #15
0
def multichooser(request):
    collection_id = request.GET.get('collection_id', None)
    if not collection_id:
        album_title = request.GET.get('album_title')
        page_id = request.GET.get('page_id', None)
        parent_page_id = request.GET.get('parent_page_id', None)
        collection = get_or_create_collection(album_title, page_id,
                                              parent_page_id)
    else:
        collection = Collection.objects.get(id=collection_id)

    Image = get_image_model()

    if permission_policy.user_has_permission(request.user, 'add'):
        ImageForm = get_image_form(Image)
        uploadform = ImageForm(user=request.user)
    else:
        uploadform = None

    images = Image.objects.filter(
        collection=collection).order_by('-created_at')

    # allow hooks to modify the queryset
    for hook in hooks.get_hooks('construct_image_chooser_queryset'):
        images = hook(images, request)

    q = None
    if ('q' in request.GET or 'p' in request.GET or 'tag' in request.GET):
        # this request is triggered from search, pagination or 'popular tags';
        # we will just render the results.html fragment

        searchform = SearchForm(request.GET)
        if searchform.is_valid():
            q = searchform.cleaned_data['q']

            images = images.search(q)
            is_searching = True
        else:
            is_searching = False

            tag_name = request.GET.get('tag')
            if tag_name:
                images = images.filter(tags__name=tag_name)

        # Pagination
        paginator, images = paginate(request, images, per_page=20)

        return render(
            request, "fotoalben/multichooser/results.html", {
                'images': images,
                'is_searching': is_searching,
                'query_string': q,
                'will_select_format': request.GET.get('select_format')
            })
    else:
        searchform = SearchForm()
        #        this_site = Site.find_for_request( request )
        #        collections = Collection.objects.all()
        #        if len(collections) < 2:
        #            collections = None

        paginator, images = paginate(request, images, per_page=20)

        return render_modal_workflow(
            request, 'fotoalben/multichooser/multichooser.html',
            'fotoalben/multichooser/multichooser.js', {
                'images': images,
                'uploadform': uploadform,
                'searchform': searchform,
                'is_searching': False,
                'query_string': q,
                'will_select_format': request.GET.get('select_format'),
                'popular_tags': popular_tags_for_model(Image),
                'collections': [collection],
                'collection': collection,
                'page_id': page_id,
                'album_title': album_title,
                'parent_page_id': parent_page_id
            })