Exemplo n.º 1
0
def history_list(request):
    check_permissions(request.user, [PERMISSION_HISTORY_VIEW])

    context = {
        'object_list':
        History.objects.all(),
        'title':
        _(u'history events'),
        'extra_columns': [{
            'name': _(u'date and time'),
            'attribute': 'datetime'
        }, {
            'name':
            _(u'object'),
            'attribute':
            encapsulate(lambda x: history_entry_object_link(x))
        }, {
            'name':
            _(u'summary'),
            'attribute':
            encapsulate(lambda x: history_entry_summary(x))
        }],
        'hide_object':
        True,
    }

    return render_to_response('generic_list.html',
                              context,
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def role_permissions(request, role_id):
    Permission.objects.check_permissions(
        request.user,
        [PERMISSION_PERMISSION_GRANT, PERMISSION_PERMISSION_REVOKE])

    role = get_object_or_404(Role, pk=role_id)
    form = RoleForm_view(instance=role)

    role_permissions_list = Permission.objects.get_for_holder(role)
    subtemplates_list = [
        {
            'name': u'generic_list_subtemplate.html',
            'context': {
                'title':
                _(u'permissions'),
                'object_list':
                Permission.objects.all(),
                'extra_columns': [
                    {
                        'name': _(u'namespace'),
                        'attribute': encapsulate(lambda x: x.namespace)
                    },
                    {
                        'name': _(u'name'),
                        'attribute': encapsulate(lambda x: x.label)
                    },
                    {
                        'name':
                        _(u'has permission'),
                        'attribute':
                        encapsulate(lambda x: two_state_template(
                            x.requester_has_this(role)).display_small()),
                    },
                ],
                'hide_link':
                True,
                'hide_object':
                True,
            }
        },
    ]

    return render_to_response('generic_detail.html', {
        'form': form,
        'object': role,
        'object_name': _(u'role'),
        'subtemplates_list': subtemplates_list,
        'multi_select_as_buttons': True,
        'multi_select_item_properties': {
            'permission_id':
            lambda x: x.pk,
            'requester_id':
            lambda x: role.pk,
            'requester_app_label':
            lambda x: ContentType.objects.get_for_model(role).app_label,
            'requester_model':
            lambda x: ContentType.objects.get_for_model(role).model,
        },
    },
                              context_instance=RequestContext(request))
Exemplo n.º 3
0
def acl_list_for(request, obj, extra_context=None):
    try:
        Permission.objects.check_permissions(request.user, [ACLS_VIEW_ACL])
    except PermissionDenied:
        AccessEntry.objects.check_access(ACLS_VIEW_ACL, request.user, obj)

    logger.debug('obj: %s', obj)

    context = {
        'object_list': AccessEntry.objects.get_holders_for(obj),
        'title': _('Access control lists for: %s' % obj),
        'extra_columns': [
            {'name': _('Holder'), 'attribute': encapsulate(lambda x: object_w_content_type_icon(x.source_object))},
            {'name': _('Permissions'), 'attribute': encapsulate(lambda x: _permission_titles(AccessEntry.objects.get_holder_permissions_for(obj, x.source_object, db_only=True)))},
        ],
        'hide_object': True,
        'access_object': AccessObject.encapsulate(obj),
        'object': obj,
        'navigation_object_list': [
            {'object': 'object'},
            {'object': 'access_object'}
        ],
    }

    if extra_context:
        context.update(extra_context)

    return render_to_response('main/generic_list.html', context,
                              context_instance=RequestContext(request))
Exemplo n.º 4
0
def job_list(request):
    Permission.objects.check_permissions(request.user,
                                         [PERMISSION_VIEW_JOB_LIST])

    context = {
        'object_list':
        get_job_list(),
        'title':
        _(u'interval jobs'),
        'extra_columns': [
            {
                'name': _(u'label'),
                'attribute': encapsulate(lambda job: job['title'])
            },
            {
                'name': _(u'start date time'),
                'attribute':
                encapsulate(lambda job: job['job'].trigger.start_date)
            },
            {
                'name': _(u'interval'),
                'attribute':
                encapsulate(lambda job: job['job'].trigger.interval)
            },
        ],
        'hide_object':
        True,
    }

    return render_to_response('generic_list.html',
                              context,
                              context_instance=RequestContext(request))
Exemplo n.º 5
0
def role_permissions(request, role_id):
    check_permissions(request.user, [PERMISSION_PERMISSION_GRANT, PERMISSION_PERMISSION_REVOKE])

    role = get_object_or_404(Role, pk=role_id)
    form = RoleForm_view(instance=role)

    role_permissions_list = Permission.objects.get_for_holder(role)
    subtemplates_list = [
        {
            'name': u'generic_list_subtemplate.html',
            'context': {
                'title': _(u'permissions'),
                'object_list': Permission.objects.all(),
                'extra_columns': [
                    {'name': _(u'namespace'), 'attribute': encapsulate(lambda x: namespace_titles[x.namespace] if x.namespace in namespace_titles else x.namespace)},
                    {'name': _(u'name'), 'attribute': u'label'},
                    {
                        'name':_(u'state'),
                        'attribute': encapsulate(lambda x: role_permission_link(role, x, role_permissions_list)),
                    }
                ],
                'hide_link': True,
                'hide_object': True,
            }
        },
    ]

    return render_to_response('generic_detail.html', {
        'template_id': u'role_permissions',
        'form': form,
        'object': role,
        'object_name': _(u'role'),
        'subtemplates_list': subtemplates_list,
    }, context_instance=RequestContext(request))
Exemplo n.º 6
0
def index_setup_view(request, index_pk):
    index = get_object_or_404(Index, pk=index_pk)

    try:
        Permission.objects.check_permissions(request.user, [PERMISSION_DOCUMENT_INDEXING_SETUP])
    except PermissionDenied:
        AccessEntry.objects.check_access(PERMISSION_DOCUMENT_INDEXING_SETUP, request.user, index)

    object_list = index.template_root.get_descendants(include_self=True)

    context = {
        'object_list': object_list,
        'index': index,
        'list_object_variable_name': 'node',
        'navigation_object_name': 'index',
        'title': _('Tree template nodes for index: %s') % index,
        'hide_object': True,
        'extra_columns': [
            {'name': _('Level'), 'attribute': encapsulate(lambda x: node_level(x))},
            {'name': _('Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))},
            {'name': _('Has document links?'), 'attribute': encapsulate(lambda x: two_state_template(x.link_documents))},
        ],
    }

    return render_to_response('main/generic_list.html', context,
                              context_instance=RequestContext(request))
Exemplo n.º 7
0
 def get_extra_context(self):
     context = super(CheckoutListView, self).get_extra_context()
     context.update(
         {
             'title': _('Documents checked out'),
             'extra_columns': (
                 {
                     'name': _('User'),
                     'attribute': encapsulate(
                         lambda document: document.checkout_info().user.get_full_name() or document.checkout_info().user
                     )
                 },
                 {
                     'name': _('Checkout time and date'),
                     'attribute': encapsulate(
                         lambda document: document.checkout_info().checkout_datetime
                     )
                 },
                 {
                     'name': _('Checkout expiration'),
                     'attribute': encapsulate(
                         lambda document: document.checkout_info().expiration_datetime
                     )
                 },
             ),
         }
     )
     return context
Exemplo n.º 8
0
 def get_extra_context(self):
     context = super(CheckoutListView, self).get_extra_context()
     context.update(
         {
             'extra_columns': (
                 {
                     'name': _('User'),
                     'attribute': encapsulate(
                         lambda document: document.checkout_info().user.get_full_name() or document.checkout_info().user
                     )
                 },
                 {
                     'name': _('Checkout time and date'),
                     'attribute': encapsulate(
                         lambda document: document.checkout_info().checkout_datetime
                     )
                 },
                 {
                     'name': _('Checkout expiration'),
                     'attribute': encapsulate(
                         lambda document: document.checkout_info().expiration_datetime
                     )
                 },
             ),
             'no_results_icon': icon_checkout_info,
             'no_results_text': _(
                 'Checking out a document blocks certain document '
                 'operations for a predetermined amount of '
                 'time.'
             ),
             'no_results_title': _('No documents have been checked out'),
             'title': _('Documents checked out'),
         }
     )
     return context
Exemplo n.º 9
0
def formats_list(request):
    if request.user.is_superuser or request.user.is_staff:
        context = {
            'title':
            _(u'suported file formats'),
            'hide_object':
            True,
            'object_list':
            sorted(get_format_list()),
            'extra_columns': [{
                'name': _(u'name'),
                'attribute': encapsulate(lambda x: x[0])
            }, {
                'name': _(u'description'),
                'attribute': encapsulate(lambda x: x[1])
            }],
            'backend':
            GRAPHICS_BACKEND,
        }

        return render_to_response('generic_list.html',
                                  context,
                                  context_instance=RequestContext(request))
    else:
        raise PermissionDenied
Exemplo n.º 10
0
def history_list(request):
    Permission.objects.check_permissions(request.user, [PERMISSION_HISTORY_VIEW])

    context = {
        'object_list': History.objects.all(),
        'title': _(u'history events'),
        'extra_columns': [
            {
                'name': _(u'date and time'),
                'attribute': 'datetime'
            },
            {
                'name': _(u'object'),
                'attribute': encapsulate(lambda x: history_entry_object_link(x))
            },
            {
                'name': _(u'summary'),
                'attribute': encapsulate(lambda x: history_entry_summary(x))
            }
        ],
        'hide_object': True,
    }

    return render_to_response('generic_list.html', context,
        context_instance=RequestContext(request))
Exemplo n.º 11
0
def user_list(request):
    Permission.objects.check_permissions(request.user, [PERMISSION_USER_VIEW])

    return object_list(
        request,
        queryset=User.objects.exclude(is_superuser=True).exclude(is_staff=True).order_by('username'),
        template_name='generic_list.html',
        extra_context={
            'title': _(u'users'),
            'hide_link': True,
            'extra_columns': [
                {
                    'name': _(u'full name'),
                    'attribute': 'get_full_name'
                },
                {
                    'name': _(u'email'),
                    'attribute': 'email'
                },
                {
                    'name': _(u'active'),
                    'attribute': encapsulate(lambda x: two_state_template(x.is_active).display_small()),
                },
                {
                    'name': _(u'has usable password?'),
                    'attribute': encapsulate(lambda x: two_state_template(x.has_usable_password()).display_small()),
                },
            ],
            'multi_select_as_buttons': True,
        },
    )
Exemplo n.º 12
0
class CheckoutListView(DocumentListView):
    extra_context = {
        'title':
        _('Documents checked out'),
        'hide_links':
        True,
        'extra_columns': (
            {
                'name':
                _('User'),
                'attribute':
                encapsulate(lambda document: document.checkout_info().user.
                            get_full_name() or document.checkout_info().user)
            },
            {
                'name':
                _('Checkout time and date'),
                'attribute':
                encapsulate(lambda document: document.checkout_info().
                            checkout_datetime)
            },
            {
                'name':
                _('Checkout expiration'),
                'attribute':
                encapsulate(lambda document: document.checkout_info().
                            expiration_datetime)
            },
        ),
    }

    def get_document_queryset(self):
        return DocumentCheckout.objects.checked_out_documents()
Exemplo n.º 13
0
def user_list(request):
    Permission.objects.check_permissions(request.user, [PERMISSION_USER_VIEW])

    context = {
        'object_list': get_user_model().objects.exclude(is_superuser=True).exclude(is_staff=True).order_by('username'),
        'title': _(u'users'),
        'hide_link': True,
        'extra_columns': [
            {
                'name': _(u'full name'),
                'attribute': 'get_full_name'
            },
            {
                'name': _(u'email'),
                'attribute': 'email'
            },
            {
                'name': _(u'active'),
                'attribute': encapsulate(lambda x: two_state_template(x.is_active)),
            },
            {
                'name': _(u'has usable password?'),
                'attribute': encapsulate(lambda x: two_state_template(x.has_usable_password())),
            },
        ],
        'multi_select_as_buttons': True,
    }

    return render_to_response('generic_list.html', context,
        context_instance=RequestContext(request))
Exemplo n.º 14
0
def setting_list(request):
    new_settings = []
    for namespace, sub_settings in settings.items():
        for sub_setting in sub_settings:
            if not sub_setting.get('hidden', False):
                new_settings.append({
                    'module': sub_setting['module'],
                    'name': sub_setting['name'],
                    'global_name': sub_setting['global_name'],
                    'description': sub_setting.get('description', None),
                    'exists': sub_setting.get('exists', False),
                    'default': sub_setting['default'],
                    })
    context = {
        'template_id': u'crud_list',
        'title': _(u'settings'),
        'object_list': new_settings,
        'hide_link': True,
        'hide_object': True,
        'extra_columns': [
            {'name': _(u'name'), 'attribute': encapsulate(lambda x: mark_safe(u'<span style="font-weight: bold;">%s</span><br>%s' % (x.get('global_name'), x.get('description'))))},
            {'name': _(u'default'), 'attribute': encapsulate(lambda x: return_type(x['default']))},
            {'name': _(u'value'), 'attribute': encapsulate(lambda x: mark_safe(u'<div class="nowrap">%s&nbsp;%s</div>' % (
                    return_type(getattr(x['module'], x['name'])),
                    exists_with_famfam(getattr(x['module'], x['name'])) if x['exists'] else ''
                )))
            },
        ]
    }

    return render_to_response('generic_list.html', context,
        context_instance=RequestContext(request))
Exemplo n.º 15
0
def setup_source_list(request):
    Permission.objects.check_permissions(request.user,
                                         [PERMISSION_SOURCES_SETUP_VIEW])

    context = {
        'object_list':
        Source.objects.select_subclasses(),
        'title':
        _('Sources'),
        'hide_link':
        True,
        'list_object_variable_name':
        'source',
        'extra_columns': [
            {
                'name': _('Type'),
                'attribute': encapsulate(lambda x: x.class_fullname())
            },
            {
                'name':
                _('Enabled'),
                'attribute':
                encapsulate(lambda x: _('Yes') if x.enabled else _('No'))
            },
        ]
    }

    return render_to_response('main/generic_list.html',
                              context,
                              context_instance=RequestContext(request))
Exemplo n.º 16
0
def index_setup_view(request, index_pk):
    index = get_object_or_404(Index, pk=index_pk)

    try:
        Permission.objects.check_permissions(request.user, [PERMISSION_DOCUMENT_INDEXING_SETUP])
    except PermissionDenied:
        AccessEntry.objects.check_access(PERMISSION_DOCUMENT_INDEXING_SETUP, request.user, index)

    object_list = index.template_root.get_descendants(include_self=True)

    context = {
        "object_list": object_list,
        "index": index,
        "object_name": _(u"index"),
        "list_object_variable_name": "node",
        "navigation_object_name": "index",
        "title": _(u"tree template nodes for index: %s") % index,
        "hide_object": True,
        "extra_columns": [
            {"name": _(u"level"), "attribute": encapsulate(lambda x: node_level(x))},
            {"name": _(u"enabled"), "attribute": encapsulate(lambda x: two_state_template(x.enabled))},
            {
                "name": _(u"has document links?"),
                "attribute": encapsulate(lambda x: two_state_template(x.link_documents)),
            },
        ],
    }

    return render_to_response("generic_list.html", context, context_instance=RequestContext(request))
Exemplo n.º 17
0
def job_list(request):
    Permission.objects.check_permissions(request.user, [PERMISSION_VIEW_JOB_LIST])

    context = {
        'object_list': get_job_list(),
        'title': _(u'interval jobs'),
        'extra_columns': [
            {
                'name': _(u'label'),
                'attribute': encapsulate(lambda job: job['title'])
            },
            {
                'name': _(u'start date time'),
                'attribute': encapsulate(lambda job: job['job'].trigger.start_date)
            },
            {
                'name': _(u'interval'),
                'attribute': encapsulate(lambda job: job['job'].trigger.interval)
            },
        ],
        'hide_object': True,
    }

    return render_to_response('generic_list.html', context,
        context_instance=RequestContext(request))
Exemplo n.º 18
0
def index_setup_view(request, index_pk):
    index = get_object_or_404(Index, pk=index_pk)

    try:
        Permission.objects.check_permissions(request.user, [PERMISSION_DOCUMENT_INDEXING_SETUP])
    except PermissionDenied:
        AccessEntry.objects.check_access(PERMISSION_DOCUMENT_INDEXING_SETUP, request.user, index)

    object_list = index.template_root.get_descendants(include_self=True)

    context = {
        'object_list': object_list,
        'index': index,
        'object_name': _(u'index'),
        'list_object_variable_name': 'node',
        'navigation_object_name': 'index',
        'title': _(u'tree template nodes for index: %s') % index,
        'hide_object': True,
        'extra_columns': [
            {'name': _(u'level'), 'attribute': encapsulate(lambda x: node_level(x))},
            {'name': _(u'enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))},
            {'name': _(u'has document links?'), 'attribute': encapsulate(lambda x: two_state_template(x.link_documents))},            
        ],
    }

    return render_to_response('generic_list.html', context,
        context_instance=RequestContext(request))
Exemplo n.º 19
0
def acl_list_for(request, obj, extra_context=None):
    try:
        Permission.objects.check_permissions(request.user, [ACLS_VIEW_ACL])
    except PermissionDenied:
        AccessEntry.objects.check_access(ACLS_VIEW_ACL, request.user, obj)

    logger.debug('obj: %s' % obj)

    context = {
        'object_list': AccessEntry.objects.get_holders_for(obj),
        'title': _(u'access control lists for: %s' % obj),
        'extra_columns': [
            {'name': _(u'holder'), 'attribute': encapsulate(lambda x: object_w_content_type_icon(x.source_object))},
            {'name': _(u'permissions'), 'attribute': encapsulate(lambda x: _permission_titles(AccessEntry.objects.get_holder_permissions_for(obj, x.source_object, db_only=True)))},
        ],
        'hide_object': True,
        'access_object': AccessObject.encapsulate(obj),
        'object': obj,
        'navigation_object_list': [
            {'object': 'object'},
            {'object': 'access_object'}
        ],
    }

    if extra_context:
        context.update(extra_context)

    return render_to_response('generic_list.html', context,
        context_instance=RequestContext(request))
Exemplo n.º 20
0
def acl_list(request, app_label, module_name, object_pk):
    content_type = get_object_or_404(ContentType, app_label=app_label, model=module_name)
    content_object = get_object_or_404(content_type.model_class(), pk=object_pk)
    
    try:
        Permission.objects.check_permissions(request.user, [ACLS_VIEW_ACL])
    except PermissionDenied:
        AccessEntry.objects.check_access(ACLS_VIEW_ACL, request.user, content_object)

    context = {
        'object_list': AccessEntry.objects.get_holders_for(content_object),
        'title': _(u'access control lists for %(object_label)s: %(object)s') % {
            'object_label': content_object._meta.verbose_name,
            'object': content_object
        },
        'extra_columns': [
            {'name': _(u'holder'), 'attribute': encapsulate(lambda x: object_w_content_type_icon(x.source_object))},
            {'name': _(u'permissions'), 'attribute': encapsulate(lambda x: _permission_titles(AccessEntry.objects.get_holder_permissions_for(content_object, x.source_object, db_only=True)))},
        ],

        'hide_object': True,
        'source_object': content_object,
        'object': content_object,
        'navigation_object_list': [
            {'object': 'source_object'},
        ],            
    }
    
    return render_to_response('generic_list.html', context,
        context_instance=RequestContext(request))
Exemplo n.º 21
0
Arquivo: views.py Projeto: x3n0/mayan
def setting_list(request):
    new_settings = []
    for namespace, sub_settings in settings.items():
        for sub_setting in sub_settings:
            if not sub_setting.get('hidden', False):
                new_settings.append({
                    'module':
                    sub_setting['module'],
                    'name':
                    sub_setting['name'],
                    'global_name':
                    sub_setting['global_name'],
                    'description':
                    sub_setting.get('description', None),
                    'exists':
                    sub_setting.get('exists', False),
                    'default':
                    sub_setting['default'],
                })
    context = {
        'title':
        _(u'settings'),
        'object_list':
        new_settings,
        'hide_link':
        True,
        'hide_object':
        True,
        'extra_columns': [
            {
                'name':
                _(u'name'),
                'attribute':
                encapsulate(lambda x: mark_safe(
                    u'<span style="font-weight: bold;">%s</span><br />%s' %
                    (x.get('global_name'), x.get('description'))))
            },
            {
                'name': _(u'default'),
                'attribute': encapsulate(lambda x: return_type(x['default']))
            },
            {
                'name':
                _(u'value'),
                'attribute':
                encapsulate(lambda x: mark_safe(
                    u'<div class="nowrap">%s&nbsp;%s</div>' %
                    (return_type(getattr(x['module'], x['name'])),
                     exists_with_famfam(getattr(x['module'], x['name']))
                     if x['exists'] else '')))
            },
        ]
    }

    return render_to_response('generic_list.html',
                              context,
                              context_instance=RequestContext(request))
Exemplo n.º 22
0
def acl_list(request, app_label, module_name, object_pk):
    content_type = get_object_or_404(ContentType,
                                     app_label=app_label,
                                     model=module_name)
    content_object = get_object_or_404(content_type.model_class(),
                                       pk=object_pk)

    try:
        Permission.objects.check_permissions(request.user, [ACLS_VIEW_ACL])
    except PermissionDenied:
        AccessEntry.objects.check_access(ACLS_VIEW_ACL, request.user,
                                         content_object)

    context = {
        'object_list':
        AccessEntry.objects.get_holders_for(content_object),
        'title':
        _(u'access control lists for %(object_label)s: %(object)s') % {
            'object_label': content_object._meta.verbose_name,
            'object': content_object
        },
        'extra_columns': [
            {
                'name':
                _(u'holder'),
                'attribute':
                encapsulate(
                    lambda x: object_w_content_type_icon(x.source_object))
            },
            {
                'name':
                _(u'permissions'),
                'attribute':
                encapsulate(lambda x: _permission_titles(
                    AccessEntry.objects.get_holder_permissions_for(
                        content_object, x.source_object, db_only=True)))
            },
        ],
        'hide_object':
        True,
        'source_object':
        content_object,
        'object':
        content_object,
        'navigation_object_list': [
            {
                'object': 'source_object'
            },
        ],
    }

    return render_to_response('generic_list.html',
                              context,
                              context_instance=RequestContext(request))
Exemplo n.º 23
0
def index_instance_node_view(request, index_instance_node_pk):
    """
    Show an instance node and it's content, whether is other child nodes
    of documents
    """
    index_instance = get_object_or_404(IndexInstanceNode,
                                       pk=index_instance_node_pk)
    index_instance_list = [
        index for index in index_instance.get_children().order_by('value')
    ]
    breadcrumbs = get_breadcrumbs(index_instance)

    try:
        Permission.objects.check_permissions(
            request.user, [PERMISSION_DOCUMENT_INDEXING_VIEW])
    except PermissionDenied:
        AccessEntry.objects.check_access(PERMISSION_DOCUMENT_INDEXING_VIEW,
                                         request.user, index_instance.index)

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

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

    return render_to_response('generic_list.html', {
        'object_list':
        index_instance_list,
        'extra_columns_preffixed':
        [{
            'name': _(u'node'),
            'attribute': encapsulate(lambda x: index_instance_item_link(x))
        }, {
            'name':
            _(u'items'),
            'attribute':
            encapsulate(lambda x: x.documents.count() if x.index_template_node.
                        link_documents else x.get_children().count())
        }],
        'title':
        title,
        'hide_links':
        True,
        'hide_object':
        True,
        'object':
        index_instance
    },
                              context_instance=RequestContext(request))
Exemplo n.º 24
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))
Exemplo n.º 25
0
def checkout_list(request):
    return document_list(
        request,
        object_list=DocumentCheckout.objects.checked_out_documents(),
        title=_('Documents checked out'),
        extra_context={
            'extra_columns': [
                {'name': _('Checkout user'), 'attribute': encapsulate(lambda document: get_object_name(document.checkout_info().user_object, display_object_type=False))},
                {'name': _('Checkout time and date'), 'attribute': encapsulate(lambda document: document.checkout_info().checkout_datetime)},
                {'name': _('Checkout expiration'), 'attribute': encapsulate(lambda document: document.checkout_info().expiration_datetime)},
            ],
        }
    )
Exemplo n.º 26
0
def index_instance_node_view(request, index_instance_node_pk):
    """
    Show an instance node and it's content, whether is other child nodes
    of documents
    """
    index_instance = get_object_or_404(IndexInstanceNode, pk=index_instance_node_pk)
    index_instance_list = [index for index in index_instance.get_children().order_by("value")]
    breadcrumbs = get_breadcrumbs(index_instance)

    try:
        Permission.objects.check_permissions(request.user, [PERMISSION_DOCUMENT_INDEXING_VIEW])
    except PermissionDenied:
        AccessEntry.objects.check_access(PERMISSION_DOCUMENT_INDEXING_VIEW, request.user, index_instance.index)

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

    if index_instance:
        if index_instance.index_template_node.link_documents:
            # Document list, use the document_list view for consistency
            return document_list(
                request,
                title=title,
                object_list=index_instance.documents.all(),
                extra_context={"object": index_instance},
            )

    return render_to_response(
        "generic_list.html",
        {
            "object_list": index_instance_list,
            "extra_columns_preffixed": [
                {"name": _(u"node"), "attribute": encapsulate(lambda x: index_instance_item_link(x))},
                {
                    "name": _(u"items"),
                    "attribute": encapsulate(
                        lambda x: x.documents.count()
                        if x.index_template_node.link_documents
                        else x.get_children().count()
                    ),
                },
            ],
            "title": title,
            "hide_links": True,
            "hide_object": True,
            "object": index_instance,
        },
        context_instance=RequestContext(request),
    )
Exemplo n.º 27
0
 def get_extra_context(self):
     context = super(DuplicatedDocumentListView, self).get_extra_context()
     context.update(
         {
             'extra_columns': (
                 {
                     'name': _('Duplicates'),
                     'attribute': encapsulate(
                         lambda document: DuplicatedDocument.objects.get(
                             document=document
                         ).documents.count()
                     )
                 },
             ),
             'no_results_icon': icon_duplicated_document_list,
             'no_results_text': _(
                 'Duplicates are documents that are composed of the exact '
                 'same file, down to the last byte. Files that have the '
                 'same text or OCR but are not identical or were saved '
                 'using a different file format will not appear as '
                 'duplicates.'
             ),
             'no_results_title': _(
                 'There are no duplicated documents'
             ),
             'title': _('Duplicated documents')
         }
     )
     return context
Exemplo n.º 28
0
def index_list(request):
    """
    Show a list of enabled indexes
    """
    context = {
        'title':
        _(u'indexes'),
        'hide_links':
        True,
        'extra_columns': [
            {
                'name':
                _(u'nodes'),
                'attribute':
                encapsulate(lambda x: x.instance_root.get_descendant_count())
            },
        ],
    }

    queryset = Index.objects.filter(enabled=True)

    try:
        Permission.objects.check_permissions(
            request.user, [PERMISSION_DOCUMENT_INDEXING_VIEW])
    except PermissionDenied:
        queryset = AccessEntry.objects.filter_objects_by_access(
            PERMISSION_DOCUMENT_INDEXING_VIEW, request.user, queryset)

    context['object_list'] = queryset

    return render_to_response('generic_list.html',
                              context,
                              context_instance=RequestContext(request))
Exemplo n.º 29
0
def folder_list(request, queryset=None, extra_context=None):
    context = {
        'title':
        _(u'folders'),
        'multi_select_as_buttons':
        True,
        'extra_columns': [{
            'name': _(u'created'),
            'attribute': 'datetime_created'
        }, {
            'name':
            _(u'documents'),
            'attribute':
            encapsulate(lambda x: x.folderdocument_set.count())
        }]
    }
    if extra_context:
        context.update(extra_context)

    return object_list(
        request,
        queryset=queryset if not (queryset is None) else Folder.objects.filter(
            user=request.user),
        template_name='generic_list.html',
        extra_context=context,
    )
Exemplo n.º 30
0
def folder_list(request, queryset=None, extra_context=None):
    context = {
        'title': _(u'folders'),
        'multi_select_as_buttons': True,
        'extra_columns': [
            {'name': _(u'created'), 'attribute': 'datetime_created'},
            {'name': _(u'documents'), 'attribute': encapsulate(lambda x: x.folderdocument_set.count())}
        ],
        'hide_link': True,
    }
    if extra_context:
        context.update(extra_context)

    queryset = queryset if not (queryset is None) else Folder.objects.all()

    try:
        Permission.objects.check_permissions(request.user, [PERMISSION_FOLDER_VIEW])
    except PermissionDenied:
        queryset = AccessEntry.objects.filter_objects_by_access(PERMISSION_FOLDER_VIEW, request.user, queryset)

    context['object_list'] = queryset

    return render_to_response('generic_list.html',
        context,
        context_instance=RequestContext(request)
    )
Exemplo n.º 31
0
def folder_list(request, queryset=None, extra_context=None):
    context = {
        'title':
        _(u'folders'),
        'multi_select_as_buttons':
        True,
        'extra_columns': [{
            'name': _(u'created'),
            'attribute': 'datetime_created'
        }, {
            'name':
            _(u'documents'),
            'attribute':
            encapsulate(lambda x: x.folderdocument_set.count())
        }],
        'hide_link':
        True,
    }
    if extra_context:
        context.update(extra_context)

    queryset = queryset if not (queryset is None) else Folder.objects.all()

    try:
        Permission.objects.check_permissions(request.user,
                                             [PERMISSION_FOLDER_VIEW])
    except PermissionDenied:
        queryset = AccessEntry.objects.filter_objects_by_access(
            PERMISSION_FOLDER_VIEW, request.user, queryset)

    context['object_list'] = queryset

    return render_to_response('generic_list.html',
                              context,
                              context_instance=RequestContext(request))
Exemplo n.º 32
0
def metadata_view(request, document_id):
    document = get_object_or_404(Document, pk=document_id)

    try:
        Permission.objects.check_permissions(
            request.user, [PERMISSION_METADATA_DOCUMENT_VIEW])
    except PermissionDenied:
        AccessEntry.objects.check_access(PERMISSION_METADATA_DOCUMENT_VIEW,
                                         request.user, document)

    return render_to_response('main/generic_list.html', {
        'title':
        _('Metadata for document: %s') % document,
        'object_list':
        document.metadata.all(),
        'extra_columns': [{
            'name': _('Value'),
            'attribute': 'value'
        }, {
            'name':
            _('Required'),
            'attribute':
            encapsulate(lambda x: x.metadata_type in document.document_type.
                        metadata.filter(required=True))
        }],
        'hide_link':
        True,
        'object':
        document,
    },
                              context_instance=RequestContext(request))
Exemplo n.º 33
0
def formats_list(request):
    check_permissions(request.user, [CONVERTER_FORMAT_LIST_VIEW])

    context = {
        "title": _(u"suported file formats"),
        "hide_object": True,
        "object_list": sorted(get_format_list()),
        "extra_columns": [
            {"name": _(u"name"), "attribute": encapsulate(lambda x: x[0])},
            {"name": _(u"description"), "attribute": encapsulate(lambda x: x[1])},
        ],
        "backend": GRAPHICS_BACKEND,
        "template_id": u"crud_list",
    }

    return render_to_response("generic_list.html", context, context_instance=RequestContext(request))
Exemplo n.º 34
0
def url_list(request):
#    check_permissions(request.user, [PERMISSION_USER_VIEW])
    title = _(u'static link')
       
    context = {
        'template_id': u'url_list',
        'title': title,
        'extra_columns': [
            {
                'name': _(u'URL'),
                'attribute': 'url'
            },
            {
                'name': _(u'enabled'),
                'attribute': encapsulate(lambda x: two_state_template(x.enabled)),
            },
        ],
        'hide_link': True,
        'multi_select_as_buttons': True,
        'navigation_object_links': [url_edit_link],
    }

    return object_list(
        request,
        queryset=URL.objects.all(),
        template_name='generic_list.html',
        extra_context=context
    )
Exemplo n.º 35
0
def index_list(request):
    """
    Show a list of enabled indexes
    """
    context = {
        'title': _(u'indexes'),
        'hide_links': True,
        'extra_columns': [
            {'name': _(u'nodes'), 'attribute': encapsulate(lambda x: x.instance_root.get_descendant_count())},
        ],
    }

    queryset = Index.objects.filter(enabled=True)

    try:
        Permission.objects.check_permissions(request.user, [PERMISSION_DOCUMENT_INDEXING_VIEW])
    except PermissionDenied:
        queryset = AccessEntry.objects.filter_objects_by_access(PERMISSION_DOCUMENT_INDEXING_VIEW, request.user, queryset)

    context['object_list'] = queryset

    return render_to_response('generic_list.html',
        context,
        context_instance=RequestContext(request)
    )
Exemplo n.º 36
0
def search(request):
    query_string = ''
    found_entries = {}
    object_list = []

    if ('q' in request.GET) and request.GET['q'].strip():
        query_string = request.GET['q']
        form = SearchForm(initial={'q': query_string})

        terms = normalize_query(query_string)

        for model, data in search_list.items():
            query = get_query(terms, data['fields'])

            results = model.objects.filter(query)
            if results:
                found_entries[data['text']] = results
                for result in results:
                    object_list.append(result)
    else:
        form = SearchForm()

    return render_to_response('dynamic_search/search_results.html', {
                            'query_string': query_string,
                            'found_entries': found_entries,
                            'form': form,
                            'object_list': object_list,
                            'form_title': _(u'Search'),
                            'extra_columns': [{'name':_(u'type'), 'attribute': encapsulate(lambda x: x._meta.verbose_name[0].upper() + x._meta.verbose_name[1:])}],
                            'title': _(u'results with: %s') % query_string
                            },
                          context_instance=RequestContext(request))
Exemplo n.º 37
0
def history_for_object(request, app_label, module_name, object_id):
    model = get_model(app_label, module_name)
    if not model:
        raise Http404
    content_object = get_object_or_404(model, pk=object_id)
    content_type = ContentType.objects.get_for_model(model)

    try:
        Permission.objects.check_permissions(request.user, [PERMISSION_HISTORY_VIEW])
    except PermissionDenied:
        AccessEntry.objects.check_access(PERMISSION_HISTORY_VIEW, request.user, content_object)

    context = {
        'object_list': History.objects.filter(content_type=content_type, object_id=object_id),
        'title': _(u'history events for: %s') % content_object,
        'object': content_object,
        'extra_columns': [
            {
                'name': _(u'date and time'),
                'attribute': 'datetime'
            },
            {
                'name': _(u'summary'),
                'attribute': encapsulate(lambda x: history_entry_summary(x))
            }
        ],
        'hide_object': True,
    }

    return render_to_response('generic_list.html', context,
        context_instance=RequestContext(request))
Exemplo n.º 38
0
def setup_source_transformation_list(request, source_type, source_id):
    Permission.objects.check_permissions(request.user, [PERMISSION_SOURCES_SETUP_EDIT])

    if source_type == SOURCE_CHOICE_WEB_FORM:
        cls = WebForm
    elif source_type == SOURCE_CHOICE_STAGING:
        cls = StagingFolder
    elif source_type == SOURCE_CHOICE_WATCH:
        cls = WatchFolder

    source = get_object_or_404(cls, pk=source_id)

    context = {
        'object_list': SourceTransformation.transformations.get_for_object(source),
        'title': _(u'transformations for: %s') % source.fullname(),
        'source': source,
        'object_name': _(u'source'),
        'navigation_object_name': 'source',
        'list_object_variable_name': 'transformation',
        'extra_columns': [
            {'name': _(u'order'), 'attribute': 'order'},
            {'name': _(u'transformation'), 'attribute': encapsulate(lambda x: x.get_transformation_display())},
            {'name': _(u'arguments'), 'attribute': 'arguments'}
            ],
        'hide_link': True,
        'hide_object': True,
    }

    return render_to_response('generic_list.html', context,
        context_instance=RequestContext(request))
Exemplo n.º 39
0
def history_list(request, object_list=None, title=None, extra_context=None):
    pre_object_list = object_list if not (object_list is None) else History.objects.all()

    try:
        Permission.objects.check_permissions(request.user, [PERMISSION_HISTORY_VIEW])
    except PermissionDenied:
        # If user doesn't have global permission, get a list of document
        # for which he/she does hace access use it to filter the
        # provided object_list
        final_object_list = AccessEntry.objects.filter_objects_by_access(PERMISSION_HISTORY_VIEW, request.user, pre_object_list, related='content_object')
    else:
        final_object_list = pre_object_list

    context = {
        'object_list': final_object_list,
        'title': title if title else _(u'history events'),
        'extra_columns': [
            {
                'name': _(u'object link'),
                'attribute': encapsulate(lambda x: history_entry_object_link(x))
            },
        ],
        'hide_object': True,
    }

    if extra_context:
        context.update(extra_context)

    return render_to_response('generic_list.html', context,
        context_instance=RequestContext(request))
Exemplo n.º 40
0
def smart_link_list(request):
    qs = SmartLink.objects.all()

    try:
        Permission.objects.check_permissions(request.user,
                                             [PERMISSION_SMART_LINK_VIEW])
    except PermissionDenied:
        qs = AccessEntry.objects.filter_objects_by_access(
            PERMISSION_SMART_LINK_VIEW, request.user, qs)

    return render_to_response('generic_list.html', {
        'title':
        _(u'smart links'),
        'object_list':
        qs,
        'extra_columns': [
            {
                'name': _(u'dynamic title'),
                'attribute': 'dynamic_title'
            },
            {
                'name': _(u'enabled'),
                'attribute':
                encapsulate(lambda x: two_state_template(x.enabled))
            },
        ],
        'hide_link':
        True,
        'list_object_variable_name':
        'smart_link',
    },
                              context_instance=RequestContext(request))
Exemplo n.º 41
0
def page_list(request):
#    check_permissions(request.user, [PERMISSION_USER_VIEW])
    context = {
        'template_id': u'crud_list',
        'title': _(u'CMS pages'),
        'extra_columns': [
            {
                'name': _(u'title'),
                'attribute': 'title'
            },            
            {
                'name': _(u'name'),
                'attribute': 'slug'
            },
            {
                'name': _(u'enabled'),
                'attribute': encapsulate(lambda x: two_state_template(x.enabled)),
            },
        ],
        'multi_select_as_buttons': True,
        'hide_object': True,
        'navigation_object_links': [page_edit_link, page_preview_link, page_render_link],
    }

    return object_list(
        request,
        queryset=Page.objects.all(),
        template_name='generic_list.html',
        extra_context=context
    )
Exemplo n.º 42
0
def acl_class_acl_detail(request, access_object_class_gid, holder_object_gid):
    Permission.objects.check_permissions(request.user, [ACLS_CLASS_VIEW_ACL])
    try:
        actor = AccessHolder.get(gid=holder_object_gid)
        access_object_class = AccessObjectClass.get(
            gid=access_object_class_gid)
    except ObjectDoesNotExist:
        raise Http404

    permission_list = get_class_permissions_for(
        access_object_class.content_type.model_class())
    #TODO : get all globally assigned permission, new function get_permissions_for_holder (roles aware)
    subtemplates_list = [
        {
            'name': u'generic_list_subtemplate.html',
            'context': {
                'title':
                _(u'permissions available to: %(actor)s for class %(class)s' %
                  {
                      'actor': actor,
                      'class': access_object_class
                  }),
                'object_list':
                permission_list,
                'extra_columns': [
                    {
                        'name': _(u'namespace'),
                        'attribute': 'namespace'
                    },
                    {
                        'name': _(u'label'),
                        'attribute': 'label'
                    },
                    {
                        'name':
                        _(u'has permission'),
                        'attribute':
                        encapsulate(lambda x: two_state_template(
                            DefaultAccessEntry.objects.has_access(
                                x, actor.source_object, access_object_class.
                                source_object)).display_small())
                    },
                ],
                'hide_object':
                True,
            }
        },
    ]

    return render_to_response('generic_detail.html', {
        'object': access_object_class,
        'subtemplates_list': subtemplates_list,
        'multi_select_as_buttons': True,
        'multi_select_item_properties': {
            'permission_pk': lambda x: x.pk,
            'holder_gid': lambda x: actor.gid,
            'access_object_class_gid': lambda x: access_object_class.gid,
        },
    },
                              context_instance=RequestContext(request))
Exemplo n.º 43
0
def history_for_object(request, app_label, module_name, object_id):
    check_permissions(request.user, [PERMISSION_HISTORY_VIEW])

    model = get_model(app_label, module_name)
    if not model:
        raise Http404
    content_object = get_object_or_404(model, pk=object_id)
    content_type = ContentType.objects.get_for_model(model)

    context = {
        'object_list':
        History.objects.filter(content_type=content_type, object_id=object_id),
        'title':
        _(u'history events for: %s') % content_object,
        'object':
        content_object,
        'extra_columns': [{
            'name': _(u'date and time'),
            'attribute': 'datetime'
        }, {
            'name':
            _(u'summary'),
            'attribute':
            encapsulate(lambda x: history_entry_summary(x))
        }],
        'hide_object':
        True,
    }

    return render_to_response('generic_list.html',
                              context,
                              context_instance=RequestContext(request))
Exemplo n.º 44
0
def smart_link_condition_list(request, smart_link_pk):
    smart_link = get_object_or_404(SmartLink, pk=smart_link_pk)

    try:
        Permission.objects.check_permissions(
            request.user,
            [PERMISSION_SMART_LINK_CREATE, PERMISSION_SMART_LINK_EDIT])
    except PermissionDenied:
        AccessEntry.objects.check_accesses(
            [PERMISSION_SMART_LINK_CREATE, PERMISSION_SMART_LINK_EDIT],
            request.user, smart_link)

    return render_to_response('generic_list.html', {
        'title':
        _(u'conditions for smart link: %s') % smart_link,
        'object_list':
        smart_link.smartlinkcondition_set.all(),
        'extra_columns': [
            {
                'name': _(u'enabled'),
                'attribute':
                encapsulate(lambda x: two_state_template(x.enabled))
            },
        ],
        'hide_link':
        True,
        'object':
        smart_link,
        'list_object_variable_name':
        'condition',
    },
                              context_instance=RequestContext(request))
Exemplo n.º 45
0
def smart_link_list(request):
    check_permissions(request.user, [PERMISSION_SMART_LINK_CREATE])

    return render_to_response('generic_list.html', {
        'title':
        _(u'smart links'),
        'object_list':
        SmartLink.objects.all(),
        'extra_columns': [
            {
                'name': _(u'dynamic title'),
                'attribute': 'dynamic_title'
            },
            {
                'name': _(u'enabled'),
                'attribute':
                encapsulate(lambda x: two_state_template(x.enabled))
            },
        ],
        'hide_link':
        True,
        'list_object_variable_name':
        'smart_link',
    },
                              context_instance=RequestContext(request))
Exemplo n.º 46
0
def setup_source_transformation_list(request, source_type, source_id):
    Permission.objects.check_permissions(request.user, [PERMISSION_SOURCES_SETUP_EDIT])

    if source_type == SOURCE_CHOICE_WEB_FORM:
        cls = WebForm
    elif source_type == SOURCE_CHOICE_STAGING:
        cls = StagingFolder
    elif source_type == SOURCE_CHOICE_WATCH:
        cls = WatchFolder

    source = get_object_or_404(cls, pk=source_id)

    context = {
        'object_list': SourceTransformation.transformations.get_for_object(source),
        'title': _(u'transformations for: %s') % source.fullname(),
        'source': source,
        'object_name': _(u'source'),
        'navigation_object_name': 'source',
        'list_object_variable_name': 'transformation',
        'extra_columns': [
            {'name': _(u'order'), 'attribute': 'order'},
            {'name': _(u'transformation'), 'attribute': encapsulate(lambda x: x.get_transformation_display())},
            {'name': _(u'arguments'), 'attribute': 'arguments'}
            ],
        'hide_link': True,
        'hide_object': True,
    }

    return render_to_response('generic_list.html', context,
        context_instance=RequestContext(request))
Exemplo n.º 47
0
def index_setup_list(request):
    context = {
        'title': _(u'indexes'),
        'hide_object': True,
        'list_object_variable_name': 'index',
        'extra_columns': [
            {'name': _(u'name'), 'attribute': 'name'},
            {'name': _(u'title'), 'attribute': 'title'},
            {'name': _(u'enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))},
        ]
    }

    queryset = Index.objects.all()

    try:
        Permission.objects.check_permissions(request.user, [PERMISSION_DOCUMENT_INDEXING_SETUP])
    except PermissionDenied:
        queryset = AccessEntry.objects.filter_objects_by_access(PERMISSION_DOCUMENT_INDEXING_SETUP, request.user, queryset)

    context['object_list'] = queryset

    return render_to_response('generic_list.html',
        context,
        context_instance=RequestContext(request)
    )
Exemplo n.º 48
0
def key_list(request, secret=True):
    Permission.objects.check_permissions(request.user, [PERMISSION_KEY_VIEW])

    if secret:
        object_list = Key.get_all(gpg, secret=True)
        title = _(u'private keys')
    else:
        object_list = Key.get_all(gpg)
        title = _(u'public keys')

    return render_to_response('generic_list.html', {
        'object_list': object_list,
        'title': title,
        'hide_object': True,
        'extra_columns': [
            {
                'name': _(u'Key ID'),
                'attribute': 'key_id',
            },
            {
                'name': _(u'Owner'),
                'attribute': encapsulate(lambda x: u', '.join(x.uids)),
            },
        ]
    }, context_instance=RequestContext(request))
Exemplo n.º 49
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))
Exemplo n.º 50
0
def index_instance_node_view(request, index_instance_node_pk):
    """
    Show an instance node and it's content, whether is other child nodes
    of documents
    """
    index_instance = get_object_or_404(IndexInstanceNode, pk=index_instance_node_pk)
    index_instance_list = [index for index in index_instance.get_children().order_by('value')]
    breadcrumbs = get_breadcrumbs(index_instance)

    try:
        Permission.objects.check_permissions(request.user, [PERMISSION_DOCUMENT_INDEXING_VIEW])
    except PermissionDenied:
        AccessEntry.objects.check_access(PERMISSION_DOCUMENT_INDEXING_VIEW, request.user, index_instance.index)

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

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

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

    }, context_instance=RequestContext(request))
Exemplo n.º 51
0
 def get_extra_context(self):
     return {
         'extra_columns': (
             {
                 'name': _('Type'),
                 'attribute': encapsulate(lambda entry: entry.class_fullname())
             },
             {
                 'name': _('Enabled'),
                 'attribute': encapsulate(
                     lambda entry: TwoStateWidget(state=entry.enabled).render()
                 )
             },
         ),
         'hide_link': True,
         'no_results_icon': icon_setup_sources,
         'no_results_secondary_links': [
             link_setup_source_create_webform.resolve(
                 context=RequestContext(request=self.request)
             ),
             link_setup_source_create_imap_email.resolve(
                 context=RequestContext(request=self.request)
             ),
             link_setup_source_create_pop3_email.resolve(
                 context=RequestContext(request=self.request)
             ),
             link_setup_source_create_sane_scanner.resolve(
                 context=RequestContext(request=self.request)
             ),
             link_setup_source_create_staging_folder.resolve(
                 context=RequestContext(request=self.request)
             ),
             link_setup_source_create_watch_folder.resolve(
                 context=RequestContext(request=self.request)
             ),
         ],
         'no_results_text': _(
             'Sources provide the means to upload documents. '
             'Some sources like the webform, are interactive and require '
             'user input to operate. Others like the email sources, are '
             'automatic and run on the background without user intervention.'
         ),
         'no_results_title': _('No sources available'),
         'title': _('Sources'),
     }
Exemplo n.º 52
0
 def get_extra_context(self):
     return {
         'extra_columns': (
             {
                 'name': _('Type'),
                 'attribute':
                 encapsulate(lambda entry: entry.class_fullname())
             },
             {
                 'name':
                 _('Enabled'),
                 'attribute':
                 encapsulate(lambda entry: TwoStateWidget(state=entry.
                                                          enabled).render())
             },
         ),
         'hide_link':
         True,
         'no_results_icon':
         icon_setup_sources,
         'no_results_secondary_links': [
             link_setup_source_create_webform.resolve(
                 context=RequestContext(request=self.request)),
             link_setup_source_create_imap_email.resolve(
                 context=RequestContext(request=self.request)),
             link_setup_source_create_pop3_email.resolve(
                 context=RequestContext(request=self.request)),
             link_setup_source_create_sane_scanner.resolve(
                 context=RequestContext(request=self.request)),
             link_setup_source_create_staging_folder.resolve(
                 context=RequestContext(request=self.request)),
             link_setup_source_create_watch_folder.resolve(
                 context=RequestContext(request=self.request)),
         ],
         'no_results_text':
         _('Sources provide the means to upload documents. '
           'Some sources like the webform, are interactive and require '
           'user input to operate. Others like the email sources, are '
           'automatic and run on the background without user intervention.'
           ),
         'no_results_title':
         _('No sources available'),
         'title':
         _('Sources'),
     }
Exemplo n.º 53
0
def user_list(request):
    Permission.objects.check_permissions(request.user, [PERMISSION_USER_VIEW])

    context = {
        "object_list": get_user_model().objects.exclude(is_superuser=True).exclude(is_staff=True).order_by("username"),
        "title": _("Users"),
        "hide_link": True,
        "extra_columns": [
            {"name": _("Full name"), "attribute": "get_full_name"},
            {"name": _("Email"), "attribute": "email"},
            {"name": _("Active"), "attribute": encapsulate(lambda x: two_state_template(x.is_active))},
            {
                "name": _("Has usable password?"),
                "attribute": encapsulate(lambda x: two_state_template(x.has_usable_password())),
            },
        ],
    }

    return render_to_response("main/generic_list.html", context, context_instance=RequestContext(request))
Exemplo n.º 54
0
class SetupSourceListView(SingleObjectListView):
    extra_context = {
        'extra_columns': (
            {
                'name': _('Type'),
                'attribute': encapsulate(lambda entry: entry.class_fullname())
            },
            {
                'name': _('Enabled'),
                'attribute': encapsulate(
                    lambda entry: two_state_template(entry.enabled)
                )
            },
        ),
        'hide_link': True,
        'title': _('Sources'),
    }
    queryset = Source.objects.select_subclasses()
    view_permission = permission_sources_setup_view