示例#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
文件: views.py 项目: IHLeanne/mayan
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))
示例#3
0
文件: views.py 项目: mrcrabby/mayan
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))