Пример #1
0
def index_instance_list(request, index_id=None):
    check_permissions(request.user, [PERMISSION_DOCUMENT_INDEXING_VIEW])

    if index_id:
        index_instance = get_object_or_404(IndexInstance, pk=index_id)
        index_instance_list = [
            index for index in index_instance.get_children().order_by('value')
        ]
        breadcrumbs = get_breadcrumbs(index_instance)
        if index_instance.documents.count():
            for document in index_instance.documents.all().order_by(
                    'file_filename'):
                index_instance_list.append(document)
    else:
        index_instance_list = IndexInstance.objects.filter(parent=None)
        breadcrumbs = get_instance_link()
        index_instance = None

    title = mark_safe(_(u'contents for index: %s') % breadcrumbs)

    if index_instance:
        if index_instance.index.link_documents:
            # Document list, use the document_list view for consistency
            return document_list(request,
                                 title=title,
                                 object_list=index_instance_list,
                                 extra_context={'object': index_instance})

    return render_to_response('generic_list.html', {
        'object_list':
        index_instance_list,
        'extra_columns_preffixed':
        [{
            'name': _(u'index'),
            'attribute': encapsulate(lambda x: index_instance_item_link(x))
        }, {
            'name':
            _(u'items'),
            'attribute':
            encapsulate(lambda x: x.documents.count() if x.index.link_documents
                        else x.get_children().count())
        }],
        'title':
        title,
        'hide_links':
        True,
        'hide_object':
        True,
        'object':
        index_instance
    },
                              context_instance=RequestContext(request))
Пример #2
0
def document_index_list(request, document_id):
    check_permissions(request.user, [PERMISSION_DOCUMENT_VIEW, PERMISSION_DOCUMENT_INDEXING_VIEW])
    document = get_object_or_404(Document, pk=document_id)

    object_list = []

    for index_instance in document.indexinstance_set.all():
        object_list.append(get_breadcrumbs(index_instance, single_link=True, include_count=True))

    return render_to_response('generic_list.html', {
        'title': _(u'indexes containing: %s') % document,
        'object_list': object_list,
        'hide_link': True,
        'object': document
    }, context_instance=RequestContext(request))
Пример #3
0
def index_instance_list(request, index_id=None):
    check_permissions(request.user, [PERMISSION_DOCUMENT_INDEXING_VIEW])

    if index_id:
        index_instance = get_object_or_404(IndexInstance, pk=index_id)
        index_instance_list = [index for index in index_instance.get_children().order_by('value')]
        breadcrumbs = get_breadcrumbs(index_instance)
        if index_instance.documents.count():
            for document in index_instance.documents.all().order_by('file_filename'):
                index_instance_list.append(document)
    else:
        index_instance_list = IndexInstance.objects.filter(parent=None)
        breadcrumbs = get_instance_link()
        index_instance = None

    title = mark_safe(_(u'contents for index: %s') % breadcrumbs)

    if index_instance:
        if index_instance.index.link_documents:
            # Document list, use the document_list view for consistency
            return document_list(
                request,
                title=title,
                object_list=index_instance_list,
                extra_context={
                    'object': index_instance
                }
            )

    return render_to_response('generic_list.html', {
        'object_list': index_instance_list,
        'extra_columns_preffixed': [
            {
                'name': _(u'index'),
                'attribute': encapsulate(lambda x: index_instance_item_link(x))
            },
            {
                'name': _(u'items'),
                'attribute': encapsulate(lambda x: x.documents.count() if x.index.link_documents else x.get_children().count() )
            }
        ],
        'title': title,
        'hide_links': True,
        'hide_object': True,
        'object': index_instance

    }, context_instance=RequestContext(request))
Пример #4
0
def get_document_indexing_subtemplate(document):
    """
    Return all the settings to render a subtemplate containing a
    list of index instances where a document may be found
    """
    object_list = []

    for index_instance in document.indexinstance_set.all():
        object_list.append(get_breadcrumbs(index_instance, single_link=True, include_count=True))

    return {
            'name': 'generic_list_subtemplate.html',
            'context': {
                'title': _(u'document indexes'),
                'object_list': object_list,
                'hide_link': True
            }
        }
Пример #5
0
def document_index_list(request, document_id):
    check_permissions(
        request.user,
        [PERMISSION_DOCUMENT_VIEW, PERMISSION_DOCUMENT_INDEXING_VIEW])
    document = get_object_or_404(Document, pk=document_id)

    object_list = []

    for index_instance in document.indexinstance_set.all():
        object_list.append(
            get_breadcrumbs(index_instance,
                            single_link=True,
                            include_count=True))

    return render_to_response('generic_list.html', {
        'title': _(u'indexes containing: %s') % document,
        'object_list': object_list,
        'hide_link': True,
        'object': document
    },
                              context_instance=RequestContext(request))
Пример #6
0
def get_document_indexing_subtemplate(document):
    """
    Return all the settings to render a subtemplate containing a
    list of index instances where a document may be found
    """
    object_list = []

    for index_instance in document.indexinstance_set.all():
        object_list.append(
            get_breadcrumbs(index_instance,
                            single_link=True,
                            include_count=True))

    return {
        'name': 'generic_list_subtemplate.html',
        'context': {
            'title': _(u'document indexes'),
            'object_list': object_list,
            'hide_link': True
        }
    }
Пример #7
0
def index_instance_list(request, index_id=None):
    check_permissions(request.user, [PERMISSION_DOCUMENT_INDEXING_VIEW])

    if index_id:
        index_instance = get_object_or_404(IndexInstance, pk=index_id)
        index_instance_list = [index for index in index_instance.get_children().order_by('value')]
        breadcrumbs = get_breadcrumbs(index_instance)
        if index_instance.documents.count():
            for document in index_instance.documents.all().order_by('file_filename'):
                index_instance_list.append(document)
    else:
        index_instance_list = IndexInstance.objects.filter(parent=None)
        breadcrumbs = get_instance_link()
        index_instance = None
    
    show_multi_select_buttons = False
    if index_instance:
        if index_instance.index.link_documents:
            show_multi_select_buttons = True

    title = mark_safe(_(u'contents for index: %s') % breadcrumbs)

    return render_to_response('generic_list.html', {
        'object_list': index_instance_list,
        'extra_columns_preffixed': [
            {
                'name': _(u'item'),
                'attribute': lambda x: index_instance_item_link(x)
            }
        ],
        'title': title,
        'hide_links': True,
        'hide_object': True,
        'multi_select_as_buttons': show_multi_select_buttons,
        'object': index_instance

    }, context_instance=RequestContext(request))